youtube-tui

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.concealed.world/youtube-tui
Log | Files | Refs | README | LICENSE

commit 93aa5edeaba4812d7058dd53afca3c86be0cf016
parent df7b533661b715758bb761db1ddf11a6889475aa
Author: Nixx <nixx@firemail.cc>
Date:   Tue, 20 Oct 2020 13:24:53 +0100

Help message tweak, removing unnecessary code, bug fixes

Diffstat:
Aexample-config-file/ytsearch | 8++++++++
Mytchannel | 15---------------
Mytformat | 16----------------
Mytsearch | 67+++++++++++++++++++++++++++++++++++++++++--------------------------
4 files changed, 49 insertions(+), 57 deletions(-)

diff --git a/example-config-file/ytsearch b/example-config-file/ytsearch @@ -0,0 +1,8 @@ +#https://yt.iswleuven.be/ +#https://invidious.13ad.de/ +#https://invidious.snopyta.org/ +#https://vid.mint.lgbt/ +s_website = https://invidious.snopyta.org/ +s_results = 10 +s_format = 22/18 +s_timeout = 20 diff --git a/ytchannel b/ytchannel @@ -2,21 +2,6 @@ # Last Revision: Sat 5 Sep 22:43:34 BST 2020 # A companion piece for ytsearch. Allows you to find the channel of videos, to use in RSS feed. # DEPENDS: youtube-dl, xclip, coreutils -# -# Copyright (C) <2020> <nixx@firemail.cc> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. message () { cat << EOF diff --git a/ytformat b/ytformat @@ -1,21 +1,5 @@ #!/bin/sh # Just to convert one format of link to another. -# DEPENDS: coreutils, xclip -# -# Copyright (C) <2020> <nixx@firemail.cc> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. end=$(echo "${1}" | rev | cut -d \/ -f 1 | rev) printf "https://www.youtube.com/${end}" | xclip -in -selection clipboard diff --git a/ytsearch b/ytsearch @@ -2,21 +2,6 @@ # Last Revision: Sat 5 Sep 22:43:58 BST 2020 # A messy bash TUI client for YT/Invidious. # DEPENDS: youtube-dl, mpv, ffmpeg, xclip, coreutils -# -# Copyright (C) <2020> <nixx@firemail.cc> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. message () { cat << EOF @@ -25,10 +10,13 @@ ytsearch TUI client for YouTube content. -Invidious is faster and 'friendlier' to scrape for search results, as -it can be done with curl, hence Invidious is the default. After -selecting videos, they are then downloaded/streamed through YouTube -directly. +Using Invidious to fetch results is faster, and 'friendlier' about +number of server requests. When a result is chosen, it is downloaded/ +streamed directly from YouTube. + +Some code pertaining to fetching results directly from YouTube +remains, but this is slow, and tends to get you banned - I would not +recommend. Usage: @@ -59,13 +47,40 @@ Config File: 's_format = 18' 's_timeout = 10' + MORE DETAILS: + + s_results: + ---------- + This is the number of individual results returned. Equivalent to + second parameter the in command line. + + s_website: + ---------- + This is the alternative Invidious mirror to use. Some will work + more reliably than others. Equivalent to the third parameter in + the command line. + + s_format: + --------- + Can only be set in config file. Determines video/audio quality: + see 'FORMAT SELECTION' on youtube-dl's man page for more + information on options. Default corresponds to 720p for video, + and best audio quality available for audio-only. + + s_timeout: + ---------- + Time taken to load a page of results, before giving up. Note that + timeout applies per page of results (20 results). 10 pages + (200 results) with a timeout of 10 seconds, could take up to 100 + seconds (assuming they all take the maximum time of 10 seconds). + Issues: Invidious instances can be highly unreliable. That's why switching instance via config file exists, often one mirror will be having issues and another will be fine. Increasing your search - timeout beyond the default may also help, if pages take a very - long time to load. + timeout beyond the default may also help, if queries tend to + timeout. Managing YouTube subscriptons: @@ -80,7 +95,7 @@ if xset -q >/dev/null 2>&1; then printf "${1}" | xclip -in -selection clipboard printf "\e[0;94m# Copied URL to clipboard.\e[0m\n" fi -printf "\e[0;94m# URL: ${1}\e[0m\n" +echo -e "\e[0;94m# URL: ${1}\e[0m" } hexformat () { @@ -181,8 +196,6 @@ if [[ $descend == 'd' || $descend == 'D' || $descend == 'descend' || $descend == fi elif [[ $playnum == 'e' || $playnum == 'E' || $playnum == 'exit' || $playnum == 'Exit' || $playnum == 'q' || $playnum == 'Q' ]]; then rm $tmp $playtmpout && exit 0 - elif [[ $playnum != 'n' && $playnum != 'N' && $playnum != 'next' && $playnum != 'Next' && $playnum != *','* ]]; then - printf "\e[1;91mERROR: Invalid number.\e[0m\n" && rm $tmp $playtmpout && exit 1 fi done pn=$(echo -n $playnum | tr -d "[:blank:]") @@ -223,7 +236,7 @@ else fi len=$(wc -l $tmp | awk '{print $1}') -[[ $len -eq 0 ]] && printf "\e[1;91m# ERROR: Could not fetch videos.\n1. Check the spelling of search instance ${website}.\n2. Increase search timeout - currently ${timeout} secs.\n3. Check: ${website}search?q=${searchhex}&page=${pagecount} - instance may be down.\n4. You may also be HTTP Error 429 blocked - have you been making a lot of requests?.\n5. Your search may just be too obscure.\e[0m\n" && rm $tmp && exit 1 +[[ $len -eq 0 ]] && echo -e "\e[1;91m# ERROR: Could not fetch videos.\n1. Check the spelling of search instance ${website}.\n2. Increase search timeout - currently ${timeout} secs.\n3. Check: ${website}search?q=${searchhex}&page=${pagecount} - instance may be down.\n4. You may also be HTTP Error 429 blocked - have you been making a lot of requests?.\n5. Your search may just be too obscure.\e[0m" && rm $tmp && exit 1 printf "\e[0;94m# Searched for results 1 to ${num}.\n\n" title @@ -237,7 +250,7 @@ while [ ${count} -le ${len} ]; do [[ $(echo $timeline | wc -L) -gt 7 ]] && printf '\t' || printf '\t\t' titleline="$(sed "${count}q;d" $tmp)" printf "\e[0;97m" - [[ $(echo $titleline | wc -L) -gt 50 ]] && printf "$(echo -n "${titleline}" | cut -c 1-50)" && echo -n ... || echo -n "${titleline}" + [[ $(echo $titleline | wc -L) -gt 50 ]] && echo -n "$(echo -n "${titleline}" | cut -c 1-50)" && echo -n ... || echo -n "${titleline}" printf '\n' ((count+=3)) done @@ -403,6 +416,8 @@ elif [[ $confirm == 'u' || $confirm == 'U' ]]; then echo "${website}${fullurl}" >> "${fileloc}" ((playmatchcount++)) done + else + printf "\e[1;91mERROR: Invalid action.\e[0m\n" && exit 0 fi else printf "\e[1;91mERROR: Invalid action.\e[0m\n" && exit 0