blob: da2d15418beec3f78a6053cebad2ad9b02e16073 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/usr/bin/env bash
export DEFAULT_PLAYLIST_END=15
export DEFAULT_INC_STEP=10
download() {
youtube-dl "$1" \
--download-archive ~/Nextcloud/txt/youtube-dl-seen.conf \
--prefer-free-formats \
--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
|