HaarigerHarald / android-youtubeExtractor

Deprecated: Android based YouTube URL extractor and downloader
Other
877 stars 304 forks source link

ytFiles null on some videos #147

Open FelipeRRM opened 4 years ago

FelipeRRM commented 4 years ago

Most of the videos work, but some do not. This one for example: https://www.youtube.com/watch?v=6gkdOX-c7iI as ytFiles comes as null. I have enabled logging and tried extracting it and this is what I got on the logs:

YouTubeExtractor: infoUrl: https://www.youtube.com/get_video_info?video_id=6gkdOX-c7iI&eurl=https%3A%2F%2Fyoutube.googleapis.com%2Fv%2F6gkdOX-c7iI

YouTubeExtractor: cbr=Chrome&cosver=6.1&innertube_context_client_version=1.20200528.05.00&player_response={"responseContext":{"serviceTrackingParams":[{"service":"GFEEDBACK","params":[{"key":"is_viewed_live","value":"False"},{"key":"logged_in","value":"0"},{"key":"e","value":"23804281,23897262,23903928,23860859,23898470,23898053,23907436,23873111,23834813,23905093,23709532,23874981,23872378,23906818,23880323,23882437,23888210,23907595,23768776,23887808,23907818,23884593,23897872,23898728,23870854,23857970,23902424,23906941,23905034,23893661,23886973,1714258,23880619,23890721,23862065,23900237,23898871,23837886,23880389,23903164,23883172,23908060,23888133,23871729,23884998,23841635,23882884,23839597,23874051,23907456,23885293,23904156,24650112,23862582,23877770,23904983,23869558,23744176,23858785,23854276,23897259,23894440,23902293,23903983,23906500,9473375,23905291,23905514,23882502,23884386,23894533,23905126,23811986,23906706,23853651,23832002,23907080,23861905,23901904,23895498,23865206,23836115,23895275,23900789,23876128,23863739,23890680,23902105,23900854,23889702,23909259,23896705,23869527,23872921,23882555,23897503,23909180,23862294,23833239,23897466,23902428,23895138,23895174,23841299,23885215,23816681,23882130,23834232,23889408,23894708,23837993,23896984,9473387,23858564,23885639,23797973,23842233,23878154,23884697,23900839,23883974,23892983,23905827,23891847,23882111,23872595,45170004,23859025,23861666,23899299,23853114,23790586,23842638,23882126,23902261,23905490,39320688,23755966,23794339,23902304,23896443,23890891,23908963,9473393,23861263,23862025,23887007,23874940,23821055,23904051,23906756,23854352,23789385"}]},{"service":"CSI","params":[{"key":"yt_ad","value":"1"},{"key":"c","value":"WEB"},{"key":"cver","value":"1.20200528.05.00"},{"key":"yt_li","value":"0"},{"key":"GetPlayer_rid","value":"0xed04698f840d87b6"}]},{"service":"GUIDED_HELP","params":[{"key":"logged_in","value":"0"}]}]},"playabilityStatus":{"status":"OK","playableInEmbed":true,"contextParams":"Q0FFU0FnZ0I="},"streamingData":{"expiresInSeconds":"21540","formats":[{"itag":18,"mimeType":"video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"","bitrate":551438,"width":640,"height":360,"lastModified":"1588190407663526","contentLength":"19374809","quality":"medium","fps":30,"qualityLabel":"360p","projectionType":"RECTANGULAR","averageBitrate":551307,"audioQuality":"AUDIO_QUALITY_LOW","approxDurationMs":"281147","audioSampleRate":"44100","audioChannels":2,"signatureCipher":"s=gOq0QJ8w4AIIB-Ipz6H9q1t0A3oBHTtfUPmE-vTPAb_TEu2jRtGqoFYCIDGbrwKJSKAjFqREMI_-QVesrB5ZoevUIGqvbMoTwzSL&sp=sig&url=https://r3---sn-cgxqc5oqufv-5goe.googlevideo.com/videoplayback%3Fexpire%3D1590779586%26ei%3DYgrRXoDuBIqq7ASMzpCQBQ%26ip%3D31.208.64.213%26id%3Do-ADNdL_ZtrGwyzTaHvllvg-ihAZYiT_179ZfpYTIntSjq%26itag%3D18%26source%3Dyoutube%26requiressl%3Dyes%26mh%3D8H%26mm%3D31%252C26%26mn%3Dsn-cgxqc5oqufv-5goe%252Csn-i5heen7z%26ms%3Dau%252Conr%26mv%3Dm%26mvi%3D2%26pl%3D23%26initcwndbps%3D1727500%26vprv%3D1%26mime%3Dvideo%252Fmp4%26gir%3Dyes%26clen%3D19374809%26ratebypass%3Dyes%26dur%3D281.147%26lmt%3D1588190407663526%26mt%3D1590757820%26fvip%3D3%26c%3DWEB%26txp%3D6316222%26sparams%3Dexpire%252Cei%252Cip%252Cid%252Citag%252Csource%252Crequiressl%252Cvprv%252Cmime%252Cgir%252Cclen%252Cratebypass%252Cdur%252Clmt%26lsparams%3Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%252Cinitcwndbps%26lsig%3DAG3C_xAwRQIhANzJSYW1QwLIJ8ZfOymx-ddNPMlU5BKy1J1WjNreQomtAiAuOEvLC0BrN_kNCeFyo8w-yvh3ebNxGeFdomCBVT1SDw%253D%253D"}],"adaptiveFormats":[{"itag":136,"mimeType":"video/mp4; codecs=\"avc1.4d401f\"","bitrate":2304853,"width":1280,"height":720,"initRange":{"start":"0","end":"738"},"indexRange":{"start":"739","end":"1454"},"lastModified":"1588190358970542","contentLength":"62925527","quality":"hd720","fps":30,"qualityLabel":"720p","projectionType":"RECTANGULAR","averageBitrate":1790964,"approxDurationMs":"281080","signatureCipher":"s=hOq0QJ8w4QIfAKMwubOXQLRxUuuVjQosCmlv41IQAvxuytbG6qZgnQKgAiA0dtqaSwLStMRbST-awMh0o1lMZwnjpgVjR2qBor0fJg%3D%3D&sp=sig&url=https://r3---sn-cgxqc5oqufv-5goe.goo
Inside4ndroid commented 4 years ago

okay

after doing some testing it seems that any youtube url which has adverts returns ytFiles as null

but youtube urls withou adverts work as normal..

for reference :

WITHOUT ADVERTS = https://www.youtube.com/watch?v=XVHReeBQFtA

WITH ADVERTS - https://www.youtube.com/watch?v=2mY7AFTtYwQ

first works fine an second returns null??

xibr commented 4 years ago

simple fix change this line private static final Pattern patCipher = Pattern.compile("\"cipher\"\\s*:\\s*\"(.+?)\""); in YouTubeExtractor.java

to this private static final Pattern patCipher = Pattern.compile("\"signatureCipher\"\\s*:\\s*\"(.+?)\"");

Inside4ndroid commented 4 years ago

simple fix change this line private static final Pattern patCipher = Pattern.compile("\"cipher\"\\s*:\\s*\"(.+?)\""); in YouTubeExtractor.java

to this private static final Pattern patCipher = Pattern.compile("\"signatureCipher\"\\s*:\\s*\"(.+?)\"");

Tried that fix already but it still won't work any videos which are monetized with ads.

xibr commented 4 years ago

Maybe Another problem !!, can you give some links that don't work.

xibr commented 4 years ago

WITH ADVERTS - https://www.youtube.com/watch?v=2mY7AFTtYwQ

This link works.

JmyW commented 4 years ago

Thanks for you guys help. But I try, still failed :( . For examples:

https://www.youtube.com/watch?v=AgFeZr5ptV8 https://www.youtube.com/watch?v=kxloC1MKTpg https://www.youtube.com/watch?v=LzCPcJHx5y8

Inside4ndroid commented 4 years ago

WITH ADVERTS - https://www.youtube.com/watch?v=2mY7AFTtYwQ

This link works.

i am still having the same issue with the above link even after doing the cipher regex change...

for me it seems to be every url with adverts in the video that dont work... all other links without adverts work just fine for me?? wonder what it could be??

xibr commented 4 years ago

check this apk advancedDownloader-debug.zip

Inside4ndroid commented 4 years ago

check this apk advancedDownloader-debug.zip

installed it but there is no app icon and cant open it from app settings am i doing something wrong?

EDIT: i went to youtube and shred vido to app and it seems to work okay.. i will test a few links that were not working for me

Inside4ndroid commented 4 years ago

seems to work fine?? but wont work in my java code??

this is how i am using extractor:

new YouTubeExtractor(getContext()) {
                    @Override
                    public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta vMeta) {
                        if (ytFiles != null) {
                            int itag = 22;
                            String downloadUrl = ytFiles.get(itag).getUrl();
                            timertask(downloadUrl, title);
                        } else {
                            Log.d("YT FILES WAS NULL ", "NULL");
                        }
                    }
                }.extract("https://www.youtube.com/watch?v=2mY7AFTtYwQ", true, true);

and the timertask(downloadUrl, title); just passes the url and title to my player.

xibr commented 4 years ago

The problem in your code, I will check later.

Inside4ndroid commented 4 years ago

being doing some exploring and i have opened 2 youtube url's one that works for me and one that dont work and i have found that the one that doesnt work the html sorce does not contain the cipher regex at all example::

WORKING - view-source:https://www.youtube.com/watch?v=SD4Z8dlZPd8 this contains the signatureCipher and i also noted that in the source there is "useCipher":true

NOT WORKING - view-source:https://www.youtube.com/watch?v=pPw_izFr5PA this does not contain signatureCipher or cipher and i also noted that in the source there is "useCipher":false

hope that helps?

xibr commented 4 years ago

@Inside4ndroid Do you still have a problem?

JmyW commented 4 years ago

@Inside4ndroid Do you still have a problem?

It works. But sometimes it extracts the url like "https:\/\/r8---sn-ipoxu-un5l.googlevideo.com\/vide ... ..." with redundant "\" on every "/", sometimes good like "https://r5---sn-ipoxu-un5e.googlevideo.com/videoplay ... ...".

So, I need to replace all \/ to / by myself after extractor. Not sure whether anybody see the same issue.

Inside4ndroid commented 4 years ago

@Inside4ndroid Do you still have a problem?

all seems to be okay and working well now pal...

although most urls return // as \/\/ so manually have to do a replace on returned urls which is not a aproblem really...

thanks for all your help :)

Skelorc commented 4 years ago

Hi all. When a try take link from new YouTubeExtractor(this) { @Override protected void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta videoMeta) { if (ytFiles != null) { int itag = 22; String newDownloadUrl = ytFiles.get(itag).getUrl(); System.out.println(newDownloadUrl); /*downloadFile.downloadImage(newDownloadUrl);*/ } else { System.out.println(ytFiles); } } }.extract("https://www.youtube.com/watch?v=2mY7AFTtYwQ",true,true); i have a error : A/libc: Fatal signal 4 (SIGILL), code 2, fault addr 0xf6ee0477 in tid 12229 (AsyncTask #1). Can some help me?

Inside4ndroid commented 4 years ago

Hi all. When a try take link from new YouTubeExtractor(this) { @Override protected void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta videoMeta) { if (ytFiles != null) { int itag = 22; String newDownloadUrl = ytFiles.get(itag).getUrl(); System.out.println(newDownloadUrl); /*downloadFile.downloadImage(newDownloadUrl);*/ } else { System.out.println(ytFiles); } } }.extract("https://www.youtube.com/watch?v=2mY7AFTtYwQ",true,true); i have a error : A/libc: Fatal signal 4 (SIGILL), code 2, fault addr 0xf6ee0477 in tid 12229 (AsyncTask #1). Can some help me?

i get the same as above it looks like youtube have changed something so the extractor returns this fatal error... we will have to wait for a fix ...

xibr commented 4 years ago

So far working with me, could you provide some links!

williamycyh commented 4 years ago

So far working with me, could you provide some links!

I tried 11 links, 8 can be extracted. There are 3 no. Can you help, the link is: https://www.youtube.com/watch?v=2n6YaiWrsPI https://www.youtube.com/watch?v=7ynrOq3vBq4 https://www.youtube.com/watch?v=-KqxoCdbzrc10

chetanparmar95 commented 3 years ago

Getting same issue for some videos (null ytfiles)

xingyanna commented 3 years ago

I still have the same problem ,xibr can you help me

Skelorc commented 3 years ago

What a problem?10.02.2021, 08:52, "xingyanna" notifications@github.com: I still have the same problem ,xibr can you help me

—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.

MixalisTselepatiotis commented 1 year ago

Try this int tag = 18;

instead of

int tag = 22;