ytcli

Des commandes pour utiliser youtube - retour accueil

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

ytgetvideos (611B)


      1 #! /bin/sh
      2 
      3 request() {
      4 	encoded=$(echo "$@" | sed 's/ /+/g;s/&//g' | tr -d '[]')
      5 	curl -Ls "https://www.youtube.com/results?search_query=$encoded"
      6 }
      7 request "$@" |
      8 	sed -n '21 p' |
      9 	grep -Eo 'ytInitialData.*' | sed 's/^ytInitialData =//' |
     10 	jq -r '.contents.twoColumnSearchResultsRenderer
     11 		   .primaryContents.sectionListRenderer
     12 		   .contents[].itemSectionRenderer.contents[].videoRenderer |
     13 				[.videoId,.title.runs[0].text,
     14 				 .longBylineText.runs[0].text,
     15 				 .shortViewCountText.simpleText,
     16 				 .publishedTimeText.simpleText,
     17 				 .lengthText.simpleText] |
     18 				@tsv' 2>/dev/null |
     19 	grep -Ev '^	*$'