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

Is it possible to use_oauth with a premium user to get access to Music Premium restricted content? #1903

Open
cavaros opened this issue Mar 30, 2024 · 1 comment

Comments

@cavaros
Copy link

cavaros commented Mar 30, 2024

Hello!
Let me explain the problem first:

I'm using pytube to download some YouTube Music albums, and got this error with two of at least 200 albums (so it's a pretty rare problem):

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/lucas/repos/ytdownloader/main.py", line 184, in <module>
    globals()[sys.argv[1]]()
  File "/home/lucas/repos/ytdownloader/main.py", line 173, in run
    list_pool.map(download_playlist, links)
  File "/usr/lib64/python3.12/multiprocessing/pool.py", line 367, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/multiprocessing/pool.py", line 774, in get
    raise self._value
  File "/usr/lib64/python3.12/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
           ^^^^^^^^^^^^^^^^
  File "/home/lucas/repos/ytdownloader/main.py", line 143, in download_playlist
    print(f"Downloading {playlist.title.replace('Album - ', '')} - {author}")
                         ^^^^^^^^^^^^^^
  File "/home/lucas/repos/ytdownloader/.venv/lib64/python3.12/site-packages/pytube/contrib/playlist.py", line 351, in title
    return self.sidebar_info[0]['playlistSidebarPrimaryInfoRenderer'][
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'runs'

First I had this problem with the Playlist().title method, then I figured the code returned a playlist with 0 videos (thus unable to iterate the loop with Playlist().videos).

Only then I found the videos were in fact unavailable due to an unknown reason.

I did some digging and when using extract.playability_status(), got a message 'This video is only available to Music Premium members'

I'm using oauth with an account that have Music Premium subscription, but even so, the playability still returns the above message.

Is it possible to enable access to Music Premium restricted content when logged in with a Premium account?

The bug occurred because, I think, the Playlist class does not use the oauth credentials to get the Playlist html, hence not being able to read it from a Music Premium restricted playlist (if that exists).

I asked the question before mentioning an explanation to the bug, because if it's impossible to use the credentials to access Premium content, this error is just a unhandled exception to a Music Premium content unavailability.

Copy link

Thank you for contributing to PyTube. Please remember to reference Contributing.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant