ytcli

Des commandes pour utiliser youtube - retour accueil

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

commit 1670ab0f0f817b0a677aae1f4be6aee31bb25ffd
parent a9313f204c001d06eeb04e3c066ebc771060ed40
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Sun, 31 Dec 2023 17:11:55 +0100

Ajout de makefile et script

Diffstat:
Mmakefile | 2++
Aytgetvideos | 14++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/makefile b/makefile @@ -1,5 +1,7 @@ PREFIX = /usr/local +all: + install: mkdir -p "${DESTDIR}${PREFIX}/bin" cp yt* "${DESTDIR}${PREFIX}/bin" diff --git a/ytgetvideos b/ytgetvideos @@ -0,0 +1,14 @@ +#! /bin/sh + +request() { + encoded=$(echo "$@" | sed 's/ /+/g') + curl -Ls "https://www.youtube.com/results?search_query=$encoded" +} +request "$@" | + sed -n '21 p' | + grep -Eo 'ytInitialData.*' | sed 's/^ytInitialData =//' | + jq | + grep -E '^ {22}"videoId|^ {28}"label.+ de .+( |Aucune).+(il y a)? .+"' | + paste - - | + sed -E 's/.+videoId": "([^"]+)".+label": "(.+) de (.+) (.+).vues?( Diffusé)?( il y a [0-9]+ (jours?|semaines?|ans?|mois))? ([0-9].+)"/\1 \2 \3 \4 \6 \8/' 2> /dev/null +