From f630c32b1b3bef687446803bfb1aaff589d8123f Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 16 Jul 2018 23:22:52 -0300 Subject: Add inc_download function to youtube.sh --- bash/youtube.sh | 26 ++++++++++++++++++++++---- encrypted/scripts/video-feed.sh | Bin 2473 -> 2485 bytes 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bash/youtube.sh b/bash/youtube.sh index 929d96d..da2d154 100644 --- a/bash/youtube.sh +++ b/bash/youtube.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash export DEFAULT_PLAYLIST_END=15 +export DEFAULT_INC_STEP=10 + download() { youtube-dl "$1" \ @@ -9,23 +11,39 @@ download() { --playlist-end $2 \ --output "~/Downloads/yt-dl/%(uploader)s/%(upload_date)s - %(title)s.%(ext)s" } - export -f download + download_user() { 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} } - export -f download_channel + download_playlist() { 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))" + + echo "$n_count_new" > "$file" + + "$fn" "$id" "$n_count" +} + +export -f inc_download diff --git a/encrypted/scripts/video-feed.sh b/encrypted/scripts/video-feed.sh index 3d0e416..c0cc940 100755 Binary files a/encrypted/scripts/video-feed.sh and b/encrypted/scripts/video-feed.sh differ -- cgit v1.2.3