Packages: Add aria2 download utility
To speed up YouTube downloads, use the external downloader aria2c. Also implemented it in the aliases and scripts where youtube-dl is used.
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
continue
|
||||||
|
file-allocation=none
|
||||||
|
max-concurrent-downloads=3
|
||||||
|
max-connection-per-server=3
|
||||||
|
min-split-size=1M
|
||||||
|
split=3
|
||||||
+3
-3
@@ -173,9 +173,9 @@ alias u="setsid -f urxvt -cd $PWD"
|
|||||||
alias weather="curl -s 'https://wttr.in/dordrecht?q&n&p' | head -n -3"
|
alias weather="curl -s 'https://wttr.in/dordrecht?q&n&p' | head -n -3"
|
||||||
alias webmconvert="aliases webmconvert"
|
alias webmconvert="aliases webmconvert"
|
||||||
alias workbench="GDK_SCALE=1 GDK_DPI_SCALE=1 setsid -f -- mysql-workbench > /dev/null 2>&1"
|
alias workbench="GDK_SCALE=1 GDK_DPI_SCALE=1 setsid -f -- mysql-workbench > /dev/null 2>&1"
|
||||||
alias ytv="youtube-dl -f bestvideo\[height\<=\?1080\]+bestaudio/best"
|
alias ytv="youtube-dl -f bestvideo\[height\<=\?1080\]+bestaudio/best --external-downloader aria2c"
|
||||||
alias ytvb="youtube-dl -f bestvideo+bestaudio/best"
|
alias ytvb="youtube-dl -f bestvideo+bestaudio/best --external-downloader aria2c"
|
||||||
alias yta="youtube-dl -f bestaudio/best -x --audio-format mp3 --audio-quality 0" # --embed-thumbnail"
|
alias yta="youtube-dl -f bestaudio/best -x --audio-format mp3 --audio-quality 0 --external-downloader aria2c" # --embed-thumbnail"
|
||||||
alias ytat="aliases ytaudio_thumbnail"
|
alias ytat="aliases ytaudio_thumbnail"
|
||||||
|
|
||||||
mkcd() { mkdir -p -- "$1" && cd -P -- "$1" || exit; }
|
mkcd() { mkdir -p -- "$1" && cd -P -- "$1" || exit; }
|
||||||
|
|||||||
+2
-2
@@ -150,8 +150,8 @@ ytaudio_thumbnail() {
|
|||||||
# Get mp3 + thumbnail
|
# Get mp3 + thumbnail
|
||||||
echo "Downloading and converting \"$FILE_NAME\".."
|
echo "Downloading and converting \"$FILE_NAME\".."
|
||||||
youtube-dl -f bestaudio/best -x --audio-format mp3 --audio-quality 0 \
|
youtube-dl -f bestaudio/best -x --audio-format mp3 --audio-quality 0 \
|
||||||
--write-thumbnail --cookies "~/documents/youtube.com_cookies.txt" "$1" > /dev/null
|
--write-thumbnail --external-downloader aria2c \
|
||||||
# --write-thumbnail "$1" > /dev/null
|
--cookies "$HOME/documents/youtube.com-cookies.txt" "$1" > /dev/null
|
||||||
|
|
||||||
echo "Embedding thumbnail into mp3.."
|
echo "Embedding thumbnail into mp3.."
|
||||||
|
|
||||||
|
|||||||
+13
-9
@@ -38,16 +38,17 @@ EOF
|
|||||||
CLIP="$(xclip -se c -o)"
|
CLIP="$(xclip -se c -o)"
|
||||||
|
|
||||||
play() {
|
play() {
|
||||||
|
MPV="mpv --ytdl-raw-options=external-downloader=aria2c"
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
MPV="mpv $CLIP"
|
MPV="$MPV $CLIP"
|
||||||
# Cut off everything after space
|
# Cut off everything after space
|
||||||
LINK=" $(echo $CLIP | sed -nE 's/^(\S+).*/\1/p')"
|
LINK=" $(echo "$CLIP" | sed -nE 's/^(\S+).*/\1/p')"
|
||||||
else
|
else
|
||||||
MPV="mpv $*"
|
MPV="$MPV $*"
|
||||||
# Determain which argument holds the urls
|
# Determain which argument holds the urls
|
||||||
[ "$1" = "${1#-}" ] && DISPLAY="$1" || DISPLAY="$2"
|
[ "$1" = "${1#-}" ] && DISPLAY="$1" || DISPLAY="$2"
|
||||||
# Cut off everything after space
|
# Cut off everything after space
|
||||||
LINK=" $(echo $DISPLAY | sed -nE 's/^(\S+).*/\1/p')"
|
LINK=" $(echo "$DISPLAY" | sed -nE 's/^(\S+).*/\1/p')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
notify-send -t 2500 "Loading video: $LINK"
|
notify-send -t 2500 "Loading video: $LINK"
|
||||||
@@ -58,27 +59,30 @@ play() {
|
|||||||
shuffle() {
|
shuffle() {
|
||||||
# Skip first argument
|
# Skip first argument
|
||||||
shift 1
|
shift 1
|
||||||
mpv --no-video --shuffle --ytdl-format='bestaudio[ext=m4a]' "${@:-$CLIP}"
|
mpv --no-video --shuffle \
|
||||||
|
--ytdl-format='bestaudio[ext=m4a]' \
|
||||||
|
--ytdl-raw-options='external-downloader=aria2c' \
|
||||||
|
"${@:-$CLIP}"
|
||||||
}
|
}
|
||||||
|
|
||||||
queue() {
|
queue() {
|
||||||
OPTIONS="--no-terminal --force-window --input-file=$PIPE"
|
OPTIONS="--no-terminal --force-window --input-file=$PIPE --ytdl-raw-options=external-downloader=aria2c"
|
||||||
|
|
||||||
# Create mpv cache directory
|
# Create mpv cache directory
|
||||||
DIR="$(dirname "$PIPE")"
|
DIR="$(dirname "$PIPE")"
|
||||||
[ ! -d "$DIR" ] && mkdir -p "$DIR"
|
[ ! -d "$DIR" ] && mkdir -p "$DIR"
|
||||||
|
|
||||||
# Delete named pipe if no umpv is running
|
# Delete named pipe if no umpv is running
|
||||||
if ! pgrep -f 'mpv $OPTIONS' > /dev/null; then
|
if ! pgrep -f "mpv $OPTIONS" > /dev/null; then
|
||||||
rm -f "$PIPE"
|
rm -f "$PIPE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Skip first argument
|
# Skip first argument
|
||||||
shift 1
|
shift 1
|
||||||
# Set url to argument if provided, clipboard otherwise
|
# Set url to argument if provided, clipboard otherwise
|
||||||
URLS="${@:-$CLIP}"
|
URLS="${*:-$CLIP}"
|
||||||
|
|
||||||
if [ -p $PIPE ]; then
|
if [ -p "$PIPE" ]; then
|
||||||
notify-send -t 2500 "Added video to queue.."
|
notify-send -t 2500 "Added video to queue.."
|
||||||
# Add video to named pipe
|
# Add video to named pipe
|
||||||
echo "$URLS" \
|
echo "$URLS" \
|
||||||
|
|||||||
Reference in New Issue
Block a user