ytcli

Des commandes pour utiliser youtube - retour accueil

git clone git://bebou.netlib.re/ytcli
Log | Files | Refs | README |

commit 6d675a5feb47a04e7911ea853b7977ba1b4bf7db
parent 9fdfffbfdc7e52d9b5df2bcefcf29c1ebfb03b3b
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Fri, 13 Sep 2024 15:44:33 +0200

Plus générique et gestion des > dans le titre

Diffstat:
Mtwitchgetstreams | 17+++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/twitchgetstreams b/twitchgetstreams @@ -1,8 +1,13 @@ #! /bin/sh -category="$1" -chromium --headless=new --timeout=3000 --dump-dom https://www.twitch.tv/directory/category/${category:?need a category}/?sort=VIEWER_COUNT | - grep -Eo '(data-test-selector="TitleAndChannel"[^>]+>|[0-9.K]+ viewers)' | - cut -d'"' -f6,10 | tr '"' '\n' | - paste - - - | - cut -d' ' -f3- +chromium --headless=new --timeout=2000 --dump-dom "https://www.twitch.tv$1" | + sed 's/">/\n/g' | + grep -E '(data-test-selector="TitleAndChannel"|viewers)' | + while read line;do + echo "$line" | grep -Eq "viewers" \ + && { echo "$line" | cut -d'<' -f1; } \ + || { echo "$line" | cut -d'"' -f8,12 | tr '"' ' ' | cut -d' ' -f3-; } + done | + paste - - | + awk -F'\t' -vOFS='\t' '{print $2,$1,$3}' +