| ytd.sh - dotfiles - These are my dotfiles. There are many like it, but these ar… | |
| git clone git://jay.scot/dotfiles | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| ytd.sh (2349B) | |
| --- | |
| 1 #!/bin/sh | |
| 2 | |
| 3 # yt-dlp subscription fetcher | |
| 4 # jay <[email protected]> | |
| 5 | |
| 6 savepath="$HOME/media/youtube" | |
| 7 cachedir="$HOME/.cache/yt_dl" | |
| 8 yt="yt-dlp" | |
| 9 baseurl="https://www.youtube.com/playlist?list=" | |
| 10 | |
| 11 info() { | |
| 12 printf "\033[35mYT ➤\033[36m %s\033[0m\n" "$1" | |
| 13 } | |
| 14 | |
| 15 main() { | |
| 16 mkdir -p "${cachedir}" | |
| 17 mkdir -p "${savepath}" | |
| 18 | |
| 19 action="$1" | |
| 20 | |
| 21 "$action" "steve1989mreinfo" "UU2I6Et1JkidnnbWgJFiMeHA" | |
| 22 "$action" "simon_wilson" "UUQCrKxBj5Id79syQEsY2Qxg" | |
| 23 "$action" "c90adventures" "UUVqpNG1R72i21jh-nAxEk4A" | |
| 24 "$action" "indigo_traveller" "UUXulruMI7BHj3kGyosNa0jA" | |
| 25 "$action" "pppeter" "UUnHEz9DZ6EAof1-DaQGD_Xw" | |
| 26 "$action" "abroad_in_japan" "UUHL9bfHTxCMi-7vfxQ-AYtg" | |
| 27 "$action" "serpentza" "UUl7mAGnY4jh4Ps8rhhh8XZg" | |
| 28 "$action" "the_lazy_peon" "UUE-f0sqi-H7kuLT0YiW9rcA" | |
| 29 "$action" "zav_alsop" "UUcjx6m03fZwtRBFn1Cf7kKQ" | |
| 30 "$action" "steve_marsh" "UUBhQuxcHU3aydk_zTXcbdTg" | |
| 31 "$action" "planes_trains_everything" "UUcKw8Eg0FfRvhIAnC0cPGAA" | |
| 32 "$action" "we_hate_the_cold" "UULmltEyJ0zBsKnL8bWSdn3A" | |
| 33 "$action" "astonishing_glasgow" "UUIDIqg7LhjLFCyD2awY_38g" | |
| 34 "$action" "drain_cleaning_aus" "UU7sGXeJOixPBgJ3r5R55JYg" | |
| 35 "$action" "mike_okay" "UUpp3cHR9TWVyXqL1AVw4XkA" | |
| 36 "$action" "rhykker" "UURl31PWkfF0a3j3hiDRaCGA" | |
| 37 "$action" "brodie_robertson" "UUld68syR8Wi-GY_n4CaoJGA" | |
| 38 "$action" "distrotube" "UUVls1GmFKf6WlTraIb_IaJg" | |
| 39 "$action" "max_roving" "UUOxpcQ7KtZc7fd0jhnWS0Sg" | |
| 40 "$action" "misfit_minds" "UUEpHkpv4_CgZIEadjjOv4jA" | |
| 41 "$action" "better_offline" "UUsdzuPs5NKvdsBkQnP7Af8w" | |
| 42 "$action" "simon_doherty" "UU2smcaU7852QtVvJz48dCRw" | |
| 43 "$action" "phil_carr" "UULva3lkHR6B5OO-eiVaPnDg" | |
| 44 "$action" "andrea_borman" "UUJsinEiaDqEn8a-GcADVEVA" | |
| 45 "$action" "veronica_explains" "UUMiyV_Ib77XLpzHPQH_q0qQ" | |
| 46 "$action" "chubby_trekka" "UU5YskHOZiTEzjdps94jFX1g" | |
| 47 "$action" "bythecurb" "UUUZ68a2OJnyTutbTNG1tSpA" | |
| 48 "$action" "naomibrockwell" "UUSuHzQ3GrHSzoBbwrIq3LLA" | |
| 49 "$action" "gotbletu" "UUkf4VIqu3Acnfzuk3kRIFwA" | |
| 50 } | |
| 51 | |
| 52 get_video() { | |
| 53 info "Fetching latest from $1" | |
| 54 mkdir -p "${savepath}/${1}" | |
| 55 | |
| 56 "$yt" -q --restrict-filename \ | |
| 57 --download-archive "${cachedir}/${1}" \ | |
| 58 "${baseurl}${2}" \ | |
| 59 -o "${savepath}/${1}/%(playlist_index)s_%(title)s.%(ext)… | |
| 60 } | |
| 61 | |
| 62 catchup() { | |
| 63 info "Catching up on $1" | |
| 64 "$yt" --flat-playlist --get-id \ | |
| 65 "${baseurl}${2}" | sed 's/.*/youtube &/' >"${cachedir}/$… | |
| 66 } | |
| 67 | |
| 68 case "$1" in | |
| 69 -m) | |
| 70 main catchup | |
| 71 ;; | |
| 72 -n) | |
| 73 catchup "$2" "$3" | |
| 74 ;; | |
| 75 *) | |
| 76 main get_video | |
| 77 ;; | |
| 78 esac |