this post was submitted on 05 Jun 2025
59 points (94.0% liked)

datahoarder

7987 readers
15 users here now

Who are we?

We are digital librarians. Among us are represented the various reasons to keep data -- legal requirements, competitive requirements, uncertainty of permanence of cloud services, distaste for transmitting your data externally (e.g. government or corporate espionage), cultural and familial archivists, internet collapse preppers, and people who do it themselves so they're sure it's done right. Everyone has their reasons for curating the data they have decided to keep (either forever or For A Damn Long Time). Along the way we have sought out like-minded individuals to exchange strategies, war stories, and cautionary tales of failures.

We are one. We are legion. And we're trying really hard not to forget.

-- 5-4-3-2-1-bang from this thread

founded 5 years ago
MODERATORS
 

I'm sure some of you already using it like this but if not, this could be useful for you.

It creates a directory with the channel's name, create sub-directories with the playlist name, it gives them a number and put them in an order, it can continue to download if you have to cancel it midway.

You can modify it to your needs.

Add this to your ~/.bashrc or your favourite shell config.

alias yt='yt-dlp --yes-playlist --no-overwrites --download-archive ~/Downloads/yt-dlp/archive.txt -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" -o "~/Downloads/yt-dlp/%(uploader)s/%(playlist_title,single_playlist)s/%(playlist_index,00)s - %(title)s - [%(id)s].%(ext)s"'

You can even limit the download speed by adding this parameter: --limit-rate 640K This example is for 5 Mb/s.

top 15 comments
sorted by: hot top controversial new old
[–] bradfrank@programming.dev 7 points 1 day ago (1 children)

I do something very similar. Thanks for sharing cause there's always something to learn by seeing how someone else solved a problem. I'll share mine here too if that's cool:

#!/usr/bin/env bash

music() {
  case $(uname -s) in
    Darwin)
      yt-dlp --format bestaudio --extract-audio --audio-format mp3 \
        --postprocessor-args "-strict experimental" "$1" ;;
    Linux)
      yt-dlp --format bestaudio --extract-audio --audio-format mp3 "$1" ;;
  esac
}

video() {
  yt-dlp \
    --format "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best" \
    --merge-output-format mp4 \
    -o "%(title)s.%(ext)s" "$1"
}

while getopts ':hm:v:' flag; do
  case "$flag" in
    h) echo "Usage: youtube [-m(usic) <url> | -v(ideo) <url>]" ; exit 0 ;;
    m) music "$OPTARG" ;;
    v) video "$OPTARG" ;;
    *) echo "Invalid argument." >&2 ; exit 1 ;;
  esac
done
[–] muhyb@programming.dev 3 points 1 day ago

It's totally cool! I like to see others' scripts. I agree, there is always something new to learn. I also liked how human readable is this. Thanks for sharing.

[–] catloaf@lemm.ee 20 points 2 days ago (2 children)
[–] LeninOnAPrayer@lemm.ee 3 points 1 day ago

Eh sometimes you just want "download_shit" and "download_shit_but_slow".

Remembering that there is a config and where the fuck it is is half the battle for me sometimes.

[–] three@lemmy.zip 5 points 2 days ago

oooo someone didn't read the documentation

[–] dessalines@lemmy.ml 4 points 2 days ago (2 children)

You really shouldn't build these from scratch, but use existing time-tested configs, like

https://github.com/TheFrenchGhosty/TheFrenchGhostys-Ultimate-YouTube-DL-Scripts-Collection/

[–] Appoxo@lemmy.dbzer0.com 4 points 1 day ago (1 children)

Why not? Why not learn how to use a tool??

[–] dessalines@lemmy.ml 0 points 1 day ago (1 children)

Because other people in the datahoarding community already spent a lot of time collaborating and finding the best config.

[–] Appoxo@lemmy.dbzer0.com 2 points 1 day ago

And now you think we have enough and don't need more?
Strange way of thinking.

[–] muhyb@programming.dev 3 points 1 day ago

Actually I'm quite proud of my version but didn't know about these at all. If I knew about this prior, I most likely wouldn't try to build from scratch. Thanks for sharing.

[–] anotherandrew@mbin.mixdown.ca 3 points 2 days ago (1 children)

I have two depending on what I'm grabbing is part of a playlist (where I want to maintain order) or not:

--download-archive archive.txt --write-auto-subs --sub-langs en --embed-subs -o "%(upload_date)s_%(title)s_%(id)s.%(ext)s" -S res,vcodec:h264,acodec:m4a

or

--download-archive archive.txt --write-auto-subs --sub-langs en --embed-subs -o "%(playlist_title)s/%(playlist_index)s_%(upload_date)s_%(title)s_%(id)s.%(ext)s" -S res,vcodec:h264,acodec:m4a

that --download-archive archive.txt is a godsend for when I rediscover something I've already grabbed. I often move the files to better locations after, but archive.txt doesn't care. Embedding the subtitles, forcing h264/m4a (because more and more things are webp it seems), and renaming the file to the title + youtube ID are what make up the rest.

[–] muhyb@programming.dev 2 points 2 days ago (1 children)

I used to force formats too but sometimes it fails because it cannot find the corresponding format. upload_date seems useful, I should update mine.

Also, didn't know it can also download subs. Good to know. Thanks for your version.

[–] anotherandrew@mbin.mixdown.ca 2 points 2 days ago (1 children)

I've been lucky I guess -- haven't had a failure with force formats before, I always thought if it couldn't download the format I wanted it was spinning the conversion over to ffmpeg. I haven't really paid that close attention to the output. :-)

[–] muhyb@programming.dev 1 points 1 day ago

Well, it's generally fine for relatively new stuff but now to think I guess I had this problem with the older videos, older than this webm era. Other than that, it's great to be able to even pick a format. :)

[–] Zachariah@lemmy.world 3 points 2 days ago