Browse Source

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.
master
Riyyi 3 years ago
parent
commit
ae1458873e
  1. 6
      .config/aria2/aria2.conf
  2. 6
      .config/zsh/.zshrc
  3. 4
      .local/bin/aliases
  4. 22
      .local/bin/play
  5. 1
      packages

6
.config/aria2/aria2.conf

@ -0,0 +1,6 @@
continue
file-allocation=none
max-concurrent-downloads=3
max-connection-per-server=3
min-split-size=1M
split=3

6
.config/zsh/.zshrc

@ -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 webmconvert="aliases webmconvert"
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 ytvb="youtube-dl -f bestvideo+bestaudio/best"
alias yta="youtube-dl -f bestaudio/best -x --audio-format mp3 --audio-quality 0" # --embed-thumbnail"
alias ytv="youtube-dl -f bestvideo\[height\<=\?1080\]+bestaudio/best --external-downloader aria2c"
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 --external-downloader aria2c" # --embed-thumbnail"
alias ytat="aliases ytaudio_thumbnail"
mkcd() { mkdir -p -- "$1" && cd -P -- "$1" || exit; }

4
.local/bin/aliases

@ -150,8 +150,8 @@ ytaudio_thumbnail() {
# Get mp3 + thumbnail
echo "Downloading and converting \"$FILE_NAME\".."
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 "$1" > /dev/null
--write-thumbnail --external-downloader aria2c \
--cookies "$HOME/documents/youtube.com-cookies.txt" "$1" > /dev/null
echo "Embedding thumbnail into mp3.."

22
.local/bin/play

@ -38,16 +38,17 @@ EOF
CLIP="$(xclip -se c -o)"
play() {
MPV="mpv --ytdl-raw-options=external-downloader=aria2c"
if [ -z "$1" ]; then
MPV="mpv $CLIP"
MPV="$MPV $CLIP"
# Cut off everything after space
LINK=" $(echo $CLIP | sed -nE 's/^(\S+).*/\1/p')"
LINK=" $(echo "$CLIP" | sed -nE 's/^(\S+).*/\1/p')"
else
MPV="mpv $*"
MPV="$MPV $*"
# Determain which argument holds the urls
[ "$1" = "${1#-}" ] && DISPLAY="$1" || DISPLAY="$2"
# Cut off everything after space
LINK=" $(echo $DISPLAY | sed -nE 's/^(\S+).*/\1/p')"
LINK=" $(echo "$DISPLAY" | sed -nE 's/^(\S+).*/\1/p')"
fi
notify-send -t 2500 "Loading video: $LINK"
@ -58,27 +59,30 @@ play() {
shuffle() {
# Skip first argument
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() {
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
DIR="$(dirname "$PIPE")"
[ ! -d "$DIR" ] && mkdir -p "$DIR"
# 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"
fi
# Skip first argument
shift 1
# 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.."
# Add video to named pipe
echo "$URLS" \

1
packages

@ -4,6 +4,7 @@ alsa-utils
arandr
arc-gtk-theme
arc-icon-theme
aria2
aspell-en
aspell-nl
base

Loading…
Cancel
Save