android-youtubeExtractor icon indicating copy to clipboard operation
android-youtubeExtractor copied to clipboard

ytFiles null on some videos

Open FelipeRRM opened this issue 5 years ago • 23 comments
trafficstars

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

FelipeRRM avatar May 29 '20 13:05 FelipeRRM

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??

Inside4ndroid avatar Jun 03 '20 11:06 Inside4ndroid

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*\"(.+?)\"");

xibr avatar Jun 03 '20 20:06 xibr

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.

Inside4ndroid avatar Jun 03 '20 20:06 Inside4ndroid

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

xibr avatar Jun 03 '20 20:06 xibr

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

This link works.

xibr avatar Jun 03 '20 20:06 xibr

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

JmyW avatar Jun 04 '20 00:06 JmyW

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??

Inside4ndroid avatar Jun 04 '20 14:06 Inside4ndroid

check this apk advancedDownloader-debug.zip

xibr avatar Jun 04 '20 15:06 xibr

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 avatar Jun 04 '20 15:06 Inside4ndroid

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.

Inside4ndroid avatar Jun 04 '20 15:06 Inside4ndroid

The problem in your code, I will check later.

xibr avatar Jun 04 '20 15:06 xibr

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?

Inside4ndroid avatar Jun 04 '20 16:06 Inside4ndroid

@Inside4ndroid Do you still have a problem?

xibr avatar Jun 06 '20 08:06 xibr

@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.

JmyW avatar Jun 07 '20 01:06 JmyW

@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 :)

Inside4ndroid avatar Jun 07 '20 09:06 Inside4ndroid

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?

Skelorc avatar Jun 30 '20 10:06 Skelorc

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 ...

Inside4ndroid avatar Jun 30 '20 13:06 Inside4ndroid

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

xibr avatar Jun 30 '20 15:06 xibr

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

williamycyh avatar Jul 16 '20 08:07 williamycyh

Getting same issue for some videos (null ytfiles)

chetanparmar95 avatar Nov 29 '20 19:11 chetanparmar95

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

xingyanna avatar Feb 10 '21 05:02 xingyanna

What a problem?10.02.2021, 08:52, "xingyanna" [email protected]: 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.

Skelorc avatar Mar 07 '21 06:03 Skelorc

Try this int tag = 18;

instead of

int tag = 22;

MixalisTselepatiotis avatar Dec 06 '22 00:12 MixalisTselepatiotis