HaarigerHarald / android-youtubeExtractor

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

[Get_Cipher_Signature] Cipher signature not getting properly. #165

Open suryajanaki opened 3 years ago

suryajanaki commented 3 years ago

Hi,

I found a defect while reading/getting cipher signature from matcher group. Pattern patEncSig = Pattern.compile("s=(.{10,}?)(\\\\u0026|\z)");

mat2 = patEncSig.matcher(cipher); if (mat2.find()) { sig = URLDecoder.decode(mat2.group(1), "UTF-8"); Qlog.d(TAG,"The final signature is : "+sig); } else {

Here the "sig" value always containing with like" s=AAOq0QJ8wRQIhAPZdMBlmj8ukXEvNmGhFK_KPU_zC0xOEu8FyR2AK%3DyvQAiAF67RVeMm3x7GqcD7WnUGE37aAbIk0mxgXsAqYFnwF3w%3D%3Dw%3Dw%3D\u0026sp=sig\u0026url=https://r3---sn-ci5gup-itqs.googlevideo.com/........"

Actually we have to get sig= "s=AAOq0QJ8wRQIhAPZdMBlmj8ukXEvNmGhFK_KPU_zC0xOEu8FyR2AK%3DyvQAiAF67RVeMm3x7GqcD7WnUGE37aAbIk0mxgXsAqYFnwF3w%3D%3Dw%3D_w%3D"

Due this we can't able to decry pt the signature. And eventually the videos is not panel. Could you suggest me in this!

Thank You

lortspogi commented 3 years ago

Hi, I noticed that the video that I'm playing is always HTTP ERROR 403, but when I checked the logs we have the same issue.

Dolanpls commented 3 years ago

I think that the error 403 is because youtube detects multiple calls from your IP and block your access for some time

Do the same test with a VPN to see if the same error happend (with same video)

suryajanaki commented 3 years ago

I tried with the same but the same issue. At last i decrypted the sign and added to the end of the URL, then its working. I think the signature is not in the correct format. seems it's appending with "\u0026" and some other characters at the end of the signature where we get after matcher.

lortspogi commented 3 years ago

I tried using vpn same result.

https://r2---sn-oxmavbpj2i-hoae.googlevideo.com/videoplayback?expire=1607703044&ei=pEXTX5jjOcW8gQPghLn4CA&ip=103.206.80.2&id=o-ADHO5uym_-dJDWlabQjq8F_JW90suJ0QS7JIkaJ5W2IW&itag=136&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C394%2C395%2C396%2C397%2C398%2C399&source=youtube&requiressl=yes&mh=JG&mm=31%2C29&mn=sn-oxmavbpj2i-hoae%2Csn-i3belnlz&ms=au%2Crdu&mv=m&mvi=2&pl=24&gcr=ph&initcwndbps=456250&vprv=1&mime=video%2Fmp4&ns=5x3g0zNLi0x9SLeBMmHzyfIF&gir=yes&clen=18526689&dur=194.027&lmt=1606005125266614&mt=1607681077&fvip=4&keepalive=yes&c=WEB&txp=5535434&n=Ih5bbdsLP8rIh2gs&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cgcr%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhALiJLhhbWwt5us4ac7yiGrbLFReUzdeHkoZDkKlmpRLQAiAmm93-vNSK2KrM1pZY7ryhjDl-OW8IZ8eFUOQ5RnCKBg%3D%3D&sig=AOq0QJ8wRAIgPg1vcnDKNKJstM6GtPwPjraVtF7_gMtoAg5JYLVtWY4CIDGUM36nOM4dlQkoYsQDrndu40zykZJDDnz8CrYSDxfYxfYxfY&sp=sig&url=https://r2---sn-oxmavbpj2i-hoae.googlevideo.com/videoplayback?expire=1607703044&ei=pEXTX5jjOcW8gQPghLn4CA&ip=103.206.80.2&id=o-ADHO5uym_-dJDWlabQjq8F_JW90suJ0QS7JIkaJ5W2IW&itag=136&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C394%2C395%2C396%2C397%2C398%2C399&source=youtube&requiressl=yes&mh=JG&mm=31%2C29&mn=sn-oxmavbpj2i-hoae%2Csn-i3belnlz&ms=au%2Crdu&mv=m&mvi=2&pl=24&gcr=ph&initcwndbps=456250&vprv=1&mime=video%2Fmp4&ns=5x3g0zNLi0x9SLeBMmHzyfIF&gir=yes&clen=18526689&dur=194.027&lmt=1606005125266614&mt=1607681077&fvip=4&keepalive=yes&c=WEB&txp=5535434&n=Ih5bbdsLP8rIh2gs&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cgcr%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhALiJLhhbWwt5us4ac7yiGrbLFReUzdeHkoZDkKDmpRLQAiAmm93-vNSK2KrM1pZY7ryhjDl-OW8IZ8eFUOQ5RnCKBg

lortspogi commented 3 years ago

From @suryajanaki example this is what I did and its working.

Matcher mat2 = patCipherUrl.matcher(cipher); if (mat2.find()) { url = URLDecoder.decode(mat2.group(1), "UTF-8"); mat2 = patEncSig.matcher(cipher); if (mat2.find()) { sig = URLDecoder.decode(mat2.group(1), "UTF-8"); sig = sig.replace("\u0026", "&"); String[] test = sig.split("&"); sig = test[0]; Log.d(LOG_TAG, "SIG:"+sig); } else { continue; } } else { continue; }

sametserpil commented 3 years ago

@lortspogi I did what you did but not working.

lortspogi commented 3 years ago

https://github.com/HaarigerHarald/android-youtubeExtractor/pull/163 do this first.

sametserpil commented 3 years ago

Now it can fetch video urls but those urls give http 403 error. is it normal?

lortspogi commented 3 years ago

From what I experienced, you get 403 because of the wrong signature. If you follow the solution of #163 at and the code above I think it will work. All private videos is still playing on my end.

sametserpil commented 3 years ago

it's working now. Thank you!

Dn-a commented 3 years ago

hi @lortspogi if it is not a problem for you, I would like to add your solution to my PR #163. Thanks

lortspogi commented 3 years ago

I don't mind at all.

Nimmidev commented 3 years ago

Now let's hope that @HaarigerHarald is going to merge that soon.

suryajanaki commented 3 years ago

From @suryajanaki example this is what I did and its working.

Matcher mat2 = patCipherUrl.matcher(cipher); if (mat2.find()) { url = URLDecoder.decode(mat2.group(1), "UTF-8"); mat2 = patEncSig.matcher(cipher); if (mat2.find()) { sig = URLDecoder.decode(mat2.group(1), "UTF-8"); sig = sig.replace("\u0026", "&"); String[] test = sig.split("&"); sig = test[0]; Log.d(LOG_TAG, "SIG:"+sig); } else { continue; } } else { continue; }

Yes, Instead, we can change the pattern like below private static final Pattern patEncSig = Pattern.compile("s=(.{10,}?)(&|\\u0026)");

suryajanaki commented 3 years ago

hi @lortspogi if it is not a problem for you, I would like to add your solution to my PR #163. Thanks

Simply changing the Pattern will fix this, private static final Pattern patEncSig = Pattern.compile("s=(.{10,}?)(&|\\u0026)");

lortspogi commented 3 years ago

Oh thanks, my bad I'm not good at regex. :D