glomatico / gytmdl

A Python CLI app for downloading YouTube Music songs with tags from YouTube Music.
109 stars 13 forks source link

Playlists that require authentication may not extract correctly #27

Closed yoshakami closed 14 hours ago

yoshakami commented 2 days ago

I tried to get albums that are not listed upon running this command (because they are premium albums), but that are listed on yt music anyways (I have a premium subscription in the cookies) gytmdl -c "C:\yt.txt" https://music.youtube.com/channel/UCNats-h_Vr0pEh5OtZo6eVw first attempt was to put the playlist link to an album gytmdl -i 774 --cover-size 2048 -s -c "C:\yt.txt" https://music.youtube.com/playlist?list=OLAK5uy_n1rux8cx7zHxJc_OjD-b6WIUAgEUziQAE which outputs this:

[INFO     17:37:59] (URL 1/1) Checking "https://music.youtube.com/playlist?list=OLAK5uy_n1rux8cx7zHxJc_OjD-b6WIUAgEUziQAE"
[INFO     17:37:59] (Track 1/7 from URL 1/1) Downloading "Fuxxin Shojo"
ERROR: [youtube:tab] None: Playlists that require authentication may not extract correctly without a successful webpage download. If you are not downloading private content, or your cookies are only for the first account and channel, pass "--extractor-args youtubetab:skip=authcheck" to skip this check
[ERROR    17:38:02] (Track 1/7 from URL 1/1) Failed to download "Fuxxin Shojo"

second attempt was to use aria2c. same output, it uses ytdlp anyways. gytmdl -i 774 --download-mode aria2c --cover-size 2048 -s -c "C:\yt.txt" --aria2c-path "C:\aria2c.exe" https://music.youtube.com/playlist?list=OLAK5uy_n1rux8cx7zHxJc_OjD-b6WIUAgEUziQAE

this is weird. because if I try with ytdlp, it works (but without metadata in the files) ytdlp --cookies "C:\yt.txt" https://music.youtube.com/playlist?list=OLAK5uy_n1rux8cx7zHxJc_OjD-b6WIUAgEUziQAE

which outputs this


[youtube:tab] Extracting URL: https://music.youtube.com/playlist?list=OLAK5uy_n1rux8cx7zHxJc_OjD-b6WIUAgEUziQAE
WARNING: [youtube:tab] YouTube Music is not directly supported. Redirecting to https://www.youtube.com/playlist?list=OLAK5uy_n1rux8cx7zHxJc_OjD-b6WIUAgEUziQAE
[youtube:tab] OLAK5uy_n1rux8cx7zHxJc_OjD-b6WIUAgEUziQAE: Downloading webpage
[youtube:tab] OLAK5uy_n1rux8cx7zHxJc_OjD-b6WIUAgEUziQAE: Redownloading playlist API JSON with unavailable videos
[download] Downloading playlist: Album - TOHO BOOTLEGS 6
[youtube:tab] Playlist Album - TOHO BOOTLEGS 6: Downloading 7 items of 7
[download] Downloading item 1 of 7
[youtube] Extracting URL: https://music.youtube.com/watch?v=uk8s0B6AGKU
[youtube] uk8s0B6AGKU: Downloading webpage
[youtube] uk8s0B6AGKU: Downloading ios player API JSON
[youtube] uk8s0B6AGKU: Downloading web creator player API JSON
[youtube] uk8s0B6AGKU: Downloading ios music player API JSON
[youtube] uk8s0B6AGKU: Downloading web music client config
[youtube] uk8s0B6AGKU: Downloading player e38bb6de
[youtube] uk8s0B6AGKU: Downloading web music player API JSON
[youtube] uk8s0B6AGKU: Downloading m3u8 information
[youtube] uk8s0B6AGKU: Downloading m3u8 information
[info] uk8s0B6AGKU: Downloading 1 format(s): 248+774
[download] Destination: Fuxxin Shojo [uk8s0B6AGKU].f248.webm
[download] 100% of    6.75MiB in 00:00:00 at 8.66MiB/s
[download] Destination: Fuxxin Shojo [uk8s0B6AGKU].f774.webm
[download] 100% of    4.93MiB in 00:00:00 at 14.68MiB/s
[Merger] Merging formats into "Fuxxin Shojo [uk8s0B6AGKU].webm"
Deleting original file Fuxxin Shojo [uk8s0B6AGKU].f248.webm (pass -k to keep)
Deleting original file Fuxxin Shojo [uk8s0B6AGKU].f774.webm (pass -k to keep)```
yoshakami commented 1 day ago

upon further investigation, I found that the problem relies in the get_tags function : ytmusic_album["audioPlaylistId"] is None

here's a dump of ytmusic_album : data.json

yoshakami commented 1 day ago

image (in case you're against downloading files)

glomatico commented 1 day ago

Thanks for identifying the issue. I'll work in a fix for these cases.

yoshakami commented 1 day ago

I managed to get playlists link download working on my own fork, but it still doesn't list premium albums, and still can't download premium musics (only playlists for now)

yoshakami commented 1 day ago

and now I got premium musics working too

yoshakami commented 1 day ago

my fix basically relies on a workaround, since the user provided the playlist id : I saved it in the class attributes. there is no need to get it from the youtube music api (which returns the "None" string for premium albums)

yoshakami commented 1 day ago

I have no idea how to list premium albums and premium singles though if the user provides a channel link, premium content is hidden (that's the only issue that I can't fix)

yoshakami commented 22 hours ago

found a way to list premium albums :) people need to run ytmusicapi oauth in the terminal. source: <https://ytmusicapi.readthedocs.io/en/latest/setup/oauth.html>

yoshakami commented 22 hours ago

now I need to find a way to download premium albums using a channel link since the premium api doesn't return the same dict with the same keys

yoshakami commented 18 hours ago

I got it working completely on my fork. if you're okay with it, I'll be making a pull request with some new cli options

glomatico commented 14 hours ago

I got it working completely on my fork. if you're okay with it, I'll be making a pull request with some new cli options

i got a better workaround, but thanks