[GH-ISSUE #718] Error to reading album information (using get_album(), some part comes as None) #468

Closed
opened 2026-02-27 23:00:57 +03:00 by kerem · 9 comments
Owner

Originally created by @NangmanGureum on GitHub (Jan 12, 2025).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/718

Describe the bug
In a nutshell, there are a lot of None in browse result. ABNORMALLY.

When I browse an album via get_album(), I found there's lot of unavailable things (In other words, its were can use previously.)

Compare with an example on document, you can see a lot of different points.

To Reproduce
Here's my enviroment.
OS: Windows 11 (23H2, 22631.4602)
Python version: 3.9.13
YouTube API: YouTube Data API v3 (Latest update: 22. 7. 22. )
ytmusicapi version: 1.9.1

Run this code below (with your oauth.json)

from ytmusicapi import YTMusic
import pprint

yt_api = YTMusic("oauth.json")

# Revival by Eminem
album = yt_api.get_album("MPREb_fefKFOTEZSp") 

pprint.pprint(album, sort_dicts=False)

And it comes(with some omission):

{'title': 'Revival',
 'type': 'Album',
 'thumbnails': [...],
 'isExplicit': False,
 '...': '...',
 'audioPlaylistId': None,
 'likeStatus': 'INDIFFERENT',
 'tracks': [{'videoId': None,
             'title': 'Walk On Water',
             'artists': [{'name': 'Eminem', 'id': 'UCedvOgsKFzcK3hA5taf3KoQ'}],
             'album': 'Revival',
             'likeStatus': None,
             'inLibrary': None,
             'thumbnails': None,
             'isAvailable': False,
             'isExplicit': False,
             'videoType': None,
             'views': None,
             'trackNumber': None,
             'duration': '5:04',
             'duration_seconds': 304},
            {...}],
 '...': '...'}

Additional context
My oauth.json(which using to reproduce a bug) is made to following OAuth authentication document.

Originally created by @NangmanGureum on GitHub (Jan 12, 2025). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/718 **Describe the bug** In a nutshell, there are **a lot of `None`** in browse result. **ABNORMALLY.** When I browse an album via `get_album()`, I found there's lot of unavailable things (In other words, its were can use previously.) Compare with an example on [document](https://ytmusicapi.readthedocs.io/en/stable/reference/browsing.html#ytmusicapi.YTMusic.get_album), you can see a lot of different points. **To Reproduce** Here's my enviroment. OS: Windows 11 (23H2, 22631.4602) Python version: 3.9.13 YouTube API: YouTube Data API v3 (Latest update: 22. 7. 22. ) `ytmusicapi` version: 1.9.1 Run this code below (with your `oauth.json`) ```python from ytmusicapi import YTMusic import pprint yt_api = YTMusic("oauth.json") # Revival by Eminem album = yt_api.get_album("MPREb_fefKFOTEZSp") pprint.pprint(album, sort_dicts=False) ``` And it comes(with some omission): ```python {'title': 'Revival', 'type': 'Album', 'thumbnails': [...], 'isExplicit': False, '...': '...', 'audioPlaylistId': None, 'likeStatus': 'INDIFFERENT', 'tracks': [{'videoId': None, 'title': 'Walk On Water', 'artists': [{'name': 'Eminem', 'id': 'UCedvOgsKFzcK3hA5taf3KoQ'}], 'album': 'Revival', 'likeStatus': None, 'inLibrary': None, 'thumbnails': None, 'isAvailable': False, 'isExplicit': False, 'videoType': None, 'views': None, 'trackNumber': None, 'duration': '5:04', 'duration_seconds': 304}, {...}], '...': '...'} ``` **Additional context** My `oauth.json`(which using to reproduce a bug) is made to following [OAuth authentication](https://ytmusicapi.readthedocs.io/en/stable/setup/oauth.html) document.
kerem 2026-02-27 23:00:57 +03:00
  • closed this issue
  • added the
    invalid
    label
Author
Owner

@sigma67 commented on GitHub (Jan 17, 2025):

cannot reproduce

<!-- gh-comment-id:2599037494 --> @sigma67 commented on GitHub (Jan 17, 2025): cannot reproduce
Author
Owner

@NangmanGureum commented on GitHub (Jan 18, 2025):

cannot reproduce

I've revisited how to reproduce.

My setup

OS: macOS 15.1(24B83)
Python version: 3.13.1
YouTube API: YouTube Data API v3 (Latest update: 22. 7. 22. )
ytmusicapi version: 1.9.1

Google Cloud (YouTube API) setup

  1. Go to https://cloud.google.com/
  2. Click "Console" in the top right corner.
  3. Click your Google Cloud project name in the top left corner.
  4. Click “NEW PROJECT” in the top right corner of the modal that follows
  5. Name your project (it doesn't matter how you name it), and set the “Location” field to “No organization”.
  6. Again, click your Google Cloud project name in the top left corner.
  7. Click your new project that you just created in the list of projects in the next modal.
  8. Search for “youtube” in the top search bar, and click “YouTube Data API v3” in the search suggestions.
  9. Click "ENABLE".
  10. When you get to the next page, click “CREATE CREDENTIALS”.
  11. In "What data will you be accessing?", select "User Data".
  12. Set "App information". Regardless of how you fill it in.
  13. Pass "Scopes".
  14. In "OAuth Client ID", set "TVs and Limited Input devices". and click "CREATE"
  15. Click "DONE"
  16. Click “Audience” in the navigation bar on the left.
  17. Click "ADD USERS" at "Test users"
  18. Enter your email. and click "SAVE"

How to check the key

  1. Click “Credentials” in the navigation bar on the left.
  2. In the list of “OAuth 2.0 Client IDs”, click “TV client 1” (or whatever name you gave it in the “App information” field earlier).

ytmusicapi setup

  1. Install ytmusicapi via pip.
  2. Enter ytmusicapi oauth on where the code is. and follow the instructions. (See: https://ytmusicapi.readthedocs.io/en/stable/setup/oauth.html )
  3. Run the code below
from ytmusicapi import YTMusic
import pprint

yt_api = YTMusic("oauth.json")

# Revival by Eminem
album = yt_api.get_album("MPREb_fefKFOTEZSp") 

pprint.pprint(album, sort_dicts=False)

Result

{'title': 'Revival',
 'type': 'Album',
 'thumbnails': [...],
 'isExplicit': False,
 '...': '...',
 'audioPlaylistId': None,
 'likeStatus': 'INDIFFERENT',
 'tracks': [{'videoId': None,
             'title': 'Walk On Water',
             'artists': [{'name': 'Eminem', 'id': 'UCedvOgsKFzcK3hA5taf3KoQ'}],
             'album': 'Revival',
             'likeStatus': None,
             'inLibrary': None,
             'thumbnails': None,
             'isAvailable': False,
             'isExplicit': False,
             'videoType': None,
             'views': None,
             'trackNumber': None,
             'duration': '5:04',
             'duration_seconds': 304},
            {...}],
 '...': '...'}

This is different from the example in YTMusic.get_album(), where neither the videoId nor the likeStatus values come out as None (in other words, the intended result is not None).

My hypothesis

I don't have a hypothesis at the moment, except to say that the configuration of the “YouTube Data API v3” in Google Cloud is different, or that ytmusicapi doesn't handle the data it receives from the API properly (e.g. ytmusicapi was adapted to an earlier version of the API).

Another hypothesis is that in South Korea, you need to subscribe to YouTube Premium to access YouTube Music. The above case could have been the result of an API associated with a Korean account that did not have a YouTube Premium subscription.

So I signed up for YouTube Premium on the linked Google account and still got the same result, which suggests that the issue is not with YouTube Premium.

Now, you might be thinking that you can use "Browser authentication" instead of "OAuth authentication", and I tried that, but when I went to the YouTube Music homepage, I couldn't find any POST corresponding to `browse?...'.

Conclusion

This doesn't seem like an issue that can be simply dismissed as “cannot reproduce” - I think you need to take a closer look at the issue. Please reopen this issue.

<!-- gh-comment-id:2599540423 --> @NangmanGureum commented on GitHub (Jan 18, 2025): > cannot reproduce I've revisited how to reproduce. ## My setup OS: macOS 15.1(24B83) Python version: 3.13.1 YouTube API: YouTube Data API v3 (Latest update: 22. 7. 22. ) `ytmusicapi` version: 1.9.1 ## Google Cloud (YouTube API) setup 1. Go to https://cloud.google.com/ 2. Click "Console" in the top right corner. 3. Click your Google Cloud project name in the top left corner. 4. Click “NEW PROJECT” in the top right corner of the modal that follows 6. Name your project (it doesn't matter how you name it), and set the “Location” field to “No organization”. 7. Again, click your Google Cloud project name in the top left corner. 8. Click your new project that you just created in the list of projects in the next modal. 9. Search for “youtube” in the top search bar, and click “YouTube Data API v3” in the search suggestions. 10. Click "ENABLE". 11. When you get to the next page, click “CREATE CREDENTIALS”. 12. In "What data will you be accessing?", select "User Data". 13. Set "App information". Regardless of how you fill it in. 14. Pass "Scopes". 15. In "OAuth Client ID", set "TVs and Limited Input devices". and click "CREATE" 16. Click "DONE" 17. Click “Audience” in the navigation bar on the left. 18. Click "ADD USERS" at "Test users" 19. Enter your email. and click "SAVE" ### How to check the key 1. Click “Credentials” in the navigation bar on the left. 2. In the list of “OAuth 2.0 Client IDs”, click “TV client 1” (or whatever name you gave it in the “App information” field earlier). ## `ytmusicapi` setup 1. Install `ytmusicapi` via `pip`. 2. Enter `ytmusicapi oauth` on where the code is. and follow the instructions. (See: https://ytmusicapi.readthedocs.io/en/stable/setup/oauth.html ) 3. Run the code below ```python from ytmusicapi import YTMusic import pprint yt_api = YTMusic("oauth.json") # Revival by Eminem album = yt_api.get_album("MPREb_fefKFOTEZSp") pprint.pprint(album, sort_dicts=False) ``` ## Result ```python {'title': 'Revival', 'type': 'Album', 'thumbnails': [...], 'isExplicit': False, '...': '...', 'audioPlaylistId': None, 'likeStatus': 'INDIFFERENT', 'tracks': [{'videoId': None, 'title': 'Walk On Water', 'artists': [{'name': 'Eminem', 'id': 'UCedvOgsKFzcK3hA5taf3KoQ'}], 'album': 'Revival', 'likeStatus': None, 'inLibrary': None, 'thumbnails': None, 'isAvailable': False, 'isExplicit': False, 'videoType': None, 'views': None, 'trackNumber': None, 'duration': '5:04', 'duration_seconds': 304}, {...}], '...': '...'} ``` This is different from [the example](https://ytmusicapi.readthedocs.io/en/stable/reference/browsing.html#ytmusicapi.YTMusic.get_album) in `YTMusic.get_album()`, where neither the `videoId` nor the `likeStatus` values come out as `None` (in other words, the intended result is not `None`). ## My hypothesis I don't have a hypothesis at the moment, except to say that the configuration of the “YouTube Data API v3” in Google Cloud is different, or that `ytmusicapi` doesn't handle the data it receives from the API properly (e.g. ytmusicapi was adapted to an earlier version of the API). Another hypothesis is that in South Korea, you need to subscribe to YouTube Premium to access YouTube Music. The above case could have been the result of an API associated with a Korean account that did not have a YouTube Premium subscription. So I signed up for YouTube Premium on the linked Google account and still got the same result, which suggests that the issue is not with YouTube Premium. Now, you might be thinking that you can use ["Browser authentication"](https://ytmusicapi.readthedocs.io/en/stable/setup/browser.html) instead of "OAuth authentication", and I tried that, but when I went to the YouTube Music homepage, I couldn't find any POST corresponding to `browse?...'. ## Conclusion This doesn't seem like an issue that can be simply dismissed as “cannot reproduce” - I think you need to take a closer look at the issue. Please reopen this issue.
Author
Owner

@sigma67 commented on GitHub (Jan 18, 2025):

You're not passing in the OAuth credentials to YTMusic. Sorry about that, it should be mentioned in the docs. Will update in a bit

<!-- gh-comment-id:2599585108 --> @sigma67 commented on GitHub (Jan 18, 2025): You're not passing in the OAuth credentials to YTMusic. Sorry about that, it should be mentioned in the docs. Will update in a bit
Author
Owner

@NangmanGureum commented on GitHub (Jan 18, 2025):

You're not passing in the OAuth credentials to YTMusic. Sorry about that, it should be mentioned in the docs. Will update in a bit

I see. let me know if it updated.

<!-- gh-comment-id:2599587505 --> @NangmanGureum commented on GitHub (Jan 18, 2025): > You're not passing in the OAuth credentials to YTMusic. Sorry about that, it should be mentioned in the docs. Will update in a bit I see. let me know if it updated.
Author
Owner

@sigma67 commented on GitHub (Jan 19, 2025):

@NangmanGureum

The documentation was already up to date: https://ytmusicapi.readthedocs.io/en/latest/setup/oauth.html

If you only looked at the usage chapter you maybe were mislead by the constructor statement. This is fixed now: https://ytmusicapi.readthedocs.io/en/latest/usage.html

I also added an error if oauth JSON is passed without credentials

<!-- gh-comment-id:2600866727 --> @sigma67 commented on GitHub (Jan 19, 2025): @NangmanGureum The documentation was already up to date: https://ytmusicapi.readthedocs.io/en/latest/setup/oauth.html If you only looked at the usage chapter you maybe were mislead by the constructor statement. This is fixed now: https://ytmusicapi.readthedocs.io/en/latest/usage.html I also added an error if oauth JSON is passed without credentials
Author
Owner

@NangmanGureum commented on GitHub (Jan 19, 2025):

@NangmanGureum

The documentation was already up to date: https://ytmusicapi.readthedocs.io/en/latest/setup/oauth.html

If you only looked at the usage chapter you maybe were mislead by the constructor statement. This is fixed now: https://ytmusicapi.readthedocs.io/en/latest/usage.html

I also added an error if oauth JSON is passed without credentials

Ok, I had something misunderstood. Sorry for that.

I think my oauth.json would have been passed in the OAuth credentials. because, the code has wrote as YTMusic("oauth.json"); and I do the OAuth setup guideline, enter the right API key and secret, get Google API webpage to follow the instructions, see if done as well (it was successfully complete!), and press Enter key. isn't it all?

I just did which the OAuth setup guideline written as. but the result is still same. Is my oauth.json is wrong?, or my API configure is wrong?

I don't mind if you don't hear from me right away, but I'd like to see you look into this more closely. I'd like to see you create a project from scratch in Google Cloud, and create a new API key. For me, “without pass OAuth credentials” doesn't make any sense.

<!-- gh-comment-id:2600895488 --> @NangmanGureum commented on GitHub (Jan 19, 2025): > [@NangmanGureum](https://github.com/NangmanGureum) > > The documentation was already up to date: https://ytmusicapi.readthedocs.io/en/latest/setup/oauth.html > > If you only looked at the usage chapter you maybe were mislead by the constructor statement. This is fixed now: https://ytmusicapi.readthedocs.io/en/latest/usage.html > > I also added an error if oauth JSON is passed without credentials Ok, I had something misunderstood. Sorry for that. I think my `oauth.json` would have been passed in the OAuth credentials. because, the code has wrote as `YTMusic("oauth.json")`; and I do the OAuth setup guideline, enter the right API key and secret, get Google API webpage to follow the instructions, see if done as well (it was successfully complete!), and press `Enter` key. isn't it all? I just did which the [OAuth setup guideline](https://ytmusicapi.readthedocs.io/en/stable/setup/oauth.html) written as. but the result is still same. Is my `oauth.json` is wrong?, or my API configure is wrong? I don't mind if you don't hear from me right away, but I'd like to see you look into this more closely. I'd like to see you create a project from scratch in Google Cloud, and create a new API key. For me, “without pass OAuth credentials” doesn't make any sense.
Author
Owner

@sigma67 commented on GitHub (Jan 19, 2025):

Image

please read closely

<!-- gh-comment-id:2600905290 --> @sigma67 commented on GitHub (Jan 19, 2025): ![Image](https://github.com/user-attachments/assets/a5929fab-0ec3-4d51-931a-5f6a3b22c1c4) please read closely
Author
Owner

@NangmanGureum commented on GitHub (Jan 19, 2025):

Image

please read closely

I see. that's my fault. I apologize.

I'll try this thing later.

<!-- gh-comment-id:2600907690 --> @NangmanGureum commented on GitHub (Jan 19, 2025): > ![Image](https://github.com/user-attachments/assets/a5929fab-0ec3-4d51-931a-5f6a3b22c1c4) > > please read closely I see. that's my fault. I apologize. I'll try this thing later.
Author
Owner

@NangmanGureum commented on GitHub (Jan 20, 2025):

Image

please read closely

I try to fix like this(as written at an example):

from ytmusicapi import YTMusic
import pprint

yt_api = YTMusic("oauth.json", oauth_credentials=OAuthCredentials(client_id="...", client_secret="...")

# Revival by Eminem
album = yt_api.get_album("MPREb_fefKFOTEZSp")

pprint.pprint(album, sort_dicts=False)

But I got an error.

File "/Users/nanggu/__projects/python/ytmusicapi_test/main.py", line 6
    yt_api = YTMusic("oauth.json", oauth_credentials=OAuthCredentials(client_id="...", client_secret="...")
                    ^
SyntaxError: '(' was never closed

So I fix this above one. but I got another error.

Traceback (most recent call last):
  File "/Users/nanggu/__projects/python/ytmusicapi_test/main.py", line 6, in <module>
    yt_api = YTMusic("oauth.json", oauth_credentials=OAuthCredentials(client_id="...", client_secret="..."))
                                                     ^^^^^^^^^^^^^^^^
NameError: name 'OAuthCredentials' is not defined

Do I something miss? what should I do?

<!-- gh-comment-id:2601302158 --> @NangmanGureum commented on GitHub (Jan 20, 2025): > ![Image](https://github.com/user-attachments/assets/a5929fab-0ec3-4d51-931a-5f6a3b22c1c4) > > please read closely I try to fix like this(as written at an example): ```python from ytmusicapi import YTMusic import pprint yt_api = YTMusic("oauth.json", oauth_credentials=OAuthCredentials(client_id="...", client_secret="...") # Revival by Eminem album = yt_api.get_album("MPREb_fefKFOTEZSp") pprint.pprint(album, sort_dicts=False) ``` But I got an error. ``` File "/Users/nanggu/__projects/python/ytmusicapi_test/main.py", line 6 yt_api = YTMusic("oauth.json", oauth_credentials=OAuthCredentials(client_id="...", client_secret="...") ^ SyntaxError: '(' was never closed ``` So I fix this above one. but I got another error. ``` Traceback (most recent call last): File "/Users/nanggu/__projects/python/ytmusicapi_test/main.py", line 6, in <module> yt_api = YTMusic("oauth.json", oauth_credentials=OAuthCredentials(client_id="...", client_secret="...")) ^^^^^^^^^^^^^^^^ NameError: name 'OAuthCredentials' is not defined ``` Do I something miss? what should I do?
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#468
No description provided.