[GH-ISSUE #278] getting invalid streaming URLs despite passing valid videoId and signatureTimestamp to get_song #215

Closed
opened 2026-02-27 22:08:38 +03:00 by kerem · 2 comments
Owner

Originally created by @totallynotadi on GitHub (Jun 8, 2022).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/278

hello,
so i tried to fetch the stream URL for a video with id As_4JTmHuW4 and passed a signatureTimestamp derived from ytmusic.get_signatureTimestamp(ytmusic.get_basejs_url()) to get_song

the resulting streamign URLs however were invalid

this is the one-lines used for the get_song call

song = ytmusic.get_song(videoId='As_4JTmHuW4', signatureTimestamp=ytmusic.get_signatureTimestamp(ytmusic.get_basejs_url()))

this was the string found in the signatureCipher property of the resulting song's streamingData
s=YOAQOAOq0QJ8wRPIhAOhjTPoVIw7oWjwD7VycYrCWpeAAnG-pIQZUyDqc45nZAiATmMQwUtzuh7Q4x0if1oGp0f8fePNz3LuGzqQXlpo8-Q%3D%3D&sp=sig&url=https://rr3---sn-ci5gup-cvhy.googlevideo.com/videoplayback%3Fexpire%3D1654723612%26ei%3DvL-gYoz_Fcaag8UPociIiAc%26ip%3D2401%253A4900%253A550c%253Aac40%253Ab55e%253Aef2f%253A1cec%253Aac8b%26id%3Do-ANbeNCegziqoO4NNOH7q1a-nQDOC4EyWsclryWV6F_pV%26itag%3D22%26source%3Dyoutube%26requiressl%3Dyes%26mh%3DXE%26mm%3D31%252C29%26mn%3Dsn-ci5gup-cvhy%252Csn-ci5gup-cvhr%26ms%3Dau%252Crdu%26mv%3Dm%26mvi%3D3%26pl%3D44%26gcr%3Din%26initcwndbps%3D188750%26spc%3D4ocVC4hhzjZIHPqPTq4FEzKHoptxgJ5ZqNasUQ2QoO6z%26vprv%3D1%26mime%3Dvideo%252Fmp4%26ns%3DeB8LI9HOLP8CjP600QsMr2IG%26cnr%3D14%26ratebypass%3Dyes%26dur%3D181.719%26lmt%3D1576954320212805%26mt%3D1654701663%26fvip%3D7%26fexp%3D24001373%252C24007246%26c%3DWEB_REMIX%26txp%3D5532432%26n%3Dd6XfckbLyCESze2QzMH0%26sparams%3Dexpire%252Cei%252Cip%252Cid%252Citag%252Csource%252Crequiressl%252Cgcr%252Cspc%252Cvprv%252Cmime%252Cns%252Ccnr%252Cratebypass%252Cdur%252Clmt%26lsparams%3Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%252Cinitcwndbps%26lsig%3DAG3C_xAwRAIgUQYGjXRSmyqhd99Hb1LoAxIBxuI9WfTMHPuG9M-8RSkCIF-7Z6fN5ibWviApOYMcCRkXfhDqckTGJequpDapCa39

if i'm not missing something, the url part is supposed to be a valid streaming url, please let me know if something's wrong

Originally created by @totallynotadi on GitHub (Jun 8, 2022). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/278 hello, so i tried to fetch the stream URL for a video with id As_4JTmHuW4 and passed a signatureTimestamp derived from `ytmusic.get_signatureTimestamp(ytmusic.get_basejs_url())` to get_song the resulting streamign URLs however were invalid this is the one-lines used for the get_song call `song = ytmusic.get_song(videoId='As_4JTmHuW4', signatureTimestamp=ytmusic.get_signatureTimestamp(ytmusic.get_basejs_url()))` this was the string found in the signatureCipher property of the resulting song's streamingData ```s=YOAQOAOq0QJ8wRPIhAOhjTPoVIw7oWjwD7VycYrCWpeAAnG-pIQZUyDqc45nZAiATmMQwUtzuh7Q4x0if1oGp0f8fePNz3LuGzqQXlpo8-Q%3D%3D&sp=sig&url=https://rr3---sn-ci5gup-cvhy.googlevideo.com/videoplayback%3Fexpire%3D1654723612%26ei%3DvL-gYoz_Fcaag8UPociIiAc%26ip%3D2401%253A4900%253A550c%253Aac40%253Ab55e%253Aef2f%253A1cec%253Aac8b%26id%3Do-ANbeNCegziqoO4NNOH7q1a-nQDOC4EyWsclryWV6F_pV%26itag%3D22%26source%3Dyoutube%26requiressl%3Dyes%26mh%3DXE%26mm%3D31%252C29%26mn%3Dsn-ci5gup-cvhy%252Csn-ci5gup-cvhr%26ms%3Dau%252Crdu%26mv%3Dm%26mvi%3D3%26pl%3D44%26gcr%3Din%26initcwndbps%3D188750%26spc%3D4ocVC4hhzjZIHPqPTq4FEzKHoptxgJ5ZqNasUQ2QoO6z%26vprv%3D1%26mime%3Dvideo%252Fmp4%26ns%3DeB8LI9HOLP8CjP600QsMr2IG%26cnr%3D14%26ratebypass%3Dyes%26dur%3D181.719%26lmt%3D1576954320212805%26mt%3D1654701663%26fvip%3D7%26fexp%3D24001373%252C24007246%26c%3DWEB_REMIX%26txp%3D5532432%26n%3Dd6XfckbLyCESze2QzMH0%26sparams%3Dexpire%252Cei%252Cip%252Cid%252Citag%252Csource%252Crequiressl%252Cgcr%252Cspc%252Cvprv%252Cmime%252Cns%252Ccnr%252Cratebypass%252Cdur%252Clmt%26lsparams%3Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%252Cinitcwndbps%26lsig%3DAG3C_xAwRAIgUQYGjXRSmyqhd99Hb1LoAxIBxuI9WfTMHPuG9M-8RSkCIF-7Z6fN5ibWviApOYMcCRkXfhDqckTGJequpDapCa39``` if i'm not missing something, the url part is supposed to be a valid streaming url, please let me know if something's wrong
kerem closed this issue 2026-02-27 22:08:39 +03:00
Author
Owner

@sigma67 commented on GitHub (Jun 13, 2022):

Unfortunately I don't know much about streaming URLs, tagging some people who might know more.

@KoljaWindeler @impliedchaos

<!-- gh-comment-id:1153643555 --> @sigma67 commented on GitHub (Jun 13, 2022): Unfortunately I don't know much about streaming URLs, tagging some people who might know more. @KoljaWindeler @impliedchaos
Author
Owner

@impliedchaos commented on GitHub (Jun 13, 2022):

@addyett - Those streaming URLs still need to be de-obfuscated before using. You can try youtube-dl or pytube to do this.
I do something like

from pytube.cipher import Cipher
from urllib.parse import parse_qs

resp = requests.get(ytmusic.get_basejs_url())
PTC  = Cipher(js=resp.text)
# "sigCiph" var is the signatureCipher you got from get_song
sc = parse_qs(sigCiph)
sig = PTC.get_signature(ciphered_signature=sc["s"][0])
url = sc["url"][0] + "&sig=" + sig + "&ratebypass=yes"
# "url" variable should now be valid and ready to stream.
<!-- gh-comment-id:1153809974 --> @impliedchaos commented on GitHub (Jun 13, 2022): @addyett - Those streaming URLs still need to be de-obfuscated before using. You can try youtube-dl or pytube to do this. I do something like ``` from pytube.cipher import Cipher from urllib.parse import parse_qs resp = requests.get(ytmusic.get_basejs_url()) PTC = Cipher(js=resp.text) # "sigCiph" var is the signatureCipher you got from get_song sc = parse_qs(sigCiph) sig = PTC.get_signature(ciphered_signature=sc["s"][0]) url = sc["url"][0] + "&sig=" + sig + "&ratebypass=yes" # "url" variable should now be valid and ready to stream. ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#215
No description provided.