zenytv zenyta

This commit is contained in:
qo-op 2020-04-15 04:37:01 +02:00
parent 868dacb0b4
commit 4c9cfea2e7
4 changed files with 160 additions and 2 deletions

View File

@ -15,6 +15,8 @@ isARM=$(cat $MY_PATH/.OS | grep YES)
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl || err=1
sudo chmod a+rx /usr/local/bin/youtube-dl
sudo apt install libid3-tools mpd mpc lame omxplayer -y || err=1
sudo apt-get install lame sox libsox-fmt-mp3 eyed3 python-chardet imagemagick curl -y #libav-tools || err=1
sudo apt-get install ca-certificates git-core binutils rsync alsa-utils bc libid3-tools espeak mpg321 fuse atomicparsley -y || err=1
## CONFIG MPD
sudo cp -f $MY_PATH/mpd.conf /etc/mpd.conf
@ -25,8 +27,7 @@ sudo service mpd restart || err=1
sudo apt-get install nginx php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-fpm sqlite -y || err=1
sudo apt-get install lame sox libsox-fmt-mp3 eyed3 python-chardet imagemagick curl -y #libav-tools || err=1
sudo apt-get install ca-certificates git-core binutils rsync alsa-utils bc libid3-tools espeak mpg321 fuse atomicparsley -y || err=1
wget http://launchpadlibrarian.net/339874908/libav-tools_3.3.4-2_all.deb -O $MY_PATH/libav-tools.deb
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-data_1.0+git20130326-3_all.deb -O $MY_PATH/libttspico-data.deb

78
zen/ssb_GET_zenyta.sh Executable file
View File

@ -0,0 +1,78 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.24
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
# #zenyta = youtube-dl video to ~/.zen/zenyta/cache/$timestamp
########################################################################
'
######## YOUTUBE-DL ##########
if [[ ! $(which youtube-dl) ]]; then
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl || err=1
sudo chmod a+rx /usr/local/bin/youtube-dl
sudo chown $USER /usr/local/bin/youtube-dl
fi
mkdir -p ~/.zen/zenyta/cache/
self=$(sbotc whoami | jq -r .id) || exit 1
g1self=$(echo $self | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
self_name=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"'", "content":{"type":"about", "about": "'"$self"'"}}}}]}' | jq -r .value?.content?.name | grep -v null | tail -n 1)
ipfsnodeid=$(ipfs id -f='<id>\n')
current_ts=$(date -u +%s%N | cut -b1-13)
[ -f ~/.zen/zenyta/last.ts ] && last_ts=$(cat ~/.zen/zenyta/last.ts) || last_ts=$((current_ts - 10*24*3600*1000 - 1)) # 10*24h ago
echo "
_
____ ___ _ __ _ _ | |_ __ __
|_ / / _ \ | '_ \ | | | | | __| \ \ / /
/ / | __/ | | | | | |_| | | |_ \ V /
/___| \___| |_| |_| \__, | \__| \_/
|___/
last timestamp: $last_ts
"
#messages=$(sbotc messagesByType '{"type":"post","gt":'$last_ts'}')
# SEARCH "#zenyta" CMD in message text
messages=$(sbotc backlinks.read '{"query":[{"$filter":{"dest":"#zenyta","value":{"content":{"type":"post"}},"timestamp":{"$gt":'"$last_ts"'}}}]}')
while read -r msg
do
# EXTRACT CMD PARAM
author=$(printf %s "$msg" | jq -r .value.author)
# echo $author
timestamp=$(printf %s "$msg" | jq -r .value.timestamp)
[[ $timestamp == $last_ts ]] && echo "ALREADY DONE" && continue
# echo $timestamp
msg_root=$(printf %s "$msg" | jq -r .value.content.root)
# echo $msg_root
msg_branch=$(printf %s "$msg" | jq -r .value.content.branch)
# echo $msg_branch
msg_text=$(printf %s "$msg" | jq -r .value.content.text)
# echo $msg_text
msg_ytdlurl=$(echo $msg_text | egrep -o 'https?://[^ ]+' | cut -d '\' -f 1 | tail -n 1)
# echo $msg_ytdlurl
# YOUTUBE-DL AUDIO
mkdir -p ~/.zen/zenyta/cache/$timestamp
/usr/local/bin/youtube-dl -x --audio-format mp3 \
--write-thumbnail --write-info-json --add-metadata --embed-thumbnail \
--no-mtime -o "~/.zen/zenyta/cache/$timestamp/%(title)s.%(id)s.%(ext)s" $msg_ytdlurl
# MEMORIZE timestamp
#echo "$timestamp" > ~/.zen/zenyta/last.ts
rm ~/.zen/zenyta/last.ts
done < <(printf '%s\n' "$messages")

78
zen/ssb_GET_zenytv.sh Executable file
View File

@ -0,0 +1,78 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.24
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
# #zenytv = youtube-dl video to ~/.zen/zenytv/cache/$timestamp
########################################################################
'
######## YOUTUBE-DL ##########
if [[ ! $(which youtube-dl) ]]; then
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl || err=1
sudo chmod a+rx /usr/local/bin/youtube-dl
sudo chown $USER /usr/local/bin/youtube-dl
fi
mkdir -p ~/.zen/zenytv/cache/
self=$(sbotc whoami | jq -r .id) || exit 1
g1self=$(echo $self | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
self_name=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"'", "content":{"type":"about", "about": "'"$self"'"}}}}]}' | jq -r .value?.content?.name | grep -v null | tail -n 1)
ipfsnodeid=$(ipfs id -f='<id>\n')
current_ts=$(date -u +%s%N | cut -b1-13)
[ -f ~/.zen/zenytv/last.ts ] && last_ts=$(cat ~/.zen/zenytv/last.ts) || last_ts=$((current_ts - 100*24*3600*1000 - 1)) # 10*24h ago
echo "
_
____ ___ _ __ _ _ | |_ __ __
|_ / / _ \ | '_ \ | | | | | __| \ \ / /
/ / | __/ | | | | | |_| | | |_ \ V /
/___| \___| |_| |_| \__, | \__| \_/
|___/
last timestamp: $last_ts
"
#messages=$(sbotc messagesByType '{"type":"post","gt":'$last_ts'}')
# SEARCH "#zenytv" CMD in message text
messages=$(sbotc backlinks.read '{"query":[{"$filter":{"dest":"#zenytv","value":{"content":{"type":"post"}},"timestamp":{"$gt":'"$last_ts"'}}}]}')
while read -r msg
do
# EXTRACT CMD PARAM
author=$(printf %s "$msg" | jq -r .value.author)
# echo $author
timestamp=$(printf %s "$msg" | jq -r .value.timestamp)
[[ $timestamp == $last_ts ]] && echo "ALREADY DONE" && continue
# echo $timestamp
msg_root=$(printf %s "$msg" | jq -r .value.content.root)
# echo $msg_root
msg_branch=$(printf %s "$msg" | jq -r .value.content.branch)
# echo $msg_branch
msg_text=$(printf %s "$msg" | jq -r .value.content.text)
# echo $msg_text
msg_ytdlurl=$(echo $msg_text | egrep -o 'https?://[^ ]+' | cut -d '\' -f 1 | tail -n 1)
# echo $msg_ytdlurl
# YOUTUBE-DL VIDEO
mkdir -p ~/.zen/zenytv/cache/$timestamp
/usr/local/bin/youtube-dl -f '[height=720]/best' \
--write-thumbnail --all-subs --write-info-json --write-annotations \
--no-mtime -o "~/.zen/zenytv/cache/$timestamp/%(title)s.%(id)s.%(ext)s" $msg_ytdlurl
# MEMORIZE timestamp
echo "$timestamp" > ~/.zen/zenytv/last.ts
done < <(printf '%s\n' "$messages")

View File

@ -47,6 +47,7 @@ ssbpub=$(sbotc whoami 2>/dev/null | jq -r .id)
########################################################################
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
[[ $g1pub == "" ]] && echo "ERROR g1pub empty !! Please check it..." && exit 1
########################################################################
# IPFS LOCAL REPOSITORY for Node Identity G1 + SSB