-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlud
More file actions
executable file
·60 lines (53 loc) · 1.65 KB
/
lud
File metadata and controls
executable file
·60 lines (53 loc) · 1.65 KB
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
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
# LUD - The LARBS Universal Downloader
# A dmenu utility to download files from various sites & types
pgrep -x dmenu && exit
# Get Link
if [[ "$1" = "" ]]; then
link=$(xclip -o)
else
link="$1"
fi
[[ "$link" = "" ]] && exit 1
echo "Link: $link"
# Get Directory
if [[ $2 = "" ]]; then
# Add your own directories below
dirlist=$(sudo find ~/Videos ~/Pictures ~/Downloads -type d -maxdepth 8 2>/dev/null)
dir=$(echo "$dirlist" | dmenu -i -p "Download to:" -l 10)
[[ "$dir" = "" ]] && exit 1
if [[ ! -d "$dir" ]]; then
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$dir does not exist. Create it?")
[[ "$mkdiryn" = "Yes" ]] && (mkdir -p "$dir" || sudo -A mkdir -p "$dir")
fi
else
dir=$2
fi
[[ "$dir" = "" ]] && exit 1
echo "Directory: $dir" # OPT
cd "$dir"
# Writes to log file
echo -e "$link"'\t'"$dir"'\t''#'`date` >> ~/.lud_history
# Sort & Download
yttest=$(youtube-dl -e --abort-on-error "$link")
if [[ $? -eq 0 ]]; then
echo "Downloader: Youtube-dl"
type=$(echo -e "Video\nAudio" | dmenu -i -p "Download Type:")
if [[ $type == "Video" ]]; then
echo "Downloading Video"
sudo youtube-dl -ic --add-metadata "$link" --abort-on-error --external-downloader aria2c --external-downloader-args "-x 16 -s 16 -k 1M"
break
elif [[ $type == "Audio" ]]; then
echo "Downloading Audio"
sudo youtube-dl -xic --add-metadata "$link" --abort-on-error --external-downloader aria2c --external-downloader-args "-x 16 -s 16 -k 1M"
break
fi
else
echo "Downloader: Aria2c"
if command -v aria2c > /dev/null; then
sudo aria2c "$link" -x 16 -s 16 -k 1M -m 5
break
fi
fi
notify-send "'$link' to '$dir'" -t 2000
exit 1