From 8ad46b2030ceec2e88a14bfe57e45083f57e54d7 Mon Sep 17 00:00:00 2001 From: fanta Date: Sun, 9 Oct 2022 10:32:41 +0200 Subject: [PATCH] =?UTF-8?q?el=20bot=20que=20a=C3=B1adir=20a=20cron?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recomendador.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 recomendador.sh diff --git a/recomendador.sh b/recomendador.sh new file mode 100755 index 0000000..f0419fb --- /dev/null +++ b/recomendador.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# apt install git toot wget +# toot login # Just the first time + +peertubeNode="fediverse.tv" +apiUrlLastVideos="https://$peertubeNode/api/v1/videos" +tmpFile="/tmp/.lastChannelsPeertube" + +function main { + getLastChannelsAccountsWithActivity + createTootMsg +} + +function getLastChannelsAccountsWithActivity { + wget -q "$apiUrlLastVideos" -O - | tr "\"" "\n" | grep -i "https://$peertubeNode/video-channels" | cut -d "/" -f 5 | sort -u > $tmpFile + readarray -t channel < $tmpFile && > $tmpFile + for a in "${channel[@]}"; do echo "@$a@$peertubeNode" >> $tmpFile; done + readarray -t channel < $tmpFile +} + +function createTootMsg { + tootMsg="Cuentas recomendadas para seguir ${channel[@]}. Cuentas con contenido multimedia que han tenido actividad en las Ășltimas 24horas #fediverse #fediverso #video #peertube #canales #channels" + toot post "$tootMsg" +} + +main