Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Album Retrieval from YouTube Music API #712

Closed
scharc opened this issue Jan 6, 2025 · 7 comments
Closed

Inconsistent Album Retrieval from YouTube Music API #712

scharc opened this issue Jan 6, 2025 · 7 comments
Labels
invalid This doesn't seem right

Comments

@scharc
Copy link

scharc commented Jan 6, 2025

Describe the bug
When fetching audiobook content from YouTube Music using the API, there's an inconsistent behavior in album retrieval. While some artists like "Wieso? Weshalb? Warum?" return their complete catalog (~134 albums), other artists like Benjamin Blümchen return only a fraction of their content (10-22 albums out of 160+).

To Reproduce
Steps to reproduce the behavior:

  1. Set up a Python environment with ytmusicapi
  2. Create authentication using browser.json from Firefox cookies
  3. Run a query for the following YouTube Music channels:
    • Benjamin Blümchen (UCorpPhp8NCbXxXQqMLjFNmA)
    • Wieso? Weshalb? Warum? (UCISZHx1LIpYedNC5qvJU9eA)
  4. Observe the inconsistency:
    • Wieso? Weshalb? Warum?: Returns complete catalog (~134 albums)
    • Benjamin Blümchen: Returns only fraction (~10-22 albums out of 160+)

Additional context
Example code showing the inconsistent behavior:

from ytmusicapi import YTMusic
ytmusic = YTMusic("browser.json")

# Test with Wieso? Weshalb? Warum? - Works correctly
artist_data = ytmusic.get_artist("UCISZHx1LIpYedNC5qvJU9eA")
albums_section = artist_data.get('albums', {})
browse_id = albums_section.get('browseId')
params = albums_section.get('params')
www_albums = ytmusic.get_artist_albums(browse_id, params)
# Returns ~134 albums correctly

# Test with Benjamin Blümchen - Incomplete results
artist_data = ytmusic.get_artist("UCorpPhp8NCbXxXQqMLjFNmA")
albums_section = artist_data.get('albums', {})
browse_id = albums_section.get('browseId')
params = albums_section.get('params')
ben_albums = ytmusic.get_artist_albums(browse_id, params)
# Returns only ~10 albums

Attempted workarounds:

  1. Using different search terms including German spelling variations (ü/ue)
  2. Increasing search limit to 500
  3. Using multiple search methods (direct API, search, playlist content)
  4. Trying different content types (albums, singles, shows)
  5. Using ignore_spelling=True to prevent auto-correction

Expected behavior:

  • Wieso? Weshalb? Warum?: ~134 albums (working correctly)
  • Benjamin Blümchen: ~160+ albums
  • Other German audiobook series: Complete catalogs

Actual behavior:

  • Wieso? Weshalb? Warum?: ~134 albums (working correctly)
  • Benjamin Blümchen: 10-22 albums (varies by method)
  • Others: Similarly incomplete results

This inconsistency suggests the issue might be related to:

  • Different channel/content organization on YouTube Music
  • Possible pagination or content grouping differences
  • API limitations for specific content types or channels

Environment:

  • Python 3.12
  • ytmusicapi 1.9.1
  • Platform: Linux/Ubuntu with Wayland
@sigma67
Copy link
Owner

sigma67 commented Jan 7, 2025

The results are localized. If your (YTMusic instance client) language is English you will see fewer albums.

@scharc
Copy link
Author

scharc commented Jan 7, 2025

Hi,

Thanks for the suggestion about using the language parameter. I've done extensive testing with different language settings (en, de, it) and found that the results appear to be identical across all languages:

  1. Test setup:
  • Used YTMusic with different language parameters: YTMusic("browser.json", language="de")
  • Modified browser.json with different Accept-Language headers ("de-DE,de;q=0.9" etc.)
  • Tested with multiple artists (Benjamin Blümchen, Wieso? Weshalb? Warum?, etc.)
  • Tried different language codes (en, de, it)
  1. Results:
  • The number of albums/content remains exactly the same across all languages
  • Sample output for one artist (Benjamin Blümchen):
    • en: 10 albums
    • de: 10 albums
    • it: 10 albums
  • Results were identical regardless of browser.json language settings
  1. Testing method:
ytmusic = YTMusic("browser.json", language="de")  # Also tried "en" and "it"
artist_data = ytmusic.get_artist(channel_id)
albums_section = artist_data.get('albums', {})

Is there something else I should try? Or might there be another parameter that affects localization besides just the language setting and Accept-Language header?

I can share more detailed test results if needed.

@sigma67
Copy link
Owner

sigma67 commented Jan 7, 2025

Are your authentication credentials valid? I only get the full list on authenticated accounts

@sigma67 sigma67 added the invalid This doesn't seem right label Jan 7, 2025
@sigma67
Copy link
Owner

sigma67 commented Jan 7, 2025

fwiw these types of issues are usually easier to debug by checking what's shown on the web view when using different accounts/settings

@scharc
Copy link
Author

scharc commented Jan 7, 2025

Thank you for the quick response! I apologize for causing confusion - you're absolutely right. My issue wasn't with the API at all, but rather with my incorrect browser.json authentication. A simple auth status check would have saved me time and helped me identify the real issue immediately. This would be super helpful for other new developers like me who are just getting started with the library.

Thanks for maintaining such a helpful library and for the fast responses to questions!

@scharc scharc closed this as completed Jan 7, 2025
@scharc
Copy link
Author

scharc commented Jan 7, 2025

fwiw these types of issues are usually easier to debug by checking what's shown on the web view when using different accounts/settings

I do not understand any of that. Maybe a guide could help others like me that are new to the api?

@sigma67
Copy link
Owner

sigma67 commented Jan 7, 2025

It's no wizardry. Just go to music.youtube.com in your browser and try logged-in, logged-out, different languages etc.

All this project does is send the same requests that are sent in your browser, so the results should always be the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants