From f70bc8b9cd193020bcf867b901617c6c742d496f Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Tue, 6 Jun 2023 15:48:43 -0400 Subject: [PATCH] Alias tweaks around video dl --- aliases | 100 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 16 deletions(-) diff --git a/aliases b/aliases index 4e5c137..3305319 100644 --- a/aliases +++ b/aliases @@ -212,7 +212,7 @@ check_signature() { local sig_file="$4" if [[ $hashes_file == "" || $pem_file == "" || $sig_file == "" ]]; then - error "Usage: $0 " + error "Usage: " return fi @@ -350,11 +350,38 @@ make_vid_dir_and_cd_into() { return 0 } -transcribe_vid() { - name_without_ext="${1%.*}" - transcribe-video "$1" "$name_without_ext" base small +function my_transcribe_video() { + file="$1" + output="$2" + if [[ $file == "" ]]; then + printf "Usage: \n" + return + fi + if [[ $output == "" ]]; then + output="${1%.*}" # just use the input name without the extension. + fi + # Tiny is fast and semi-accurate, so whatever. + # Base is pretty good overall. It has good punctuation inserting and + # catches most words. Small and medium can do better word detection at + # times, but suffer from bad punctuation. Medium is particularly bad and + # not adding commas and periods. + transcribe-video "$file" "$output" base tiny } +function my_transcribe_video_all_models() { + file="$1" + output="$2" + if [[ $file == "" ]]; then + printf "Usage: \n" + return + fi + if [[ $output == "" ]]; then + output="${1%.*}" # just use the input name without the extension. + fi + transcribe-video "$file" "$output" tiny base small medium +} + + # Download YouTube videos. Note that yt-dlp downloads a lot faster than streamlink. download_youtube_vid() { local format="$1" @@ -367,7 +394,7 @@ download_youtube_vid() { local opts="$@" if [[ $url == "" ]]; then - error "Usage: $0 " + error "Usage: " return fi @@ -421,7 +448,7 @@ download_youtube_vid() { rm *.vtt *.srt 2>/dev/null if [[ $transcribe == "1" ]]; then - transcribe_vid "$filename" + my_transcribe_video "$filename" fi if [[ $make_folder == "1" ]]; then cd ..; fi @@ -437,7 +464,7 @@ download_youtube_playlist() { local opts="$@" if [[ $url == "" ]]; then - error "Usage: $0 " + error "Usage: " return fi @@ -470,6 +497,44 @@ download_youtube_playlist() { printf "${BOLD}Finished downloading the playlist\n${NORMAL}" } +download_youtube_playlist_list() { + local url="$1" + local output_name="$2" + shift 2 + local opts="$@" + + if [[ $url == "" || $output_name == "" ]]; then + error "Usage: " + return + fi + + printf "${BOLD}Downloading Youtube playlist video list\n\n${NORMAL}" + + local cmd="yt-dlp.exe --ignore-errors -O \"%(playlist_index)s-%(title)s--%(id)s\" --skip-download $opts $url" + eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string. + + printf "${BOLD}Finished downloading the playlist video list\n${NORMAL}" +} + +download_youtube_uploads_list() { + local url="$1" + local output_name="$2" + shift 2 + local opts="$@" + + if [[ $url == "" || $output_name == "" ]]; then + error "Usage: " + return + fi + + printf "${BOLD}Downloading Youtube uploads list\n\n${NORMAL}" + + local cmd="yt-dlp.exe --ignore-errors -O \"%(video_autonumber)s-%(upload_date>%Y-%m-%d)s--%(title)s--%(id)s\" --skip-download $opts $url" + eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string. + + printf "${BOLD}Finished downloading the upload list\n${NORMAL}" +} + # Download Twitch chat transcript actually_download_twitch_chat() { local url="$1" @@ -493,7 +558,7 @@ download_twitch_chat() { local opts="$@" if [[ $url == "" ]]; then - error "Usage: $0 " + error "Usage: " return fi @@ -531,7 +596,7 @@ download_twitch_vid() { local opts="$@" if [[ $url == "" ]]; then - error "Usage: $0 " + error "Usage: " return fi @@ -617,7 +682,7 @@ download_twitch_vid() { fi if [[ $transcribe == "1" ]]; then - transcribe_vid "$filename" + my_transcribe_video "$filename" fi if [[ $make_folder == "1" ]]; then cd ..; fi @@ -640,7 +705,7 @@ download_vimeo_vid() { local opts="$@" if [[ $format == "" || $url == "" ]]; then - error "Usage: $0 " + error "Usage: " return fi @@ -691,7 +756,7 @@ download_vimeo_vid() { fi if [[ $transcribe == "1" ]]; then - transcribe_vid "$filename" + my_transcribe_video "$filename" fi if [[ $make_folder == "1" ]]; then cd ..; fi @@ -707,7 +772,7 @@ download_twitter_vid() { local vid_name="$4" if [[ $url == "" ]]; then - error "Usage: $0 " + error "Usage: " return fi @@ -759,7 +824,7 @@ download_instagram_vid() { local vid_name="$4" if [[ $url == "" ]]; then - error "Usage: $0 " + error "Usage: " return fi @@ -811,7 +876,7 @@ download_mp4() { local filename="$2" if [[ $url == "" || $filename == "" ]]; then - error "Usage: $0 " + error "Usage: " return fi @@ -834,7 +899,7 @@ download_from_m3u8() { local filename="$2" if [[ $m3u8_path == "" || $filename == "" ]]; then - error "Usage: $0 " + error "Usage: " return fi @@ -853,6 +918,8 @@ download_from_m3u8() { #------------------------------------------------- # YouTube Vid DL #------------------------------------------------- +alias yt-list='download_youtube_uploads_list ' + alias yt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_OFF' alias yt-shortname='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_OFF' alias yt-1080='download_youtube_vid "137+140" $SHORTNAME_OFF $TRANSCRIBE_OFF' @@ -868,6 +935,7 @@ alias yt-720-t='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSC alias yt-720-shortname-t='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_ON' #--------------------------- alias yt-playlist='download_youtube_playlist ""' +alias yt-playlist-list='download_youtube_playlist_list ' 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"'