Closed CyberedCake closed 1 year ago
Hi @CyberedCake, thanks for raising this issue. YouTube is always changing the data that the innertube API returns slightly, therefore that is likely what's happened here. It's very unlikely that this is at all an error on your side - I'll see if I'm able to reproduce the issue
Interestingly I'm not even able to instantiate a client:
import ytm
api = ytm.YouTubeMusic()
$ python3 app.py
MethodError: Page has no configuration data
Edit: I was able to resolve this by providing a cookie which indicated that I had accepted YouTube's cookies
So the .song
method uses the get_video_info
endpoint under the hood, e.g. https://www.youtube.com/get_video_info?video_id=k1BneeJTDcU however this appears to be returning an empty response which is strange. I wonder whether YouTube has deprecated this endpoint :confused:
It's returning a 410 Gone
which is ominous and likely confirms the suspicion that YouTube has removed it:
$ http "https://www.youtube.com/get_video_info?video_id=k1BneeJTDcU"
HTTP/1.1 410 Gone
...
I've written a library called innertube
which talks to the underlying API that YouTube uses and should be able to help get around this:
import innertube
client = innertube.InnerTube("WEB_REMIX")
data = client.player("k1BneeJTDcU")
You'll need to parse out the bits of data you need, however it should all be there. For example:
from pprint import pprint
pprint(data["videoDetails"])
{
'videoId': 'k1BneeJTDcU',
'title': 'Welcome to the Internet',
'lengthSeconds': '281',
'channelId': 'UC81hVmI5eEBIt3s3HQpJd_w',
'isOwnerViewing': False,
'isCrawlable': True,
'thumbnail': {
'thumbnails': [
{
'url': 'https://i.ytimg.com/vi/k1BneeJTDcU/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AOn4CLCxoAMIXcFyiQAiAL9UkCWL1Wj6IQ',
'width': 400,
'height': 225
},
{
'url': 'https://i.ytimg.com/vi/k1BneeJTDcU/hq720.jpg?sqp=-oaymwEXCKAGEMIDIAQqCwjVARCqCBh4INgESFo&rs=AOn4CLDLjQoo6o1bxgy2QJgjO-YqtVBNDA',
'width': 800,
'height': 450
},
{
'url': 'https://i.ytimg.com/vi/k1BneeJTDcU/hq720.jpg?sqp=-oaymwEXCNUGEOADIAQqCwjVARCqCBh4INgESFo&rs=AOn4CLAd2OyHWCHIkF0nzezkb5b9wY6H6g',
'width': 853,
'height': 480
}
]
},
'allowRatings': True,
'viewCount': '98764277',
'author': 'Bo Burnham',
'isPrivate': False,
'isUnpluggedCorpus': False,
'musicVideoType': 'MUSIC_VIDEO_TYPE_OMV',
'isLiveContent': False
}
I'm going to close this issue as there's little I'm able to do, beyond deprecating the .song
method
A "No Data To Parse" error occurs whenever I try to create a song object, even when using the same ID as in the example in the README. I tried some other songs, including Welcome to the Internet by Bo Burnham, and it still didn't work.
After which I tried,
api.search_songs("Welcome to the Internet")
, where the results have the ID included in them. After also attempting to create a song using that ID, it still gave me the "No data to parse exception".✔️ I am using the latest version ✔️ I have installed all dependencies, optional and required ✔️ I have followed instructions to the best of my ability ℹ️ I am using Windows 10 Enterprise 22H2. (high school laptop, so not very good specs in general)
Lemme know if this is an error on my side or if it's not replicable.