Update aliases
This commit is contained in:
parent
3536a8b03f
commit
f1cbe81655
79
aliases
79
aliases
|
@ -153,26 +153,50 @@ function dl_youtube_vid {
|
||||||
shift 2
|
shift 2
|
||||||
local opts="$@"
|
local opts="$@"
|
||||||
opts+=" --all-subs --embed-subs"
|
opts+=" --all-subs --embed-subs"
|
||||||
local name_format="%(upload_date)s%(title)s-youtube-%(id)s.%(ext)s"
|
local name_format=$(youtube-dl.exe --get-filename -o "%(upload_date)s-%(title)s-youtube-%(id)s.%(ext)s" $url)
|
||||||
|
name_format="${name_format:0:4}-${name_format:4:2}-${name_format:6}"
|
||||||
|
|
||||||
if [[ $format == "" ]]; then
|
if [[ $format == "" ]]; then
|
||||||
echo "Downloading default format"
|
echo "Downloading default format"
|
||||||
youtube-dl.exe -o $name_format $opts $url
|
youtube-dl.exe -o "$name_format" $opts $url
|
||||||
else
|
else
|
||||||
youtube-dl.exe -f $format -o $name_format $opts $url
|
youtube-dl.exe -f $format -o "$name_format" $opts $url
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function dl_youtube_playlist {
|
function dl_youtube_playlist {
|
||||||
local format="$1"
|
local format="$1"
|
||||||
local url="$2"
|
local url="$2"
|
||||||
shift 2
|
local dir_name="$3"
|
||||||
|
if [[ $dir_name == "" ]]; then
|
||||||
|
echo "Please provide a name for the playlist directory"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
shift 3
|
||||||
local opts="$@"
|
local opts="$@"
|
||||||
opts+=" --all-subs --embed-subs"
|
opts+=" --all-subs --embed-subs"
|
||||||
local name_format="%(playlist_index)s - %(title)s-youtube-%(id)s.%(ext)s"
|
|
||||||
|
# @note If the filename contains symbols that are incompatible with
|
||||||
|
# Windows' directory names then add --restrict-filenames to the command.
|
||||||
|
if [[ $dir_name == "" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo "Creating directory '$dir_name'"
|
||||||
|
mkdir "$dir_name"
|
||||||
|
cd "$dir_name"
|
||||||
|
error=$?
|
||||||
|
if [[ ! $error -eq 0 ]]; then
|
||||||
|
echo "Error: failed to create directory. Aborting."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Downloading playlist"
|
||||||
|
local name_format="v%(playlist_index)s--%(upload_date)s-%(title)s-youtube-%(id)s.%(ext)s"
|
||||||
|
|
||||||
if [[ $format == "" ]]; then
|
if [[ $format == "" ]]; then
|
||||||
echo "Downloading default format"
|
echo "Downloading default format"
|
||||||
youtube-dl.exe -o $name_format $opts $url
|
youtube-dl.exe -o "$name_format" $opts $url
|
||||||
else
|
else
|
||||||
youtube-dl.exe -f $format -o $name_format $opts $url
|
youtube-dl.exe -f $format -o "$name_format" $opts $url
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
alias yt-download='dl_youtube_vid ""'
|
alias yt-download='dl_youtube_vid ""'
|
||||||
|
@ -187,27 +211,33 @@ alias yt-download-audio='youtube-dl.exe -f "140"'
|
||||||
function dl_twitch_vid {
|
function dl_twitch_vid {
|
||||||
local format="$1"
|
local format="$1"
|
||||||
local url="$2"
|
local url="$2"
|
||||||
|
shift 2
|
||||||
|
local opts="$@"
|
||||||
|
|
||||||
# @note If the filename contains symbols that are incompatible with
|
# @note If the filename contains symbols that are incompatible with
|
||||||
# Windows' directory names then add --restrict-filenames to the command.
|
# Windows' directory names then add --restrict-filenames to the command.
|
||||||
local dir=$(youtube-dl.exe --get-filename -o "%(upload_date)s - %(title)s" $url)
|
local dir_name=$(youtube-dl.exe --get-filename -o "%(upload_date)s - %(title)s" $url)
|
||||||
if [[ $dir == "" ]]; then
|
if [[ $dir_name == "" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
dir="${dir:0:4}-${dir:4:2}-${dir:6}"
|
|
||||||
echo "Creating directory '$dir'"
|
dir_name="${dir_name:0:4}-${dir_name:4:2}-${dir_name:6}"
|
||||||
mkdir "$dir"
|
echo "Creating directory '$dir_name'"
|
||||||
cd "$dir"
|
mkdir "$dir_name"
|
||||||
|
cd "$dir_name"
|
||||||
error=$?
|
error=$?
|
||||||
if [[ ! $error -eq 0 ]]; then
|
if [[ ! $error -eq 0 ]]; then
|
||||||
echo "Failed to download '$url'"
|
echo "Error: failed to create directory. Aborting."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local name_format="%(upload_date)s-%(title)s-twitch-%(id)s"
|
local name_format="%(upload_date)s-%(title)s-twitch-%(id)s"
|
||||||
local video_file=$(youtube-dl.exe --get-filename -o "$name_format.%(ext)s" $url)
|
local video_file=$(youtube-dl.exe --get-filename -o "$name_format.%(ext)s" $url)
|
||||||
youtube-dl.exe -f "$format" -o "$video_file" $url
|
video_file="${video_file:0:4}-${video_file:4:2}-${video_file:6}"
|
||||||
|
youtube-dl.exe -f "$format" -o "$video_file" $opts $url
|
||||||
|
|
||||||
error=$?
|
error=$?
|
||||||
if [[ $error -eq 0 ]]; then
|
if [[ $error -eq 0 ]]; then
|
||||||
mv "$video_file" "${video_file:0:4}-${video_file:4:2}-${video_file:6}"
|
|
||||||
# Download Twitch chat transcript
|
# Download Twitch chat transcript
|
||||||
local chat_file=$(youtube-dl.exe --get-filename -o "$name_format" $url)
|
local chat_file=$(youtube-dl.exe --get-filename -o "$name_format" $url)
|
||||||
rechat.exe -d $url "$chat_file.json"
|
rechat.exe -d $url "$chat_file.json"
|
||||||
|
@ -215,25 +245,26 @@ function dl_twitch_vid {
|
||||||
mv "$chat_file.txt" "${chat_file:0:4}-${chat_file:4:2}-${chat_file:6}.txt"
|
mv "$chat_file.txt" "${chat_file:0:4}-${chat_file:4:2}-${chat_file:6}.txt"
|
||||||
tt "$chat_file.json"
|
tt "$chat_file.json"
|
||||||
else
|
else
|
||||||
echo "Failed to download '$url'"
|
echo "Error: Failed to download '$url'"
|
||||||
fi
|
fi
|
||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
function dl_twitch_chat {
|
function dl_twitch_chat {
|
||||||
local url="$1"
|
local url="$1"
|
||||||
|
|
||||||
# @note If the filename contains symbols that are incompatible with
|
# @note If the filename contains symbols that are incompatible with
|
||||||
# Windows' directory names then add --restrict-filenames to the command.
|
# Windows' directory names then add --restrict-filenames to the command.
|
||||||
local dir=$(youtube-dl.exe --get-filename -o "%(upload_date)s - %(title)s" $url)
|
local dir_name=$(youtube-dl.exe --get-filename -o "%(upload_date)s - %(title)s" $url)
|
||||||
if [[ $dir == "" ]]; then
|
if [[ $dir_name == "" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
dir="${dir:0:4}-${dir:4:2}-${dir:6}"
|
dir_name="${dir_name:0:4}-${dir_name:4:2}-${dir_name:6}"
|
||||||
echo "Creating directory '$dir'"
|
echo "Creating directory '$dir_name'"
|
||||||
mkdir "$dir"
|
mkdir "$dir_name"
|
||||||
cd "$dir"
|
cd "$dir_name"
|
||||||
error=$?
|
error=$?
|
||||||
if [[ ! $error -eq 0 ]]; then
|
if [[ ! $error -eq 0 ]]; then
|
||||||
echo "Failed to download chat for '$url'"
|
echo "Error: failed to create directory. Aborting."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# Download Twitch chat transcript
|
# Download Twitch chat transcript
|
||||||
|
|
Loading…
Reference in New Issue
Block a user