summaryrefslogtreecommitdiff
path: root/scripts/ytdl
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2023-05-17 00:09:51 +0200
committerMartial Simon <msimon_fr@hotmail.com>2023-05-17 00:09:51 +0200
commit5d3c0b24405381a41bd13a3135fa2969c2b47a48 (patch)
treec59a2521159b90daac9e139e5ebaeaf24dd3fa0f /scripts/ytdl
parent436159f3542d4e11c81ff927ab6b22f5ad2619e0 (diff)
parentca1fba1ef518b2f55bc168e9782b500dfec67c16 (diff)
Merge branch 'main' of https://github.com/Laitram31/config
Diffstat (limited to 'scripts/ytdl')
-rwxr-xr-xscripts/ytdl33
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/ytdl b/scripts/ytdl
new file mode 100755
index 0000000..e69cf26
--- /dev/null
+++ b/scripts/ytdl
@@ -0,0 +1,33 @@
+#!/bin/sh
+# wrapper for yt-dlp
+
+MUSICDIR="${XDG_MUSIC_DIR:-$HOME/Music}"
+VIDEODIR="${XDG_VIDEOS_DIR:-$HOME/Videos}"
+
+case $1 in
+v)
+ mkdir -p "$VIDEODIR"
+ notify-send "Video download started"
+ yt-dlp -f 'bv,ba' -o '%(title)s [%(id)s].%(ext)s'\
+ -P "$VIDEODIR" "$2" &&
+ notify-send "Video downloaded" ||
+ (notify-send "Error: No internet connection" && exit 1) ;;
+m)
+ mkdir -p "$MUSICDIR/download"
+ notify-send "Music download started"
+ yt-dlp -f 'ba' -x --embed-thumbnail --audio-format mp3\
+ -o '%(title)s [%(id)s].%(ext)s' -P "$MUSICDIR/download" "$2" &&
+ notify-send "Music downloaded" ||
+ (notify-send "Error: No internet connection" && exit 1) ;;
+p)
+ NAME=$(printf '' | dmenu -p 'Name ')
+ mkdir -p "$MUSICDIR/$NAME"
+ notify-send "Playlist download started"
+ yt-dlp -f 'ba' -x --embed-thumbnail --audio-format mp3\
+ -o '%(playlist_index)s - %(title)s [%(id)s].%(ext)s'\
+ -P "$MUSICDIR/$NAME" "$2" &&
+ notify-send "Playlist downloaded" ||
+ (notify-send "Error: No internet connection" && exit 1) ;;
+*)
+ exit 1 ;;
+esac \ No newline at end of file