Add scripts to download youtube videos

This commit is contained in:
Thomas Dehaeze 2020-04-10 16:38:44 +02:00
parent dd1bb0facc
commit 8b91e7a9c4

View File

@ -268,10 +268,10 @@ Open Youtube video using =mpv=
config.bind(',M', 'hint links spawn --detach mpv --force-window yes {hint-url}') config.bind(',M', 'hint links spawn --detach mpv --force-window yes {hint-url}')
#+END_SRC #+END_SRC
Cast Youtube to Chromecast Download Youtube video / entire playlist
#+begin_src python #+begin_src python
config.bind(',c', 'spawn --userscript ~/.config/qutebrowser/userscripts/cast.sh {url}') config.bind(',v', 'spawn --userscript ~/.config/qutebrowser/userscripts/yt-download.sh {url}')
config.bind(',C', 'hint links spawn --userscript ~/.config/qutebrowser/userscripts/cast.sh {hint-url}') config.bind(',V', 'hint links spawn --userscript ~/.config/qutebrowser/userscripts/yt-download.sh {hint-url}')
#+END_SRC #+END_SRC
Add page to Bookmarks using =buku= Add page to Bookmarks using =buku=
@ -293,7 +293,7 @@ Org Capture
Download a torrent Download a torrent
#+begin_src python #+begin_src python
config.bind(',t', 'hint links spawn --userscript torrent-add {hint-url}') config.bind(',t', 'hint links spawn torrent-add {hint-url}')
#+end_src #+end_src
Annotate with Hypothesis Annotate with Hypothesis
@ -307,14 +307,14 @@ See Amazon price history using CamelCamelCamel
#+end_src #+end_src
* Userscripts * Userscripts
** Create a new password
:PROPERTIES: :PROPERTIES:
:header-args: :tangle ~/.config/qutebrowser/userscripts/add-passowrd.sh :header-args:bash: :shebang "#!/usr/bin/env bash"
:header-args+: :comments both :mkdirp yes :header-args:bash+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END: :END:
#+begin_src bash ** Create a new password
#+begin_src bash :tangle ~/.config/qutebrowser/userscripts/add-passowrd.sh
url=$(echo "$QUTE_URL" | awk -F[/:] '{print $4}' | rofi -p "URL" -dmenu -lines 1) url=$(echo "$QUTE_URL" | awk -F[/:] '{print $4}' | rofi -p "URL" -dmenu -lines 1)
username=$(echo -e "dehaeze.thomas@gmail.com\nthomas.dehaeze@esrf.fr\ntdehaeze" | rofi -p "Username" -dmenu -lines 5) username=$(echo -e "dehaeze.thomas@gmail.com\nthomas.dehaeze@esrf.fr\ntdehaeze" | rofi -p "Username" -dmenu -lines 5)
password=$(rofi -p "Password" -dmenu -password -lines 1) password=$(rofi -p "Password" -dmenu -password -lines 1)
@ -329,23 +329,31 @@ See Amazon price history using CamelCamelCamel
fi fi
#+end_src #+end_src
** Cast Youtube to Chromecast ** Download Youtube Video
:PROPERTIES:
:header-args: :tangle ~/.config/qutebrowser/userscripts/cast.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash #+begin_src bash :tangle ~/.config/qutebrowser/userscripts/yt-download.sh
youtube-dl -o - $1 | castnow --quiet - cd ~/Documents/to-watch/;
if [[ "$1" == *"list"* ]]; then
choice=$(echo -e "Video\nPlaylist" | rofi -dmenu -only-match -i)
fi
if [ -n "$choice" ] && [ "$choice" = "Playlist" ]; then
dunstify --replace=19243 "Youtube " "Downloading Playlist...";
youtube-dl -i -f 'bestvideo[height<=720]+bestaudio/best[height<=720]' "$1" -o "%(playlist_title)s/%(playlist_index)s-%(title)s.%(ext)s" && \
dunstify --replace=19243 "Youtube " "Downloaded" || \
dunstify --replace=19243 --urgency=critical "Youtube " "Failed to download"
else
dunstify --replace=19243 "Youtube " "Downloading Video...";
youtube-dl --no-playlist -f 'bestvideo[height<=720]+bestaudio/best[height<=720]' "$1" && \
dunstify --replace=19243 "Youtube " "Downloaded" || \
dunstify --replace=19243 --urgency=critical "Youtube " "Failed to download"
fi
#+end_src #+end_src
** Password_fill_rc ** Password_fill_rc
:PROPERTIES:
:header-args+: :tangle ~/.config/qutebrowser/password_fill_rc
:END:
#+begin_src bash #+begin_src bash :tangle ~/.config/qutebrowser/password_fill_rc
# Show all password fields in the menu # Show all password fields in the menu
query_entries() { query_entries() {
# safe queried url for choose_entry # safe queried url for choose_entry
@ -368,13 +376,8 @@ See Amazon price history using CamelCamelCamel
#+end_src #+end_src
** Org-Capture ** Org-Capture
:PROPERTIES:
:header-args: :tangle ~/.config/qutebrowser/userscripts/org-capture.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash #+begin_src bash :tangle ~/.config/qutebrowser/userscripts/org-capture.sh
readonly CAPTURE_SCRIPT=~/.config/qutebrowser/userscripts/org-protocol-capture-html.sh readonly CAPTURE_SCRIPT=~/.config/qutebrowser/userscripts/org-protocol-capture-html.sh
if [[ "$QUTE_MODE" = "hints" ]]; then if [[ "$QUTE_MODE" = "hints" ]]; then
@ -519,13 +522,8 @@ Send to Emacs
#+end_src #+end_src
** Add Url to Buku using Rofi ** Add Url to Buku using Rofi
:PROPERTIES:
:header-args: :tangle ~/.config/qutebrowser/userscripts/buku-rofi.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash #+begin_src bash :tangle ~/.config/qutebrowser/userscripts/buku-rofi.sh
title=$(echo "$QUTE_TITLE" | rofi -p "Title" -dmenu -lines 1) title=$(echo "$QUTE_TITLE" | rofi -p "Title" -dmenu -lines 1)
tags=$(buku -t --nc --np | sed -e 's/\s*[[:digit:]]*\.\s*\(.*\)\s*([[:digit:]]*)\s*/\1/' -e '/^\s*$/d' | sort | uniq | rofi -p "Tags" -dmenu) tags=$(buku -t --nc --np | sed -e 's/\s*[[:digit:]]*\.\s*\(.*\)\s*([[:digit:]]*)\s*/\1/' -e '/^\s*$/d' | sort | uniq | rofi -p "Tags" -dmenu)
@ -533,12 +531,7 @@ Send to Emacs
#+end_src #+end_src
** Add Url to Buku without asking for information ** Add Url to Buku without asking for information
:PROPERTIES:
:header-args: :tangle ~/.config/qutebrowser/userscripts/buku-add.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash #+begin_src bash :tangle ~/.config/qutebrowser/userscripts/buku-add.sh
buku --add $QUTE_URL --title "$QUTE_TITLE" && dunstify "Buku" "📑 Bookmark Added" buku --add $QUTE_URL --title "$QUTE_TITLE" && dunstify "Buku" "📑 Bookmark Added"
#+end_src #+end_src