From 9f5cfd946988e94aec0a1ac22798a44b12a94591 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Thu, 21 Nov 2024 20:26:16 -0500 Subject: [PATCH] Update aliases --- .aliases | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/.aliases b/.aliases index 0918a72..fa4f2e2 100644 --- a/.aliases +++ b/.aliases @@ -492,15 +492,22 @@ download_youtube_vid() { printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" } + +# +# You can control which videos are downloaded using the opts param: +# --playlist-start NUMBER (1-indexed) +# --playlist-end NUMBER +# --playlist-items ITEMS (Can be something like 1,2,5 or a range like 1-3,7,10-20) +# download_youtube_playlist() { local format="$1" local url="$2" local dir_name="$3" shift 3 - local opts="$@" + local opts="$@ --write-sub --sub-lang en --embed-subs" - if [[ $url == "" ]]; then - error "Usage: " + if [[ $url == "" || $dir_name == "" ]]; then + error "Usage: " return fi @@ -513,22 +520,18 @@ download_youtube_playlist() { opts+=" --merge-output-format mp4" fi - opts+=" --write-sub --sub-lang en --embed-subs" - - if [[ $dir_name != "" ]]; then - make_vid_dir_and_cd_into $url "$dir_name" - if [[ $? -ne 0 ]]; then - return - fi + make_vid_dir_and_cd_into $url "$dir_name" + if [[ $? -ne 0 ]]; then + return fi - local cmd="yt-dlp.exe -f $format -o \"v%(playlist_index)03d--%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s\" $opts $url" + local cmd="yt-dlp.exe -f $format -o \"%(playlist_index)03d--%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s\" $opts $url" eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string. # Removing any trailing subtitle files rm *.vtt *.srt 2>/dev/null - if [[ $dir_name == "1" ]]; then cd ..; fi + cd .. printf "${BOLD}Finished downloading the playlist\n${NORMAL}" } @@ -873,13 +876,14 @@ download_twitter_vid() { printf "${BOLD}Downloading Twitter vid.${NORMAL}\n" + local opts="" + if [[ $vid_name == "" ]]; then local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-twitter-%(id)s" - local opts="" else local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-twitter-%(id)s" shift 4 - local opts="$@" + opts="$@" fi if [[ $make_folder == "1" ]]; then @@ -928,13 +932,14 @@ download_instagram_vid() { printf "${BOLD}Downloading Instagram vid.${NORMAL}\n" + local opts="" + if [[ $vid_name == "" ]]; then local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-ig-%(id)s" - local opts="" else local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-ig-%(id)s" shift 4 - local opts="$@" + opts="$@" fi if [[ $make_folder == "1" ]]; then @@ -1074,12 +1079,13 @@ alias yt-1080-shortname-t='download_youtube_vid "137+140" $SHORTNAME_ON $TRANSC alias yt-720-t='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSCRIBE_ON' alias yt-720-shortname-t='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_ON' #--------------------------- -alias yt-playlist='download_youtube_playlist ""' +alias yt-playlist='download_youtube_playlist ""' +alias yt-playlist-audio='download_youtube_playlist "140"' +alias yt-playlist-1440='download_youtube_playlist "620+140"' +alias yt-playlist-1080='download_youtube_playlist "137+140"' +alias yt-playlist-720='download_youtube_playlist "136+140"' +alias yt-playlist-tiny='download_youtube_playlist "160+140"' alias yt-playlist-list='download_youtube_playlist_list ' -alias yt-playlist-1440='download_youtube_playlist "620+140"' -alias yt-playlist-1080='download_youtube_playlist "137+140"' -alias yt-playlist-720='download_youtube_playlist "136+140"' -alias yt-playlist-tiny='download_youtube_playlist "160+140"' #--------------------------- alias yt-audio='download_youtube_audio'