ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.75k stars 9.98k forks source link

configure youtube-dl to create folders based on artist name. #30481

Closed aandroide closed 2 years ago

aandroide commented 2 years ago

Checklist

Question

Hi everyone I'm trying to figure out how youtube-dl to create folders based on artist name and group the tracks found even if the titles change but the alterist is always the same in the same folder. the command i am trying to use is: youtube-dl --download-archive Music/download.txt --no-post-overwrites -ciwx --add-metadata --audio-format mp3 -o "Music/%(artist)s/%(title)s.%(ext)s" https://youtube.com/playlist?list=PLracvmce8hFZcjECC2rlGMxsn1dN_69ql The folders are created but with some titles even if the artist is always the same, the program creates a new folder with a new name.

dirkf commented 2 years ago

Presumably the extracted artist value looks the same but isn't identical. Show us examples. Also, extract the artist value in two cases that cause different directories and pass them into a hex-dump tool.

aandroide commented 2 years ago

I created a "test" folder and I created a playlist with only 2 songs to show the error that I want to point out with some artists it works and others not. I attach image of the given command. Cattura

and the content is this as you can see it created a "NA" folder 1

inside the NA folder I have this file note the title and artist are written: 2

and inside the "max pezzali" folder I have this: 3

in reality the artist is the same person. why did he create 2 separate folders for me, one of which is named NA? Thanks!!

dirkf commented 2 years ago

NA is the default used when a template field is missing.

Some of your songs are tagged in the site with an artist and some aren't (or the extractor isn't finding the tag).

The code documentation of artist says:

    The following fields should only be used when the media is a track or a part of
    a music album:
...
    artist:         Artist(s) of the track.
...

So, as a one-step procedure, your plan is doomed. You might be able to use some other tool to extract an artist value from each song that ends up in NA and move and/or re-tag it appropriately. Or perhaps there's some other template value that might be more reliable than artist but with similar semantics (creator?). Or investigate the --metadata-from-title option since you are converting to MP3.

aandroide commented 2 years ago

if I use "creator" no folders are created. it would appear that only "artist" creates the folders. or am I wrong?

dirkf commented 2 years ago

I guess so. Any output template field will create a directory if used in the directory part of the output filename template, and the directory doesn't already exist. If the field isn't set by the extractor, the directory name will be NA by default. Apparently creator isn't extracted for the item that you tested.

You can check if the artist is set for an item by checking that the output of yt-dl with the options --get-filename -o '%(artist)s' --output-na-placeholder '' (and the item URL) is not empty. Obviously that idea can be applied to any other template field.

aandroide commented 2 years ago

ok thank you for all this information. maybe in the future it would be nice if youtube-dl can do everything automatically if some metadata is missing

dirkf commented 2 years ago

If only we knew how to discover metadata that isn't provided! Welcome to the nightmare world of media cataloguing.