From 9aa290b9667832c8ae41ed8bc36e57da7a74b9c2 Mon Sep 17 00:00:00 2001 From: LM-LCL Date: Thu, 31 Aug 2023 01:01:57 +0200 Subject: complete script revamp --- README.md | 59 +- ext/waldl | 162 --- ext/ytfzf | 3634 ------------------------------------------------ lcl-edit | 293 ++-- lcl-find | 20 +- lcl-kill | 16 +- lcl-playlist | 57 +- lcl-start | 9 - lcl-system | 38 +- lib/action/Clip | 23 - lib/action/Clipboard | 12 - lib/action/Download | 10 - lib/action/Open | 6 - lib/action/Play | 11 - lib/action/Record | 7 - lib/action/Torrent | 6 - lib/action/aDownload | 13 - lib/search/1337x | 67 - lib/search/Odysee | 10 - lib/search/PeerTube | 10 - lib/search/Wallhaven | 8 - lib/search/YouTube | 19 - rmt-action | 125 +- rmt-history | 15 - rmt-search | 55 +- util/dpath | 5 - util/hpath | 11 - util/menu/deasy | 12 - util/menu/deasy-core | 10 - util/notify | 6 - util/verify/cbd-core | 25 - util/verify/cbd-https | 8 - util/verify/cbd-magnet | 8 - 33 files changed, 217 insertions(+), 4553 deletions(-) delete mode 100755 ext/waldl delete mode 100755 ext/ytfzf delete mode 100755 lcl-start delete mode 100755 lib/action/Clip delete mode 100755 lib/action/Clipboard delete mode 100755 lib/action/Download delete mode 100755 lib/action/Open delete mode 100755 lib/action/Play delete mode 100755 lib/action/Record delete mode 100755 lib/action/Torrent delete mode 100755 lib/action/aDownload delete mode 100755 lib/search/1337x delete mode 100755 lib/search/Odysee delete mode 100755 lib/search/PeerTube delete mode 100755 lib/search/Wallhaven delete mode 100755 lib/search/YouTube delete mode 100755 rmt-history delete mode 100755 util/dpath delete mode 100755 util/hpath delete mode 100755 util/menu/deasy delete mode 100755 util/menu/deasy-core delete mode 100755 util/notify delete mode 100755 util/verify/cbd-core delete mode 100755 util/verify/cbd-https delete mode 100755 util/verify/cbd-magnet diff --git a/README.md b/README.md index 7aded0e..9890ed7 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,12 @@ Build your own digital library. ## Supported Features -- Search videos on **YouTube**, **Odysee** & **PeerTube**. -- Search BitTorrent supported files on **1337x**. -- Search & preview wallpapers on **Wallhaven**. +- Search videos on **YouTube** ---- - -After acquiring a link from the clipboard, by search or the search history you may choose what to do with this link: +After acquiring the link from the clipboard you may choose what to do with this link: - You may choose to **play** or **record** the video/stream using **mpv**. - You may choose to **clip** the remote video with **FFmpeg**. - You may choose to **download** the video with **audio** or **video** format using **yt-dlp**. -- You may choose to **torrent** the file using **qBittorrent**. --- @@ -25,40 +20,29 @@ Once you've downloaded the media files to your offline digital library you can: - **Strip**, **convert format**, **resize**, **trim transparency** & **apply border-radius** using **ImageMagick**. Workflow specific automation of tasks: -- Easily access a start menu for installed programs. - Easily search & end processes running on your computer. - Easily perform system actions, like restarting your computer. ## Dependencies - dmenu -- sxiv +- xclip - mpv +- ytfzf - ffmpeg - imagemagick - exiftool -- xclip -- jq -- qbittorrent #### Recommendation -To create comfortable mpv settings. The command below creates a mpv.conf file that limits the quality of streamed videos to 1080p & always creates a 1440x810 mpv window. This might be good enough, but for the specific settings I use, it's available [here](https://git.exaltedelite.club/mpv-settings). - - mkdir -p ~/.config/mpv && echo -e "ytdl-format='bestvideo[height<=1080]+bestaudio/best[height<=1080]'\ngeometry='1440x810'" > ~/.config/mpv/mpv.conf - -All the scripts do require relative file paths to work, except for lcl-start & lcl-kill. Below is an example of how a keybind command might look like. +To create comfortable mpv settings. The command below creates a mpv.conf file that limits the quality of streamed videos to 1080p & always creates a 1280x720 mpv window. This might be good enough, but can be configured to your liking in more detail. - sh -c 'cd ~/Desktop/EZown && ./rmt-search' + mkdir -p ~/.config/mpv && echo -e "ytdl-format='bestvideo[height<=1080]+bestaudio/best[height<=1080]'\ngeometry='1280x720'" > ~/.config/mpv/mpv.conf ## Usage - ./rmt-action [Clipboard Link] - **Param Nº1:** Skip dmenu Nº1 (./rmt-action 'Play') - **Param Nº2:** Skip clipboard link (./rmt-action 'Play' 'https://invidious.flokinet.to/watch?v=AhZqOYu5BOw') - ./rmt-search [Acquire Link & Forward To ./rmt-action] - - **Param Nº1:** Skip dmenu Nº1 (./rmt-search '1337x') - - **Param Nº2:** Skip dmenu Nº2 (./rmt-search '1337x' 'Collateral 2004') - - **Param Nº3:** Skip dmenu Nº4 (./rmt-search '1337x' 'Collateral 2004' 'Torrent') -- ./rmt-history [Link History & Forward To ./rmt-action] - - **Param Nº1:** Skip dmenu Nº1 (./rmt-history 'Record') + - **Param Nº1:** Skip dmenu Nº1 (./rmt-search 'Collateral 2004') --- @@ -69,32 +53,12 @@ All the scripts do require relative file paths to work, except for lcl-start & l --- -- ./lcl-start [Start Menu] - ./lcl-kill [Kill Local Process] - ./lcl-system [Perform System Action] - - **Param Nº1:** Skip dmenu Nº1 (./lcl-system 'Shutdown') - -## Usage Flow -By default, rmt-action uses links stored in the clipboard when used. But rmt-search & rmt-history can be used to discover links. When using rmt-search without a correctly chosen item from the dmenu list, will automatically search YouTube. Therefore you can skip param Nº1 if you're searching YouTube. The command ./rmt-search 'YouTube' 'BugsWriter' 'Play' could be shortened to ./rmt-search 'BugsWriter' 'Play'. But in case you would search Odysee for example, you would explicitly have to specify the platform (./rmt-search 'Odysee' 'BugsWriter' 'Play'). - -- You could for example bind Shift+Ctrl+P to play copied video links automatically with the ./rmt-action 'Play' command. -- You could for example bind Shift+Ctrl+B to search local files with the ./lcl-find command. -- You could for example bind Shift+Ctrl+O to perform an action with the ./rmt-action command. -- You could for example bind Super+R to search PeerTube videos with the ./rmt-search 'PeerTube' command. - -*This should help you get started & better understand the flow of the program.* #### RSS This script may act as another key to the puzzle of unfiltered interactions when used in combination with your RSS feed & its links. -#### Sane Defaults -- yt-dlp downloads in the .mp4 format & has a max quality of 1080p. -- Notifications are shown upon errors & not upon appropriate behaviour. -- Magnet links are opened with qBittorrent & may easily be modified in lib/action/Torrent. -- You may easily change the default downloads directory & Invidious instance, in util/dpath & lib/search/YouTube. -- You may modify the "find" command within the different scripts, it looks for files in ~/Desktop & ~/Downloads. -- ext/ytfzf & ext/waldl are slightly modified, search for "MODIFIED" in these files to see the changes. - ## Why You may never use these services, but a lot of good content is hosted on them created by good people, as discovery & revenue is easier than supplying independent content with your own digital infrastructure. But this dependence on a third-party service platform limits interactions with the hosted files. For security reasons- fearing abuse, legal reasons- fearing to support piracy on their platforms or business incentives that may not be inline with your values or use of the platform. One thing generally appreciated is the ability to store digital media offline, you might be going away on a trip without reliable internet or fear the site may not share your enthusiasm for the files being uploaded to their services. But this is made difficult & when available, is most always provided in a janky format that may not be very robust or censorship resistant. Streaming in its essence is interesting when you consider how it works, you stream files to your computer, but you're never supposed to download them to file, fearing you'll not need their services anymore, not use their platform as much or concerns around piracy of copyrighted material. To battle this, these services apply digital rights management or DRM making it as difficult as possible for you to regain this control of ownership of the files you stream to view. @@ -103,12 +67,3 @@ Without the proper knowledge of the great projects, run by good people that crea In the past more people may have served content by their own distribution, but centralization makes things easy, & less technical people are attracted to create & distribute their works on platforms that are seemingly becoming more & more restrictive over time, with their increased size, nurtured dependence of their services & larger impact on peoples daily lives. These services & a lot of the major technology platforms are changing with the times of the world, moving their services into an ever more controlled & predictable environment for them over their users. Building your own digital library is easier than ever before, the tools are there for you to use. It will minimize the dependence on these services, provide more flexibility how these files are used or shared, whether it is online or offline & regaining the control & subsequent power that was given up for the convenience these now very large services provide. - -## Credits -- https://github.com/Bugswriter/notflix -- https://github.com/pystardust/ytfzf -- https://github.com/pystardust/waldl -- https://odysee.com/@bugswriter:8/stream-any-movie-show-in-5-sec.-rip:9 -- https://odysee.com/@bugswriter:8/dmenu-is-killing-my-programs-and-it-s:8 -- https://odysee.com/@bugswriter:8/download-wallhaven-wallpapers-with-waldl:8 - diff --git a/ext/waldl b/ext/waldl deleted file mode 100755 index f1f9649..0000000 --- a/ext/waldl +++ /dev/null @@ -1,162 +0,0 @@ -#! /bin/bash - -source ./util/notify # MODIFIED - -# https://github.com/pystardust/waldl -# script to find and download wallpapers from wallhaven -version="0.0.1" - -# Usage: -# waldl -# if query left empty then sh_menu will be used (dmenu by default) -# after the thumbnails are cached, sxiv would open up with the thumbnails -# Select the wallpapers using `m` on the image. ( marking the image in sxiv ) -# press `q` to quit sxiv, the marked images would start downloading - -#################### -## User variables ## -#################### - -# the dir where wallpapers are stored -walldir="$2/Wallhaven" # MODIFIED -# the dir used to cache thumbnails -cachedir="$HOME/.cache/wallhaven" -# sxiv options -sxiv_otps=" -tfpob -z 200" # o is needed for selection # MODIFIED -# number of pages to show in search results -# each page contains 24 results -max_pages=4 -# sorting : date_added, relevance, random, views, favorites, toplist -sorting=relevance -# quality : large original small -quality=large -# atleast : least res -atleast=1920x1080 - -# allow the user to customize the defaults -[ -e "$HOME/.config/waldlrc" ] && . "$HOME/.config/waldlrc" - -# the menu command used when no query is provided -sh_menu () { - : | dmenu -p "search wallhaven:" - # ROFI: comment the previous line and uncomment the next line for rofi - # rofi -dmenu -l 0 -p "search wallpapers" -} - -########################## -## getting search query ## -########################## - -[ -n "$1" ] && query="$1" || query=$( sh_menu ) -[ -z "$query" ] && exit 1 -query=$(printf '%s' "$query" | tr ' ' '+' ) - -###################### -## start up commands # -###################### - -rm -rf "$cachedir" -mkdir -p "$walldir" "$cachedir" - -# progress display command -sh_info () { - printf "%s\n" "$1" >&2 - #notify-send "wallhaven" "$1" # MODIFIED - [ -n "$2" ] && exit "$2" -} - -# dependency checking -dep_ck () { - for pr; do - command -v $pr >/dev/null 2>&1 || sh_info "command $pr not found, install: $pr" 1 - done -} -dep_ck "sxiv" "curl" "jq" - - -# clean up command that would be called when the program exits -clean_up () { - printf "%s\n" "cleaning up..." >&2 - rm -rf "$datafile" "$cachedir" -} - -# data file to store the api information -datafile="/tmp/wald.$$" - -# clean up if killed -trap "exit" INT TERM -trap "clean_up" EXIT - -################## -## getting data ## -################## - -# request the search results for each page -get_results () { - for page_no in $(seq $max_pages) - do - { - json=$(curl -s -G "https://wallhaven.cc/api/v1/search" \ - -d "q=$1" \ - -d "page=$page_no" \ - -d "atleast=$atleast" \ - -d "sorting=$sorting" - ) - printf "%s\n" "$json" >> "$datafile" - } & - sleep 0.001 - done - wait -} - -# search wallpapers -sh_info "getting data..." -get_results "$query" - -# check if data file is empty, if so then exit -[ -s "$datafile" ] || sh_info "no images found" 1 - -############################ -## downloading thumbnails ## -############################ - -# get a list of thumnails from the data -thumbnails=$( jq -r '.data[]?|.thumbs.'"$quality" < "$datafile") - -[ -z "$thumbnails" ] && notify 'Empty Response' # MODIFIED - -# download the thumbnails -sh_info "caching thumbnails..." -for url in $thumbnails -do - printf "url = %s\n" "$url" - printf "output = %s\n" "$cachedir/${url##*/}" -done | curl -Z -K - -#sh_info "downloaded thumbnails..." - -########################### -## user selection (sxiv) ## -########################### - -# extract the id's out of the thumbnail name -image_ids="$(sxiv $sxiv_otps "$cachedir")" -[ -z "$image_ids" ] && exit - -######################### -## download wallpapers ## -######################### - -# download the selected wall papers -cd "$walldir" -sh_info "downloading wallpapers..." -for ids in $image_ids -do - ids="${ids##*/}" - ids="${ids%.*}" - url=$( jq -r '.data[]?|select( .id == "'$ids'" )|.path' < "$datafile" ) - printf "url = %s\n" "$url" - printf -- "-O\n" -done | curl -K - - -sh_info "wallpapers downloaded in:- '$walldir'" -sxiv -f $(ls -c) # MODIFIED diff --git a/ext/ytfzf b/ext/ytfzf deleted file mode 100755 index ae9fc30..0000000 --- a/ext/ytfzf +++ /dev/null @@ -1,3634 +0,0 @@ -#!/usr/bin/env sh - -source ./util/notify # MODIFIED - -# state variables -: "${__is_submenu:=0}" "${__is_fzf_preview:=0}" - -# versioning system: -# major.minor.bugs -YTFZF_VERSION="2.6.0" - -#ENVIRONMENT VARIABLES {{{ -: "${YTFZF_CONFIG_DIR:=${XDG_CONFIG_HOME:-$HOME/.config}/ytfzf}" -: "${YTFZF_CONFIG_FILE:=$YTFZF_CONFIG_DIR/conf.sh}" -: "${YTFZF_SUBSCRIPTIONS_FILE:=$YTFZF_CONFIG_DIR/subscriptions}" -: "${YTFZF_THUMBNAIL_VIEWERS_DIR:=$YTFZF_CONFIG_DIR/thumbnail-viewers}" -: "${YTFZF_SORT_NAMES_DIR:=$YTFZF_CONFIG_DIR/sort-names}" -: "${YTFZF_CUSTOM_INTERFACES_DIR:=$YTFZF_CONFIG_DIR/interfaces}" -: "${YTFZF_URL_HANDLERS_DIR:=$YTFZF_CONFIG_DIR/url-handlers}" -: "${YTFZF_CUSTOM_THUMBNAILS_DIR:=$YTFZF_CONFIG_DIR/thumbnails}" -: "${YTFZF_EXTENSIONS_DIR:=$YTFZF_CONFIG_DIR/extensions}" -: "${YTFZF_CUSTOM_SCRAPERS_DIR:=$YTFZF_CONFIG_DIR/scrapers}" - -: "${YTFZF_SYSTEM_ADDON_DIR:=/usr/local/share/ytfzf/addons}" - -: "${YTFZF_TEMP_DIR:="${TMPDIR:-/tmp}"/ytfzf-$(id -u)}" - -: "${YTFZF_LOGFILE:=}" - -[ "${YTFZF_LOGFILE}" ] && printf "[%s]\n==============\nSubmenu: %d\nFzf Preview: %d\n==============\n" "$(date)" "$__is_submenu" "$__is_fzf_preview" >>"${YTFZF_LOGFILE}" - -! [ -d "$YTFZF_TEMP_DIR" ] && mkdir -p "${YTFZF_TEMP_DIR}" - -export YTFZF_PID=$$ -#}}} - -############################ -# DEBUGGING # -############################ - -# There are only a couple tooling methods that I know of for debugging (other than printing stuff everywhere) -# set log_level to 3, and set YTFZF_LOGFILE=./some-file.log -# set -x may also be used. - -############################ -# CODE STYLE # -############################ - -################## -# VARIABLE NAMES # -################## - -# Starts with __ if it is a state variable thatt is allowed to be accessed globally. -# for example: __is_submenu is a state variable that keeps track of whether or not itt is a submenu -# another example: __scrape_count is the current scrape number - -# Environment variables should be all caps, do not use full caps for constansts - -# Const variable should start with c_ or const_ - -# Configuration variables should not start with any prefix, and should have a --long-opt equivelent with as close of a name as posisble to the variable -# example: the search_source variable has the long opt equivelent of --search-source - -# Private variables should start with an _ -# A major exception to this is the _search variable, which is global, and should not be used as a local variable. - -################## -# FUNCTION NAMES # -################## - -# Private functions should start with an _ - -# All other functions that should be accessed globally should not start with an _ -# A major exception to this is _get_request which is a global function - -# interface functions MUST start with interface_ in order to work properly -# scraper functions MUST start with scrape_ in order to work properly - -############################ -# ERRORS # -############################ - -# 0: success -# 1: general error -# 2: invalid -opt or command argument, invalid argument for opt, configuration error -# eg: ytfzf -c terminal (invalid scrape) -# 3: missing dependency -# 4: scraping error -# 5: empty search -# *: Likely a curl error - -############################ -# CODE # -############################ - -# colors {{{ -c_red="\033[1;31m" -c_green="\033[1;32m" -c_yellow="\033[1;33m" -c_blue="\033[1;34m" -c_magenta="\033[1;35m" -c_cyan="\033[1;36m" -c_reset="\033[0m" -c_bold="\033[1m" -#}}} - -: "${check_vars_exists:=${YTFZF_CHECK_VARS_EXISTS:-1}}" - -# __ytfzf__ extension {{{ - -print_help___ytfzf__() { - #the [2A will clear the \n---__ytfzf__--- garbage (in supported terminals) - printf "\033[2A%s" \ - "Usage: ytfzf [OPTIONS...] - The search-query can also be read from stdin - GENERAL OPTIONS: - -h Show this help text - - --version Get the current version - - --version-all Get the current version of ytfzf, - and required dependencies - - UTILITY OPTIONS: - --channel-link= Gets the uuid of a youtube channel from a link. - - PLAYING OPTIONS: - -d Download the selected video(s) - - -m Only play audio - - -f Select a video format before playing - - --format-selection= - Type can either be normal, or simple - --format-sort= The sort used in ytdl for -f. - - --video-pref= The ytdl video preference. - - --audio-pref= The ytdl audio preference. - - --ytdl-pref= The combined ytdl video and audio preference. - - -u The program to use for handling urls - (deafult: multimedia_player) - -L Show the link of selected video(s) - - -I Instead of playing the selected video(s), - get information about them. - Options can be separated with a comma, - eg: L,R - Options for info: - L: print the link of the video - VJ: print the json of the video - J: print the json of all videos - shown in the search - R: print the data - of the selected videos, - as appears in the menu - F: print the selected video format - --info-wait When -I or -L is used, - wait for user input before continuing - - --info-action= - The action to do when --info-wait is 1. - action can be one of - q: exit - Q: exit (bypass -l) - '': play video - - --detach Detach the url handler from the terminal - - --notify-playing Sends a notification when a video is selected. - - --url-handler-opts= - Pass the given opts to the url handler. - - --ytdl-opts= Pass the opts to ytdl when downloading - - --ytdl-path= The path to youtube-dl - - MENU OPTIONS: - -l Reopen the menu when the video stops playing - - -t Show thumbnails - - -T The program to use for displaying thumbnails. - see ytfzf(1) for a list of viewers. - - --async-thumbnails Download thumbnails asynchronously. - - --skip-thumb-download Skips the process of downloading thumbnails - - --thumbnail-quality= - Select quality of thumbnails, - can be: - maxres - maxresdefault - sddefault - high (default) - medium - default - start - middle - end - - -i The interface to use (default: text) - - -D Alias for -i ext - - -a Automatically select the first video - - -r Automatically select a random video - - -A Select all videos - - -S Automatically selects a specific video - based on a given sed address - - -n