Closed devnullpointer closed 3 years ago
Do you have any specific error message?
E/com.totalgreek.media.activities.MainActivity: Unable to parse Youtube content.
com.github.kiulian.downloader.YoutubeException$BadPageException: Streaming data not found
at com.github.kiulian.downloader.parser.DefaultParser.parseFormats(DefaultParser.java:189)
at com.github.kiulian.downloader.YoutubeDownloader.getVideo(YoutubeDownloader.java:59)
at com.totalgreek.media.activities.MainActivity$AsyncLoadYoutubeContent.doInBackground(MainActivity.java:461)
at com.myapp.media.activities.MainActivity$AsyncLoadYoutubeContent.doInBackground(MainActivity.java:453)
at android.os.AsyncTask$3.call(AsyncTask.java:378)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
@devnullpointer I just tested your videoId dC3-ISvqnJI
and it works fine. The error looks strage, because it appears here https://github.com/sealedtx/java-youtube-downloader/blob/45c48d53b7325f920adacbcfcd8fc0d51773f4c2/src/main/java/com/github/kiulian/downloader/parser/DefaultParser.java#L189
but same "streaming data" should be requested earlier here https://github.com/sealedtx/java-youtube-downloader/blob/45c48d53b7325f920adacbcfcd8fc0d51773f4c2/src/main/java/com/github/kiulian/downloader/parser/DefaultParser.java#L116
Could you please attach html webpage response from this code snippet:
String html = new DefaultExtractor().loadUrl("https://www.youtube.com/watch?v=dC3-ISvqnJI")
And BTW, @poornerd, do we actually need to parse formats if video is live? I think it is useless, because those formats have urls to only ~5 seconds of video stream. Live HLS url should be enough for such videos.
@sealedtx Here you go...
@sealedtx you are right - we probably do not need to parse the others if it is a live stream.
@devnullpointer I replaced html content with your file and it can be parsed successfully. Did you get this file from same device/network connection as you tried youtube.getVideo(...)
?
If everything is same, please, verify that you use latest version and test it your video again.
@sealedtx yes I did. I'm running 2.5.1 and this is the method I'm calling. If I trace the code getVideo throws the exception.
try {
final String url = "https://www.youtube.com/watch?v=dC3-ISvqnJI";
final YoutubeDownloader youtube = new YoutubeDownloader();
final YoutubeVideo video = youtube.getVideo(url);
final Format formatByItag = video.findFormatByItag(137);
return formatByItag.url();
}
catch (final YoutubeException yex)
{
Log.e(TAG, "Unable to parse Youtube content.", yex);
return null;
}
@devnullpointer You should pass videoId instead of full url.
String videoId = dC3-ISvqnJI
YoutubeVideo video = youtube.getVideo(videoId);
Look at Usage section of README
Well that seemed to have worked, sorry I missed that in the README. Problem now is that playing the url in the formats list is returning a 403 Forbidden error. I guess I need to figure out what headers I need to pass unless you have an idea which ones are required?
@devnullpointer are you still talking about live video? For live video you may use live url, not from formats:
YoutubeVideo video = downloader.getVideo(videoId);
System.out.println("Live Stream HLS URL: " + video.details().liveUrl());`
Perfect. Mucho appreciated!
Using the library to parse the following youtube live stream: https://www.youtube.com/embed/dC3-ISvqnJI?rel=0&autoplay=1 and I'm getting a BadPageException: Streaming data not found. I've also tried with https://www.youtube.com/watch?v=dC3-ISvqnJI