Yt-dlp question

Let’s say hypothetically I open yt-dlp in the terminal.

Let’s say hypothetically I launch freetube at the same time.

Let’s say hypothetically I search for an old rock song in Freetube, find it, right click, “get youtube links” and paste it into yt-dlp and get the song…

scr

Question: who adds that bracketed data and what does it mean? I edit it out before I throw it in my playlist but what is it?

The data in the brackets is the ID for the YouTube video, it can be found at the end of the video URL. On the music thread for example if you hover over the video text it will show the ID in the URL at the bottom left of the browser.

It may be added so you can find the Video later by searching for it’s ID.

Not sure what you mean by who adds it, I think YT-DLP adds it as default as far as I’m aware.

I had a quick look and apparently it is used to keep the file name unique as multiple videos could have the same name.

1 Like

you got it: I was wondering whose data was it and who added it between yt-dlp, freetube, & youtube.

yt-dlp https://youtu.be/ypr18UmxOas

para

You are correct, I never noticed this before.

You are saying yt-dlp adds youtube’s address/identifier number for an alternative user indexing type thing, so they can find the exact video again?

Interesting and somewhat useful if you like searching this way.

I stuck just that number into freetube and hot damn, they found it.

Thanks @_Six

Just FYI, the -o flag in yt-dlp can get rid of that junk and rename the file to your liking. For example, yt-dlp -o ‘%(artist)s-%(title)s.%(ext)s’ “<youtube url>will strip out the youtube ID and save the file with just the artist’s name, hyphen, and song title + ext.

I use a fancier version of this from reddit for dl’ing albums (only ones in the public domain, obviously!): yt-dlp -o ‘%(playlist_index)02d - %(title)s.%(ext)s’ “<playlist url>”. It numbers the tracks correctly and gives the title of each. I find it works well, despite occasional glitches. I just alias yt-dlp -o ‘%(playlist_index)02d - %(title)s.%(ext)s’ to “yt-album” and then use yt-album “<playlist url>"when I want to grab something. You can obviously customize all this in various ways. The man page has the full list of fields, etc.

3 Likes

As far as I know yt-dlp only adds it to keep the name of the video unique. Or maybe so people can find the video again if they didn’t save it through YouTube or Freetube.

The name can be modified and changed by manually setting what the name should be via yt-dlp options. I don’t personally know how to do it as I haven’t tried (I mostly download videos and delete them after) but @drhoopoe has added some information on this.

1 Like

Using your syntax I get error.

bash: syntax error near unexpected token `(’

Closely watch the quoting, this forum modifies the quotes: Use ' and ", not the curly ones. Also, the last quote at the right is missing.

I don’t know if yt-dlp sanitizes filenames, so you might get filenames that don’t work on all platforms.

I noticed it was missing quote at the end too. Anyway, I replaced the parentheses with double quotes, and it downloaded. The resulting file name is, ‘%artists-%titles.%exts’.webm. I guess it will take some tweaking. Another interesting thing is the terminal prompt did not come back. It had a blank cursor like it still working on something although it closed when I clicked the x. It did not ask me if I wanted to close the terminal like it sometimes does when it is still working. Not sure what state it was in.

Don’t just experiment wildly—the parenthess are used. Bash just complained because the opening/closing quotes were typographic quotes (‘…’), not straight apostrophes ('…'). So bash didn’t see it as quoted, suddenly saw the command to open a subshell (artist) and promptly diagnosed a syntax error.

The quoting issue often happens because forum software (or your Mac!) “cleverly” decides it should replace straight quotes and apostrophes with typographical ones. Just remember that for shell commands in almost all cases the simple straight apostrophe ' and quotes " are the correct ones to use.

So @drhoopoe’s command above would actually become:

yt-dlp -o '%(artist)s-%(title)s.%(ext)s' "<youtube url>"

yt-dlp’s output templates use printf formatting, see man yt-dlp and look for OUTPUT TEMPLATE (far down).

If your bash still waits for input (because a quote wasn’t closed), you could abort input using Ctrl+C in most cases.

1 Like

Oops! Sorry about leaving off that last quote! With that it in place it runs fine for me.

Default template