Closed Eradeon closed 3 months ago
It seems instance related, the official instance is having this issue but not my own, see blob/d61488fbe0becf6d2a6ebc97761e5b87a8facd3f/README.md#install-your-own-instance-of-the-api. I am investigating the issue going on with the official instance.
VIDEO_IDS=('UPrkC1LdlLY' 'a9cyG_yfh1k')
YOUTUBE_OPERATIONAL_API_INSTANCE_URL='http://localhost/YouTube-operational-API'
for videoId in "${VIDEO_IDS[@]}"
do
echo $videoId
curl -s "$YOUTUBE_OPERATIONAL_API_INSTANCE_URL/videos?part=music&id=$videoId" | jq '.items[0].music.available' -
done
UPrkC1LdlLY
false
a9cyG_yfh1k
true
VIDEO_IDS=('UPrkC1LdlLY' 'a9cyG_yfh1k')
YOUTUBE_OPERATIONAL_API_INSTANCE_URL='https://yt.lemnoslife.com'
for videoId in "${VIDEO_IDS[@]}"
do
echo $videoId
curl -s "$YOUTUBE_OPERATIONAL_API_INSTANCE_URL/videos?part=music&id=$videoId" | jq '.items[0].music.available' -
done
UPrkC1LdlLY
false
a9cyG_yfh1k
false
Well I updated the official instance and rebooted and it seems to have solved the issue, let me know if it continues happening.
My bad I checked on the wrong instance.
No line seems written to /var/log/apache2/error.log
when this issue happens.
Locally:
curl -s https://music.youtube.com/youtubei/v1/player -H 'Content-Type: application/json' --data-raw '{"videoId": "UPrkC1LdlLY", "context": {"client": {"clientName": "WEB_REMIX", "clientVersion": "1.20240805.00.00"}}}' | grep 'This video is not available'
"reason": "This video is not available",
"text": "This video is not available"
On the official instance:
curl -s https://music.youtube.com/youtubei/v1/player -H 'Content-Type: application/json' --data-raw '{"videoId": "UPrkC1LdlLY", "context": {"client": {"clientName": "WEB_REMIX", "clientVersion": "1.20240805.00.00"}}}'
So it seems clear that on your own instance you will not have this issue.
Personal notes:
When being connected:
Content not available. Playing something else.
When not being connected:
This video is not available
minimizeCURL curl.sh 'Content not available. Playing something else.'
curl https://music.youtube.com/watch -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0' -H 'Cookie: __Secure-3PSID=CENSORED; PREF=repeat=NONE&autoplay=true&hl=en'
On the official instance:
curl https://music.youtube.com/youtubei/v1/player -H 'Content-Type: application/json' --data-raw '{"context": {"client": {"clientName": "WEB_REMIX", "clientVersion": "1.20240805.00.00"}}}'
So removing "videoId": "UPrkC1LdlLY",
in --data-raw
solves the issue... Lol but then YouTube does not know the video so definitely need to authenticate.
curl https://music.youtube.com/youtubei/v1/player -H 'Content-Type: application/json' -H 'Authorization: SAPISIDHASH CENSORED' -H 'Origin: https://music.youtube.com' -H 'Cookie: __Secure-3PSID=CENSORED; __Secure-3PAPISID=CENSORED' --data-raw '{"videoId": "1AiZ3n6HKEI", "context": {"client": {"clientName": "WEB_REMIX", "clientVersion": "1.20240805.00.00"}}}'
For debugging:
if ($_SERVER['REMOTE_ADDR'] == 'XXX.XXX.XXX.XXX') {
die('hey');
//die(json_encode($headers));
}
Solve the issue on the official instance:
git diff videos.php
diff --git a/videos.php b/videos.php
index 7047138..e4d88e1 100644
--- a/videos.php
+++ b/videos.php
@@ -83,7 +83,19 @@
'Accept-Language: en'
];
if ($music) {
- array_push($headers, 'Referer: https://music.youtube.com');
+ $currentTime = time();
+ $SAPISID = 'CENSORED';
+ $__Secure_3PSID = 'CENSORED';
+ $ORIGIN = 'https://music.youtube.com';
+ $SAPISIDHASH = "${currentTime}_" . sha1("$currentTime $SAPISID $ORIGIN");
+
+ array_push($headers,
+ //'Referer: https://music.youtube.com',
+ "Origin: $ORIGIN",
+ "Authorization: SAPISIDHASH $SAPISIDHASH",
+ "Cookie: __Secure-3PSID=$__Secure_3PSID; __Secure-3PAPISID=$SAPISID",
+ );
}
$opts = [
'http' => [
Let me know if it stops working at some point.
Today I have noticed that https://yt.lemnoslife.com/videos?part=music&id=VIDEO_ID returns
false
for availability on YouTube Music for every video ID, even when that video is available on YouTube Music. Seems to be reproducible with any video ID from YouTube Music.