| yt_dl.sh - dotfiles - These are my dotfiles. There are many like it, but these … | |
| git clone git://jay.scot/dotfiles | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| yt_dl.sh (2215B) | |
| --- | |
| 1 #!/bin/sh | |
| 2 | |
| 3 # Instead of using tools like ytcc we can just use yt-dlp directly | |
| 4 # with a simple shell script without the need for python dependencies | |
| 5 # etc. | |
| 6 # | |
| 7 # Jay Scott <[email protected]> | |
| 8 | |
| 9 # user config | |
| 10 savepath="/home/jay/media/videos" | |
| 11 cachedir="${HOME}/.cache/yt_dl" | |
| 12 notify="echo \"%(title)s\" | mail -s 'YT: %(channel)s' jay" | |
| 13 | |
| 14 # static config | |
| 15 yt="yt-dlp" | |
| 16 baseurl="https://www.youtube.com/playlist?list=" | |
| 17 | |
| 18 main() { | |
| 19 | |
| 20 mkdir -p "${cachedir}" | |
| 21 | |
| 22 $1 "mre_steve" "UU2I6Et1JkidnnbWgJFiMeHA" | |
| 23 $1 "harald_baldr" "UUKr68ZJ4vv6VloNdnS2hjhA" | |
| 24 $1 "dale_philip" "UUKygRpISlqs5TufcT3JtRng" | |
| 25 $1 "simon_wilson" "UUQCrKxBj5Id79syQEsY2Qxg" | |
| 26 $1 "hexdsl" "UURE3NFNtdjR96-H4QG4U1Fg" | |
| 27 $1 "distrotube" "UUVls1GmFKf6WlTraIb_IaJg" | |
| 28 $1 "brodie_robertson" "UUld68syR8Wi-GY_n4CaoJGA" | |
| 29 $1 "pppeter" "UUnHEz9DZ6EAof1-DaQGD_Xw" | |
| 30 $1 "bald_and_bankrupt" "UUxDZs_ltFFvn0FDHT6kmoXA" | |
| 31 $1 "vagrant_holiday" "UUgNqlRGqHdxNRPR6ycynWhw" | |
| 32 $1 "chris_ramsay" "UUrPUg54jUy1T_wII9jgdRbg" | |
| 33 $1 "c90adventures" "UUVqpNG1R72i21jh-nAxEk4A" | |
| 34 $1 "abroad_in_japan" "UUHL9bfHTxCMi-7vfxQ-AYtg" | |
| 35 $1 "quin69" "UUpNBjjE8y8eFPhDU4YzYmKA" | |
| 36 $1 "clawd00d" "UUdQ3VoDGjjl3NsfB3V0mPng" | |
| 37 $1 "serpentza" "UUl7mAGnY4jh4Ps8rhhh8XZg" | |
| 38 $1 "preach_gaming" "UUXJL3ST-O0J3nqzQyPJtpNg" | |
| 39 $1 "indigo_traveller" "UUXulruMI7BHj3kGyosNa0jA" | |
| 40 $1 "sidenote" "UURvWwMPr2SmSG7rXXzeEUdA" | |
| 41 $1 "dave_snider" "UU7uO9V1Frl_wPd9d1qOm_RQ" | |
| 42 $1 "bright_sun_films" "UU5k3Kc0avyDJ2nG9Kxm9JmQ" | |
| 43 $1 "tuxfoo" "UUWpoyqSBIXtylRLFgP3PFfg" | |
| 44 $1 "liamtheterrible" "UULF5Au9oV9G4qbyTKJmUcWWJg" | |
| 45 $1 "mentourpilot" "UULFwpHKudUkP5tNgmMdexB3ow" | |
| 46 $1 "will_whereabouts" "UULFvaxWoGczo5olB3lgC6Nr6A" | |
| 47 $1 "linus_tech_tips" "UULFXuqSBlHAE6Xw-yeJA0Tunw" | |
| 48 $1 "auto_alex" "UULFqWFLuBLPiaeNzYAek6BOmA" | |
| 49 $1 "zac" "UULFcjx6m03fZwtRBFn1Cf7kKQ" | |
| 50 $1 "openbsdguy" "UULFqGmpMaWCpLe7hpnNnU09TA" | |
| 51 } | |
| 52 | |
| 53 get_video() { | |
| 54 echo "fetching ... $1" | |
| 55 $yt -q --restrict-filename --download-archive \ | |
| 56 "${cachedir}/${1}" "${baseurl}${2}" -o \ | |
| 57 "${savepath}/${1}/%(playlist_index)s_%(title)s.%(ext)s" \ | |
| 58 --exec "$notify" | |
| 59 } | |
| 60 | |
| 61 catchup() { | |
| 62 echo "catching up ... $1" | |
| 63 $yt --flat-playlist --get-id \ | |
| 64 "${2}" | sed 's/.*/youtube &/' >"${cachedir}/${1}" | |
| 65 } | |
| 66 | |
| 67 case $1 in | |
| 68 -m) | |
| 69 main catchup | |
| 70 exit | |
| 71 ;; | |
| 72 -n) | |
| 73 catchup "$2" "$3" | |
| 74 exit | |
| 75 ;; | |
| 76 | |
| 77 *) | |
| 78 main get_video | |
| 79 exit | |
| 80 ;; | |
| 81 esac |