diff options
Diffstat (limited to 'bash/youtube.sh')
-rw-r--r-- | bash/youtube.sh | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/bash/youtube.sh b/bash/youtube.sh index c732e26..275e0b8 100644 --- a/bash/youtube.sh +++ b/bash/youtube.sh @@ -2,44 +2,53 @@ export DEFAULT_PLAYLIST_END=15 export DEFAULT_INC_STEP=10 +export YT_TEMPLATE="$HOME/Downloads/yt-dl/%(uploader)s/%(upload_date)s %(title)s.%(ext)s" +# Always downloads video, doesn't look at the download-archive +yt_dl() { + youtube-dl "$1" -o "$YT_TEMPLATE" --write-description +} +export -f yt_dl download() { youtube-dl "$1" \ - --download-archive ~/Nextcloud/cache/youtube-dl-seen.conf \ - --prefer-free-formats \ - --playlist-end $2 \ - --output "~/Downloads/yt-dl/%(uploader)s/%(upload_date)s - %(title)s.%(ext)s" + --download-archive ~/ownCloud/cache/youtube-dl-seen.conf \ + --prefer-free-formats \ + --playlist-end "$2" \ + --write-description \ + --output "$YT_TEMPLATE" } export -f download download_user() { - download "https://www.youtube.com/user/$1" ${2-$DEFAULT_PLAYLIST_END} + download "https://www.youtube.com/user/$1" "${2-$DEFAULT_PLAYLIST_END}" } export -f download_user download_channel() { - download "https://www.youtube.com/channel/$1" ${2-$DEFAULT_PLAYLIST_END} + download "https://www.youtube.com/channel/$1" "${2-$DEFAULT_PLAYLIST_END}" } export -f download_channel download_playlist() { - download "https://www.youtube.com/playlist?list=$1" ${2-$DEFAULT_PLAYLIST_END} + download "https://www.youtube.com/playlist?list=$1" "${2-$DEFAULT_PLAYLIST_END}" } export -f download_playlist - inc_download() { local fn="$1" local id="$2" local step="${3-$DEFAULT_INC_STEP}" local file="$HOME/.yt-db/$id" - local n_count="$(cat $file 2> /dev/null || printf 10)" - local n_count_new="$(($n_count + $step))" + mkdir -p "$HOME/.yt-db" + cat "$file" 2> /dev/null + local n_count + n_count="$(cat "$file" 2> /dev/null || printf 10)" + local n_count_new="$((n_count + step))" echo "$n_count_new" > "$file" |