提问人:mrithul e 提问时间:11/16/2023 最后编辑:mrithul e 更新时间:11/18/2023 访问量:54
如何在innertube(youtubie/youtube-internal-api)播放器端点中使用YouTube音乐?
How to use YouTube music in innertube(youtubie/youtube-internal-api) player endpoint?
问:
如何在innertube(youtubie/youtube-internal-api)播放器端点中使用YouTube音乐? 我使用 innertube 和 Python 使用 YouTube(网络),但是当使用“WEB_MUSIC”时,它给出了一个不起作用的签名密码 URL,该怎么办?我听说 ViMusic 使用 YouTube-Internal-Clients
Innertube 在 YOUTUBE_WEB 中很好,但不能使用 yt 音乐 我得到这样的JSON响应:
"streamingData": {
"expiresInSeconds": "21540",
"formats": [
{
"itag": 18,
"mimeType": "video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"",
"bitrate": 140435,
"width": 360,
"height": 360,
"lastModified": "1669984279860628",
"contentLength": "4674407",
"quality": "medium",
"fps": 25,
"qualityLabel": "360p",
"projectionType": "RECTANGULAR",
"averageBitrate": 140395,
"audioQuality": "AUDIO_QUALITY_LOW",
"approxDurationMs": "266356",
"audioSampleRate": "44100",
"audioChannels": 2,
"signatureCipher": "s=S4WPDj%3DlGZvg4ObadxAEkB2sd-XU248b3tfJXATKsI3mAEiApqfYB6j3pLbrrr5hrp-vk023QaoSW8tVJ_TbD6S4stOAhIgRwAgewLNAZAZ&sp=sig&url=https://rr4---sn-ci5gup-jjwl.googlevideo.com/videoplayback%3Fexpire%3D1700000666%26ei%3DOp9TZcbcA7SK9fwP2ouQcA%26ip%3D2401%253A4900%253A6139%253A822%253A587d%253A471c%253A4abb%253A5eb%26id%3Do-AJ6mPnmamzz2JEE7aA44guGhkU2u1BqD6dSsiKrkfLWy%26itag%3D18%26source%3Dyoutube%26requiressl%3Dyes%26mh%3DK_%26mm%3D31%252C29%26mn%3Dsn-ci5gup-jjwl%252Csn-ci5gup-cvhr%26ms%3Dau%252Crdu%26mv%3Dm%26mvi%3D4%26pl%3D44%26gcr%3Din%26initcwndbps%3D192500%26spc%3DUWF9f0sysDx06wwca4FwPzknvvDdZBs%26vprv%3D1%26svpuc%3D1%26mime%3Dvideo%252Fmp4%26ns%3DHUrqFbJnd83ZpOw6rHEBg20P%26gir%3Dyes%26clen%3D4674407%26ratebypass%3Dyes%26dur%3D266.356%26lmt%3D1669984279860628%26mt%3D1699978900%26fvip%3D7%26fexp%3D24007246%26beids%3D24350018%26c%3DWEB_REMIX%26txp%3D2319224%26n%3DP3gLBrEETySrz_y%26sparams%3Dexpire%252Cei%252Cip%252Cid%252Citag%252Csource%252Crequiressl%252Cgcr%252Cspc%252Cvprv%252Csvpuc%252Cmime%252Cns%252Cgir%252Cclen%252Cratebypass%252Cdur%252Clmt%26lsparams%3Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%252Cinitcwndbps%26lsig%3DAM8Gb2swRQIgYhHb1mVspqUTQYTRyhnZUyMv7ig5-0bmiJqBko5v57ICIQCBrEIYLdmWduZCWU2GFmGKcuRJJomytPK-vuK-TSYoGw%253D%253D"
}
]
我使用的代码是:
import requests
url = "https://www.youtube.com/youtubei/v1/player?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"
headers = {
"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.42",
"Accept": "*/*",
"Origin": "https://www.youtube.com",
"Referer": "https://www.youtube.com/",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "de,de-DE;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
}
json_payload = {
"context": {
"client": {
"hl": "en",
"gl": "US",
"clientName": "WEB_MUSIC",
"clientVersion": "1.0",
#"clientScreen": "WATCH",
#"androidSdkVersion": 31
},
"thirdParty": {
"embedUrl": "https://www.youtube.com/"
}
},
"videoId": "JIc0b7fToA8",
"playbackContext": {
"contentPlaybackContext": {
"signatureTimestamp": 19250
}
},
"racyCheckOk": True,
"contentCheckOk": True
}
response = requests.post(url, headers=headers, json=json_payload)
k= response.status_code
p = response.text
with open("hi.json","w+", encoding='utf-8') as hi:
hi.write(p)
更多信息在YouTube-Internal-Clients和innertube上
请说出如何在innertube和Python中使用yt音乐和请求。
答: 暂无答案
评论