2022-09-04 12:20:55 +02:00
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 1.0
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
# SCRIPT INTERACTIF POUR AJOUTER UN FICHIER à ASTROPORT/TW
#
# 1. CAT: film, serie
# 2. TMDB: ID de la fiche sur https://www.themoviedb.org/
# 3. TITLE: Titre de la vidéo
# 4. YEAR: Année de la vidéo
# 5. RES: Résolution 1080p, 4K, SD, 720, HD
# 6. SAISON: Pour les séries, c'est le numéro de saison.
# Pour un film, le champ SAISON est utilisé pour renseigner la Saga
# 7. GENRES: Action, Aventure, Fantastique, Animation, etc (choix multiple).
# 8. GROUPES: Stocker la clef IPNS du MEDIAKEY.
#
# https://github.com/Kodi-vStream/venom-xbmc-addons/wiki/Voir-et-partager-sa-biblioth%C3%A8que-priv%C3%A9e#d%C3%A9clarer-des-films
########################################################################
MY_PATH = " `dirname \" $0 \"` " # relative
MY_PATH = " `( cd \" $MY_PATH \" && pwd )` " # absolutized and normalized
2022-12-27 19:35:43 +01:00
2023-12-30 18:38:02 +01:00
#~ LOWMODE=$(sudo systemctl status ipfs | grep disabled) ## IPFS DISABLED - START ONLY FOR SYNC -
#~ # echo "$USER ALL=(ALL) NOPASSWD:/bin/systemctl" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/systemctl')
#~ if [[ $LOWMODE != "" ]]; then
#~ espeak "Low Mode"
#~ sudo systemctl start ipfs
#~ fi
2023-04-14 17:42:58 +02:00
2023-12-30 18:38:02 +01:00
#~ ########################################################################
2024-02-10 20:45:17 +01:00
# REMOVE GtkDialog errors for zenity
shopt -s expand_aliases
alias zenity = 'zenity 2> >(grep -v GtkDialog >&2)'
2024-03-10 11:40:45 +01:00
alias espeak = 'espeak >/dev/null 2>&1'
2023-07-31 17:08:55 +02:00
## CHECK IF IPFS DAEMON IS STARTS WELL
floop = 0
while [ [ ! $( netstat -tan | grep 5001 | grep LISTEN) ] ] ; do
sleep 1
2024-01-19 15:48:21 +01:00
( ( floop++) ) && [ $floop -gt 5 ] \
2024-01-02 12:22:32 +01:00
&& echo "ERROR. IPFS daemon not running on port 5001" \
2024-01-04 18:57:31 +01:00
&& espeak 'ERROR. I P F S daemon not running' \
2023-12-31 15:06:34 +01:00
&& exit 1
2023-07-31 17:08:55 +02:00
done
. " ${ MY_PATH } /tools/my.sh "
2022-12-27 19:35:43 +01:00
[ [ $IPFSNODEID = = "" ] ] && echo "IPFSNODEID manquant" && espeak "IPFS NODE ID Missing" && exit 1
2023-04-14 17:42:58 +02:00
2022-12-03 16:54:40 +01:00
start = ` date +%s`
2024-02-10 20:45:17 +01:00
2022-09-04 12:20:55 +02:00
########################################################################
2023-12-31 15:06:34 +01:00
[ [ $( which ipfs) = = "" ] ] && echo "ERREUR! Installez ipfs" && exit 1
2022-09-04 12:20:55 +02:00
[ [ $( which zenity) = = "" ] ] && echo "ERREUR! Installez zenity" && echo "sudo apt install zenity" && exit 1
[ [ $( which ffmpeg) = = "" ] ] && echo "ERREUR! Installez ffmpeg" && echo "sudo apt install ffmpeg" && exit 1
[ [ $( which xdpyinfo) = = "" ] ] && echo "ERREUR! Installez x11-utils" && echo "sudo apt install x11-utils" && exit 1
2023-12-31 15:06:34 +01:00
[ [ $( which tiddlywiki) = = "" ] ] && echo "ERREUR! Installez tiddlywiki" && echo "sudo npm install -g tiddlywiki" && exit 1
2022-09-04 12:20:55 +02:00
2023-12-31 15:06:34 +01:00
mkdir -p ~/.zen/tmp/
2022-12-30 17:07:08 +01:00
exec 2>& 1 >> ~/.zen/tmp/ajouter_media.log
2022-12-23 23:10:31 +01:00
2022-12-11 04:13:47 +01:00
URL = " $1 "
PLAYER = " $2 "
CHOICE = " $3 "
2023-04-24 15:51:48 +02:00
echo " >>> RUNNING 'ajouter_media.sh' URL= $URL PLAYER= $PLAYER CHOICE= $CHOICE "
2022-12-11 04:13:47 +01:00
2023-04-24 15:51:48 +02:00
# Check who is PLAYER ?
if [ [ ${ PLAYER } = = "" ] ] ; then
2023-01-05 16:28:10 +01:00
2023-04-24 15:51:48 +02:00
players = ( $( ls ~/.zen/game/players | grep "@" 2>/dev/null) )
2023-01-05 16:28:10 +01:00
2023-04-24 15:51:48 +02:00
if [ [ ${# players [@] } -ge 1 ] ] ; then
2024-03-10 11:40:45 +01:00
espeak "SELECT YOUR PLAYER"
2023-04-24 15:51:48 +02:00
OUTPUT = $( zenity --list --width 480 --height 200 --title= "Choix du PLAYER" --column= "Astronaute" " ${ players [@] } " )
[ [ ${ OUTPUT } = = "" ] ] && espeak "No player selected. EXIT" && exit 1
else
OUTPUT = " ${ players } "
fi
2023-01-05 16:28:10 +01:00
2023-04-24 15:51:48 +02:00
PLAYER = ${ OUTPUT }
else
OUTPUT = ${ PLAYER }
fi
2024-03-31 14:39:50 +02:00
####### NO CURRENT ? PLAYER = .current
[ [ ! -d $( readlink ~/.zen/game/players/.current) ] ] \
&& rm -f ~/.zen/game/players/.current \
&& ln -s ~/.zen/game/players/${ PLAYER } ~/.zen/game/players/.current
echo "ADMIN : " $( cat ~/.zen/game/players/.current/.player)
2023-04-24 15:51:48 +02:00
[ [ ${ OUTPUT } != "" ] ] \
2024-03-31 14:39:50 +02:00
&& espeak " ${ OUTPUT } CONNECTED " \
2023-01-16 23:42:33 +01:00
&& . " ${ MY_PATH } /tools/my.sh "
2022-12-12 22:17:55 +01:00
2023-04-24 15:51:48 +02:00
## NO PLAYER AT ALL
[ [ ${ OUTPUT } = = "" ] ] \
2023-01-05 16:28:10 +01:00
&& espeak "Astronaut. Please register." \
2023-01-01 21:34:02 +01:00
&& xdg-open "http://astroport.localhost:1234" \
2023-01-05 22:49:10 +01:00
&& exit 1 \
|| PSEUDO = $( myPlayerUser)
2022-11-29 16:39:58 +01:00
2022-12-02 15:14:19 +01:00
espeak " Hello $PSEUDO "
2024-03-31 14:39:50 +02:00
G1PUB = $( cat ~/.zen/game/players/${ PLAYER } /.g1pub)
2022-12-02 15:14:19 +01:00
[ [ $G1PUB = = "" ] ] && espeak "ERROR NO G 1 PUBLIC KEY FOUND - EXIT" && exit 1
2022-10-31 17:22:40 +01:00
2023-12-31 15:06:34 +01:00
PLAYERNS = $( myPlayerNs) || { echo "noplayerns" && exit 1; }
2022-09-04 12:20:55 +02:00
2022-12-29 14:51:05 +01:00
ASTRONAUTENS = $( myAstroKey)
2022-10-31 17:22:40 +01:00
[ [ $ASTRONAUTENS = = "" ] ] && echo "ASTRONAUTE manquant" && espeak "Astronaut Key Missing" && exit 1
2023-03-07 14:58:12 +01:00
BZER = $( xdg-settings get default-web-browser | cut -d '.' -f 1 | cut -d '-' -f 1) ## GET cookies-from-browser
[ [ $BZER ] ] && BROWSER = " --cookies-from-browser $BZER " || BROWSER = ""
[ [ ! $isLAN ] ] && BROWSER = ""
2022-09-04 12:20:55 +02:00
2023-01-05 16:28:10 +01:00
###
2022-09-04 12:20:55 +02:00
if [ $URL ] ; then
2023-01-05 16:28:10 +01:00
2022-09-04 12:20:55 +02:00
echo " URL: $URL "
REVSOURCE = " $( echo " $URL " | awk -F/ '{print $3}' | rev) _ "
2023-04-27 00:39:27 +02:00
[ [ ${ CHOICE } = = "" ] ] && IMPORT = $( zenity --entry --width 640 --title= " $URL => Astroport " --text= " ${ PLAYER } Type de media à importer ? " --entry-text= "Video" PDF MP3) || IMPORT = " $CHOICE "
2023-04-24 15:51:48 +02:00
[ [ $IMPORT = = "" ] ] && espeak "No choice made. Exit" && exit 1
2022-09-04 12:20:55 +02:00
[ [ $IMPORT = = "Video" ] ] && IMPORT = "Youtube"
CHOICE = " $IMPORT "
2023-01-05 16:28:10 +01:00
2022-09-04 12:20:55 +02:00
fi
2023-01-05 16:28:10 +01:00
###
2023-03-13 18:50:20 +01:00
2023-03-20 13:26:16 +01:00
COINS = $( $MY_PATH /tools/COINScheck.sh $G1PUB | tail -n 1)
2023-04-24 15:51:48 +02:00
echo " $PLAYER wallet = $COINS G1 "
2022-09-04 12:20:55 +02:00
2023-07-10 11:51:36 +02:00
2023-04-24 15:51:48 +02:00
2022-09-04 12:20:55 +02:00
########################################################################
2023-04-24 15:51:48 +02:00
## EXCEPTION COPIE PRIVE
2022-09-04 12:20:55 +02:00
# https://www.legifrance.gouv.fr/codes/article_lc/LEGIARTI000006278917/2008-12-11/
2022-11-29 16:39:58 +01:00
if [ [ ! -f ~/.zen/game/players/${ PLAYER } /legal ] ] ; then
2022-09-04 12:20:55 +02:00
zenity --width ${ large } --height= ${ haut } --text-info \
--title= "Action conforme avec le Code de la propriété intellectuelle" \
--html \
--url= "https://fr.wikipedia.org/wiki/Droit_d%27auteur_en_France#Les_exceptions_au_droit_d%E2%80%99auteur" \
--checkbox= "J'ai lu et j'accepte les termes."
case $? in
0)
echo "AUTORISATION COPIE PRIVE ASTROPORT OK !"
2022-11-29 16:39:58 +01:00
echo " $G1PUB " > ~/.zen/game/players/${ PLAYER } /legal
2022-09-04 12:20:55 +02:00
# next step
; ;
1)
echo "Refus conditions"
2022-11-29 16:39:58 +01:00
rm -f ~/.zen/game/players/${ PLAYER } /legal
2022-09-04 12:20:55 +02:00
exit 1
; ;
-1)
echo "Erreur."
exit 1
; ;
esac
fi
2023-11-24 18:02:20 +01:00
## CHANGE ASTROPORT BOOSTRAP
2022-10-31 17:22:40 +01:00
if [ [ $1 = = "on" ] ] ; then
2022-09-04 12:20:55 +02:00
STRAP = $( ipfs bootstrap)
2022-11-22 19:13:55 +01:00
BOOT = $( zenity --entry --width 300 --title= "Catégorie" --text= " $STRAP Changez de Bootstrap " --entry-text= "Aucun" Astroport Public)
2022-09-04 12:20:55 +02:00
[ [ $BOOT = = "Aucun" ] ] && ipfs bootstrap rm --all
2022-11-22 19:13:55 +01:00
[ [ $BOOT = = "Astroport" ] ] && for bootnode in $( cat ${ MY_PATH } /A_boostrap_nodes.txt | grep -Ev "#" ) ; do ipfs bootstrap add $bootnode ; done
[ [ $BOOT = = "Public" ] ] && for bootnode in $( cat ${ MY_PATH } /A_boostrap_public.txt | grep -Ev "#" ) ; do ipfs bootstrap add $bootnode ; done
REP = $( ${ MY_PATH } /tools/cron_VRFY.sh ON) && zenity --warning --width 600 --text " $REP "
2022-09-04 12:20:55 +02:00
fi
2022-10-31 17:22:40 +01:00
2022-12-04 23:02:09 +01:00
###
2023-04-24 15:51:48 +02:00
# IS THERE ANY RUNNING IPFS ADD OR PUBLISH IN PROGRESS ?
2024-04-14 17:37:53 +02:00
ISADDING = $( ps auxf --sort= +utime | grep -w 'ipfs add' | grep -v -E 'color=auto|grep' | tail -n 1 | xargs | cut -d " " -f 1)
ISPUBLISHING = $( ps auxf --sort= +utime | grep -w 'ipfs name publish' | grep -v -E 'color=auto|grep' | tail -n 1 | xargs | cut -d " " -f 1)
2022-12-04 23:02:09 +01:00
[ [ $ISADDING || $ISPUBLISHING ] ] \
2023-01-05 22:49:10 +01:00
&& espeak "I P F S task in progress. Wait finish & try later" && exit 1
2022-12-02 15:14:19 +01:00
2022-10-31 17:22:40 +01:00
## CHECK IF ASTROPORT/CRON/IPFS IS RUNNING
2022-12-27 19:35:43 +01:00
YOU = $( myIpfsApi)
2022-10-31 17:22:40 +01:00
[ [ ! $YOU ] ] && espeak "I P F S not running - EXIT" && exit 1
2022-09-04 12:20:55 +02:00
2023-01-15 16:47:58 +01:00
[ [ ! $URL ] ] && xdg-open " http://ipfs.localhost:8080/ipns/ $ASTRONAUTENS "
2023-01-07 17:14:57 +01:00
2022-12-02 15:14:19 +01:00
########################################################################
2023-03-13 18:50:20 +01:00
espeak " $COINS JUNE Ready ! "
2022-12-02 15:14:19 +01:00
########################################################################
2022-11-19 21:28:00 +01:00
2022-09-04 12:20:55 +02:00
########################################################################
# CHOOSE CATEGORY (remove anime, not working!)
2023-07-26 12:28:58 +02:00
[ ! $2 ] && [ [ $CHOICE = = "" ] ] && CHOICE = $( zenity --entry --width 300 --title= "Catégorie" --text= "Quelle catégorie pour ce media ?" --entry-text= "Vlog" Video Film Serie PDF Youtube MP3 Web)
2022-12-11 04:13:47 +01:00
[ [ $CHOICE = = "" ] ] && echo "NO CHOICE MADE" && exit 1
2022-09-04 12:20:55 +02:00
# LOWER CARACTERS
CAT = $( echo " ${ CHOICE } " | awk '{print tolower($0)}' )
# UPPER CARACTERS
CHOICE = $( echo " ${ CAT } " | awk '{print toupper($0)}' )
PREFIX = $( echo " ${ CAT } " | head -c 1 | awk '{ print toupper($0) }' ) # ex: F, S, A, Y, M ... P W
[ [ $PREFIX = = "" ] ] && exit 1
########################################################################
########################################################################
case ${ CAT } in
########################################################################
2022-12-02 15:14:19 +01:00
########################################################################
2022-12-02 19:38:05 +01:00
########################################################################
2022-12-02 15:14:19 +01:00
# CASE ## VLOG
2022-11-22 19:13:55 +01:00
#~ __ ___
#~ \ \ / / | ___ __ _
#~ \ \ / /| |/ _ \ / _` |
#~ \ V / | | (_) | (_| |
#~ \_/ |_|\___/ \__, |
#~ |___/
2022-09-04 12:20:55 +02:00
#
########################################################################
2022-10-31 17:22:40 +01:00
vlog)
2022-09-04 12:20:55 +02:00
2023-04-26 21:20:36 +02:00
mkdir -p ~/Astroport/${ PLAYER } /vlog
2022-12-04 19:12:02 +01:00
espeak "Ready to record your webcam"
2022-09-04 12:20:55 +02:00
2022-12-11 04:13:47 +01:00
[ ! $2 ] && zenity --warning --width 300 --text " ${ PLAYER } . Prêt à enregistrer votre video ? "
2022-09-04 12:20:55 +02:00
## RECORD WEBCAM VIDEO
2022-11-22 19:13:55 +01:00
${ MY_PATH } /tools/vlc_webcam.sh
2022-09-04 12:20:55 +02:00
2023-01-20 15:17:02 +01:00
exit 0
; ;
2022-09-04 12:20:55 +02:00
########################################################################
# CASE ## YOUTUBE
# _ _
# _ _ ___ _ _| |_ _ _| |__ ___
#| | | |/ _ \| | | | __| | | | '_ \ / _ \
#| |_| | (_) | |_| | |_| |_| | |_) | __/
# \__, |\___/ \__,_|\__|\__,_|_.__/ \___|
# |___/
########################################################################
youtube)
2023-04-26 21:20:36 +02:00
mkdir -p ~/Astroport/${ PLAYER } /youtube
2022-10-31 17:22:40 +01:00
espeak "youtube : video copying"
2022-09-04 12:20:55 +02:00
YTURL = " $URL "
2023-04-26 23:50:27 +02:00
[ ! $2 ] && [ [ $YTURL = = "" ] ] && YTURL = $( zenity --entry --width 420 --title "Lien ou identifiant à copier" --text "Indiquez le lien (URL) ou l'ID de la vidéo" --entry-text= "" )
2022-12-11 04:13:47 +01:00
[ [ $YTURL = = "" ] ] && echo "URL EMPTY " && exit 1
2022-09-04 12:20:55 +02:00
REVSOURCE = " $( echo " $YTURL " | awk -F/ '{print $3}' | rev) _ "
# Create TEMP directory to copy $YID_$TITLE.$FILE_EXT
YTEMP = " $HOME /.zen/tmp/ $( date -u +%s%N | cut -b1-13) "
mkdir -p ${ YTEMP }
# youtube-dl $YTURL
echo " VIDEO $YTURL "
2023-03-07 14:58:12 +01:00
LINE = " $( yt-dlp $BROWSER --print "%(id)s&%(title)s" " ${ YTURL } " ) "
2023-03-08 17:00:53 +01:00
echo $LINE
2022-12-23 14:43:54 +01:00
YID = $( echo " $LINE " | cut -d '&' -f 1)
TITLE = $( echo " $LINE " | cut -d '&' -f 2- | detox --inline)
2022-12-14 13:46:06 +01:00
2022-12-23 14:43:54 +01:00
/usr/local/bin/youtube-dl -f "(bv*[ext=mp4][height<=720]+ba/b[height<=720])" \
2023-01-06 06:23:34 +01:00
--no-playlist \
2023-04-14 14:19:20 +02:00
$BROWSER --verbose \
2022-12-11 04:13:47 +01:00
--download-archive $HOME /.zen/.yt-dlp.list \
2022-12-23 14:43:54 +01:00
-S res,ext:mp4:m4a --recode mp4 --no-mtime --embed-thumbnail --add-metadata \
-o " ${ YTEMP } / $TITLE .%(ext)s " " $YTURL "
2022-09-04 12:20:55 +02:00
2023-03-08 17:00:53 +01:00
DFILE = $( ls ${ YTEMP } /*.mp4)
echo " LISTING ${ YTEMP } : $DFILE "
if [ [ $DFILE = = "" ] ] ; then
2023-03-07 14:58:12 +01:00
## SECOND TRY
/usr/local/bin/youtube-dl --no-playlist $BROWSER --download-archive $HOME /.zen/.yt-dlp.list -S res,ext:mp4:m4a --no-mtime --embed-thumbnail --add-metadata -o " ${ YTEMP } / $TITLE .%(ext)s " " $YTURL "
fi
2023-03-08 17:00:53 +01:00
DFILE = $( ls ${ YTEMP } /*.mp4)
echo " LISTING ${ YTEMP } : $DFILE "
[ [ $DFILE = = "" ] ] && espeak "cannot find file" && exit 1
2023-03-07 14:58:12 +01:00
2022-12-23 14:43:54 +01:00
ZFILE = " $TITLE .mp4 "
echo " $ZFILE "
2022-09-04 12:20:55 +02:00
2022-12-23 14:43:54 +01:00
FILE_NAME = " $( basename " ${ ZFILE } " ) "
FILE_EXT = " ${ FILE_NAME ##*. } "
2022-12-04 19:12:02 +01:00
2022-12-23 14:43:54 +01:00
echo " OK $ZFILE copied "
espeak " OK $TITLE copied "
2022-12-04 19:12:02 +01:00
2022-09-04 12:20:55 +02:00
MEDIAID = " $REVSOURCE ${ YID } "
MEDIAKEY = " YOUTUBE_ ${ MEDIAID } "
2023-04-26 21:20:36 +02:00
FILE_PATH = " $HOME /Astroport/ ${ PLAYER } /youtube/ $MEDIAID "
2022-09-04 12:20:55 +02:00
mkdir -p ${ FILE_PATH } && mv -f ${ YTEMP } /* ${ FILE_PATH } /
FILE_RES = $( ffprobe -v error -select_streams v:0 -show_entries stream = width,height -of csv = s = x:p= 0 " ${ FILE_PATH } / ${ FILE_NAME } " | cut -d "x" -f 2)
RES = ${ FILE_RES %? } 0p
2023-04-26 21:20:36 +02:00
## CREATE "~/Astroport/${PLAYER}/${CAT}/${MEDIAID}/ajouter_video.txt" and video.json
2022-09-04 12:20:55 +02:00
URLENCODE_FILE_NAME = $( echo ${ FILE_NAME } | jq -Rr @uri)
## KEEPS KODI COMPATIBILITY (BROKEN astroport.py !! ) : TODO DEBUG
2023-04-26 21:20:36 +02:00
echo " youtube; ${ MEDIAID } ; $( date -u +%s%N | cut -b1-13) ; ${ TITLE } ; ${ SAISON } ; ${ GENRES } ;_IPNSKEY_; ${ RES } ;/ipfs/_IPFSREPFILEID_/ $URLENCODE_FILE_NAME " > ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt
2022-09-04 12:20:55 +02:00
# _IPFSREPFILEID_ is replaced later
rm -Rf ${ YTEMP }
; ;
########################################################################
# CASE ## WEB
2022-11-22 19:13:55 +01:00
#~ __ __ _
#~ \ \ / /__ | |__
#~ \ \ /\ / / _ \ '_ \
#~ \ V V /__/ |_) |
#~ \_/\_/ \_|_.__/
#~
2022-09-04 12:20:55 +02:00
web)
2023-04-26 21:20:36 +02:00
mkdir -p ~/Astroport/${ PLAYER } /web
2022-12-02 15:14:19 +01:00
# URL="https://discuss.ipfs.io/t/limit-ipfs-get-command/3573/6"
espeak "Mirror web site"
cd ~/.zen/tmp/
2022-12-11 04:13:47 +01:00
[ ! $2 ] && [ [ $URL = = "" ] ] && URL = $( zenity --entry --width 300 --title "Lien du site Web à copier" --text "Indiquez le lien (URL)" --entry-text= "" )
2022-12-02 15:14:19 +01:00
## Extract http(s)://domain.tld
2022-12-18 20:09:54 +01:00
URLSOURCE = $( echo $URL | grep -Eo '^http[s]?://[^/]+' ) # URL="https://discuss.ipfs.io"
DOMAIN = $( echo $URLSOURCE | rev | cut -d '/' -f1 | rev) # DOMAIN=discuss.ipfs.io
2022-12-02 15:14:19 +01:00
ARR = ( $( echo $DOMAIN | sed "s~\.~ ~g" ) ) # ARR=discuss ipfs io
NIAMOD = $( printf '%s\n' " ${ ARR [@] } " | tac | tr '\n' '.' ) # NIAMOD=io.ipfs.discuss.
NIAPATH = $( echo $NIAMOD | sed "s~\.~\/~g" ) # NIAPATH=io/ipfs/discuss/
TITLE = $DOMAIN
GENRES = "Web"
espeak " ${ ARR [@] } "
2022-12-04 19:12:02 +01:00
## CREATE IPNS KEY HOOK JUST FOR FUN
2022-12-02 15:14:19 +01:00
REVSOURCE = " $( echo " $NIAMOD " | rev | sha256sum | cut -d ' ' -f 1) " ; echo $REVSOURCE
MEDIAKEY = " $REVSOURCE " # MEDIAKEY=435582881619ee4df9e2723fb9e20bb173b32818094a3e40c9536068ae3730ac
IPNSKEY = $( ipfs key list -l | grep -w $MEDIAKEY | cut -d ' ' -f 1 )
if [ [ ! $IPNSKEY ] ] ; then
# Funny Crypto Level # TODO MAKE IT MORE SECURE # THIS KEY OWNS THE DOMAIN NOW
${ MY_PATH } /tools/keygen -t ipfs -o ~/.zen/tmp/$MEDIAKEY .ipns " $DOMAIN " " $NIAMOD "
IPNSKEY = $( ipfs key import $MEDIAKEY -f pem-pkcs8-cleartext ~/.zen/tmp/$MEDIAKEY .ipns)
fi
MEDIAID = " WEB_ ${ NIAMOD } " # MEDIAID=WEB_io.ipfs.discuss.
2023-04-26 21:20:36 +02:00
FILE_PATH = " $HOME /Astroport/ ${ PLAYER } /web/ $MEDIAID " ; # FILE_PATH=/home/fred/Astroport/${PLAYER}/web/WEB_io.ipfs.discuss.
2022-10-31 17:22:40 +01:00
2022-12-02 15:14:19 +01:00
start = ` date +%s`
2022-10-31 17:22:40 +01:00
2022-12-02 15:14:19 +01:00
mkdir -p $FILE_PATH
cd $FILE_PATH
2022-09-04 12:20:55 +02:00
2022-12-02 15:14:19 +01:00
espeak "Let's go. " ###################### HTTRACK COPYING
2022-09-04 12:20:55 +02:00
2023-01-17 21:53:10 +01:00
httrack -wxY --sockets= 99 − − max− rate= 0 --disable-security-limits − − keep− alive --ext-depth= 0 --stay-on-same-domain --robots= 0 --keep-links= 0 -V " echo \$0 >> $FILE_PATH /files " " $URL " -* +*/$DOMAIN /* -*wget* # -%l "fr"
2022-09-04 12:20:55 +02:00
2023-02-04 18:50:32 +01:00
cd $FILE_PATH /$DOMAIN /
grep -rl '../external.html' ./ | xargs sed -i 's~../external.html~external.html~g'
2023-02-04 18:55:28 +01:00
2023-02-04 19:03:42 +01:00
cp $MY_PATH /templates/external.html $FILE_PATH /$DOMAIN /
2023-02-04 18:50:32 +01:00
2022-12-02 15:14:19 +01:00
## G1PUB ENCODE.16 MEDIAKEY
${ MY_PATH } /tools/natools.py encrypt -p $G1PUB -i $HOME /.zen/tmp/$MEDIAKEY .ipns -o $HOME /.zen/tmp/$MEDIAKEY .ipns.enc
cat $HOME /.zen/tmp/$MEDIAKEY .ipns.enc | base16 > $FILE_PATH /$DOMAIN /.ipnskey.$G1PUB .enc.16
## BLOCKCHAIN IT
echo " $MOATS " > $FILE_PATH /$DOMAIN /.moats # TIMESTMAPING
echo " $IPNSKEY " > $FILE_PATH /$DOMAIN /.ipnshook # SELF REFERING
2022-12-04 19:12:02 +01:00
espeak "OK Web is copied. Adding to I P F S now..."
2022-12-02 15:14:19 +01:00
### ADD TO IPFS
2022-12-04 15:06:09 +01:00
IPFSREPFILEID = $( ipfs add -qHwr $FILE_PATH /$DOMAIN /* | tail -n 1) # ADDING $DOMAIN TO IPFS
2022-12-02 15:14:19 +01:00
ipfs name publish -k $MEDIAKEY /ipfs/$IPFSREPFILEID # PUBLISH $MEDIAKEY
## CREATE ajouter_video.txt
2023-04-26 21:20:36 +02:00
echo " web; ${ MEDIAID } ; ${ MOATS } ; ${ TITLE } ; ${ SAISON } ; ${ GENRES } ; $IPNSKEY ; ${ RES } ;/ipfs/ $IPFSREPFILEID " > ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt
2022-12-02 15:14:19 +01:00
## DURATION LOG
end = ` date +%s`
dur = ` expr $end - $start `
echo ${ MOATS } :${ G1PUB } :${ PLAYER } :${ MEDIAID } :$dur >> ~/.zen/tmp/${ IPFSNODEID } /_timings
cat ~/.zen/tmp/${ IPFSNODEID } /_timings | tail -n 1
## TIDDLER CREATION
FILE_BSIZE = $( du -b " $FILE_PATH / $DOMAIN / " | awk '{print $1}' | tail -n 1)
FILE_SIZE = $( echo " ${ FILE_BSIZE } " | awk '{ split( "B KB MB GB TB PB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } printf "%.2f %s", $1, v[s] }' )
2022-12-04 19:12:02 +01:00
## NB TEXT IS MADE WITH TIDDLERS FIELDS VALUES (LEARN TODO)
2022-12-02 15:14:19 +01:00
TEXT = " <iframe src={{{ [{ $:/ipfs/saver/gateway/http/localhost!!text}] [{!!ipfs}] +[join[]] }}} height='360' width='100%'></iframe>
2022-12-02 17:45:45 +01:00
Web : $URL ----> <a href = { { { [ { $:/ipfs/saver/gateway/http/localhost!!text} ] [ { !!ipfs} ] +[ join[ ] ] } } } } ><<currentTiddler>></a>
2022-12-04 19:12:02 +01:00
<br>$FILE_SIZE - $dur sec"
2022-12-02 15:14:19 +01:00
echo ' [
{
"created" : " ' ${ MOATS } ' " ,
"modified" : " ' ${ MOATS } ' " ,
2022-12-04 15:06:09 +01:00
"dur" : " ' $dur ' " ,
2022-12-02 17:45:45 +01:00
"title" : " ' ${ NIAMOD } ' " ,
2022-12-02 15:14:19 +01:00
"type" : "'text/vnd.tiddlywiki'" ,
"text" : " ' $TEXT ' " ,
"size" : " ' ${ FILE_BSIZE } ' " ,
2022-12-15 02:35:59 +01:00
"filesize" : " ' ${ FILE_SIZE } ' " ,
2022-12-02 15:14:19 +01:00
"g1pub" : " ' ${ G1PUB } ' " ,
"ipfs" : " '/ipfs/ ${ IPFSREPFILEID } ' " ,
"mediakey" : " ' ${ MEDIAKEY } ' " ,
"ipnskey16" : " ' $( cat $HOME /.zen/tmp/$MEDIAKEY .ipns.enc | base16) ' " ,
"ipns" : " '/ipns/ ${ IPNSKEY } ' " ,
2022-12-04 19:12:02 +01:00
"tags" : " 'ipfs G1Web $PLAYER webmaster@ $DOMAIN ' "
2022-12-02 15:14:19 +01:00
}
]
2023-04-26 21:20:36 +02:00
' > ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /${ MEDIAKEY } .dragdrop.json
2022-12-02 15:14:19 +01:00
# zenity --warning --width ${large} --text "Copie $URL dans ${FILE_PATH}/ et /ipns/$IPNSKEY"
2022-12-04 19:12:02 +01:00
espeak "Done. Tiddler is ready"
2022-09-04 12:20:55 +02:00
; ;
########################################################################
2023-04-05 18:07:18 +02:00
# CASE ## PDF
2022-11-22 19:13:55 +01:00
#~ ____
#~ | _ \ __ _ __ _ ___
#~ | |_) / _` |/ _` |/ _ \
#~ | __/ (_| | (_| | __/
#~ |_| \__,_|\__, |\___|
#~ |___/
2023-04-05 18:07:18 +02:00
pdf)
2022-09-04 12:20:55 +02:00
2023-04-26 21:20:36 +02:00
mkdir -p ~/Astroport/${ PLAYER } /pdf
2023-04-05 18:07:18 +02:00
espeak "Importing file or web page to P D F"
2022-12-02 15:14:19 +01:00
## EVOLVE TO ARTICLE
# httrack --mirror --ext-depth=0 --depth=1 --near --stay-on-same-address --keep-links=0 --path article-x --quiet https://example.com/article-x/
2022-11-22 19:13:55 +01:00
2023-04-16 02:00:19 +02:00
[ ! $2 ] && [ [ $URL = = "" ] ] && URL = $( zenity --entry --width 500 --title "Convertir lien PDF (ANNULER ET CHOISIR UN FICHIER LOCAL)" --text "Indiquez le lien (URL)" --entry-text= "" )
2022-10-31 17:22:40 +01:00
2022-11-22 19:13:55 +01:00
if [ [ $URL != "" ] ] ; then
2022-09-04 12:20:55 +02:00
## record one page to PDF
2022-12-11 04:13:47 +01:00
[ ! $2 ] && [ [ ! $( which chromium) ] ] && zenity --warning --width ${ large } --text "Utilitaire de copie de page web absent.. Lancez la commande 'sudo apt install chromium'" && exit 1
2022-11-22 19:13:55 +01:00
cd ~/.zen/tmp/ && rm -f output.pdf
# https://peter.sh/experiments/chromium-command-line-switches
2022-12-04 19:12:02 +01:00
${ MY_PATH } /tools/timeout.sh -t 30 \
2022-11-22 19:13:55 +01:00
chromium --headless --use-mobile-user-agent --no-sandbox --print-to-pdf " $URL "
fi
if [ [ $URL = = "" ] ] ; then
# SELECT FILE TO ADD TO ASTROPORT/KODI
2022-12-11 04:13:47 +01:00
[ ! $2 ] && FILE = $( zenity --file-selection --title= "Sélectionner le fichier à ajouter" )
2022-11-22 19:13:55 +01:00
echo " ${ FILE } "
2023-04-15 23:56:53 +02:00
[ [ ! -s " ${ FILE } " ] ] && echo "NO FILE" && exit 1
2022-11-19 17:46:00 +01:00
2022-11-22 19:13:55 +01:00
# Remove file extension to get file name => STITLE
FILE_PATH = " $( dirname " ${ FILE } " ) "
FILE_NAME = " $( basename " ${ FILE } " ) "
FILE_EXT = " ${ FILE_NAME ##*. } "
FILE_TITLE = " ${ FILE_NAME %.* } "
2023-04-15 23:56:53 +02:00
cp " ${ FILE } " ~/.zen/tmp/output.pdf
2022-11-22 19:13:55 +01:00
URL = " /ipfs.localhost/ $FILE_TITLE "
fi
2022-11-19 17:46:00 +01:00
2022-09-04 12:20:55 +02:00
2022-11-23 14:59:04 +01:00
[ [ ! -s ~/.zen/tmp/output.pdf ] ] && espeak "No file Sorry. Exit" && exit 1
2022-11-19 17:46:00 +01:00
2022-12-16 13:02:03 +01:00
espeak "OK P D F received"
2022-12-04 19:12:02 +01:00
2023-07-31 17:08:55 +02:00
#~ ## TODO
#~ ## CONVERT TO DOCX
#~ pdf2docx convert ~/.zen/tmp/output.pdf
#~ # THEN TO MD
#~ pandoc -f docx -t markdown -o ~/.zen/tmp/output.md ~/.zen/tmp/output.docx
2022-11-19 17:46:00 +01:00
CTITLE = $( echo $URL | rev | cut -d '/' -f 1 | rev)
2022-12-15 03:50:40 +01:00
[ ! $2 ] && TITLE = $( zenity --entry --width 480 --title "Titre" --text "Quel nom donner à ce fichier ? " --entry-text= " ${ CTITLE } " ) || TITLE = " $CTITLE "
2022-12-11 04:13:47 +01:00
[ [ " $TITLE " = = "" ] ] && echo "NO TITLE" && exit 1
2022-09-04 12:20:55 +02:00
2022-12-11 04:13:47 +01:00
FILE_NAME = " $( echo " ${ TITLE } " | detox --inline) .pdf " ## TODO make it better
2022-11-22 19:13:55 +01:00
REVSOURCE = " $( echo " $URL " | awk -F/ '{print $3}' | rev | detox --inline) _ "
2022-09-04 12:20:55 +02:00
MEDIAID = " $REVSOURCE $( echo " ${ TITLE } " | detox --inline) "
2023-04-16 02:00:19 +02:00
MEDIAKEY = " PDF_ ${ MEDIAID } "
2023-04-26 21:20:36 +02:00
FILE_PATH = " $HOME /Astroport/ ${ PLAYER } /pdf/ $MEDIAID "
2022-11-22 19:13:55 +01:00
mkdir -p ${ FILE_PATH } && mv ~/.zen/tmp/output.pdf ${ FILE_PATH } /${ FILE_NAME }
2022-09-04 12:20:55 +02:00
2023-04-26 21:20:36 +02:00
echo " pdf; ${ MEDIAID } ; $( date -u +%s%N | cut -b1-13) ; ${ TITLE } ; ${ SAISON } ; ${ GENRES } ;_IPNSKEY_; ${ RES } ;/ipfs/_IPFSREPFILEID_/ $FILE_NAME " > ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt
2022-09-04 12:20:55 +02:00
2022-11-22 19:13:55 +01:00
espeak 'Document ready'
2022-09-04 12:20:55 +02:00
; ;
########################################################################
# CASE ## MP3
# _____
# _ __ ___ _ __|___ /
#| '_ ` _ \| '_ \ |_ \
#| | | | | | |_) |__) |
#|_| |_| |_| .__/____/
# |_|
########################################################################
mp3)
2023-04-26 21:20:36 +02:00
mkdir -p ~/Astroport/${ PLAYER } /mp3
2023-04-05 18:07:18 +02:00
[ [ $URL = = "" ] ] && URL = $( zenity --entry --width 500 --title "Lien Youtube à convertir en MP3" --text "Indiquez le lien (URL)" --entry-text= "" )
espeak "OK."
2023-04-26 21:20:36 +02:00
yt-dlp -x --no-mtime --audio-format mp3 --embed-thumbnail --add-metadata -o " $HOME /Astroport/ ${ PLAYER } /mp3/%(autonumber)s_%(title)s.%(ext)s " " $URL "
2023-04-05 18:07:18 +02:00
espeak "Ready. check your home Astoport mp3 directory"
break
2022-09-04 12:20:55 +02:00
; ;
########################################################################
2022-11-22 19:13:55 +01:00
# Film __ _ _ Serie
#~ _____ _ _ ___ ____ _
#~ | ___(_) |_ __ ___ ( _ ) / ___| ___ _ __(_) ___
#~ | |_ | | | '_ ` _ \ / _ \/\ \___ \ / _ \ '__| |/ _ \
#~ | _| | | | | | | | | | (_> < ___) | __/ | | | __/
#~ |_| |_|_|_| |_| |_| \___/\/ |____/ \___|_| |_|\___|
2022-09-04 12:20:55 +02:00
#
########################################################################
film | serie)
2023-04-26 21:20:36 +02:00
mkdir -p ~/Astroport/${ PLAYER } /film
mkdir -p ~/Astroport/${ PLAYER } /serie
2022-11-20 12:57:41 +01:00
espeak "please select your file"
2022-10-31 17:22:40 +01:00
2022-09-04 12:20:55 +02:00
# SELECT FILE TO ADD TO ASTROPORT/KODI
FILE = $( zenity --file-selection --title= "Sélectionner le fichier à ajouter" )
echo " ${ FILE } "
[ [ $FILE = = "" ] ] && exit 1
# Remove file extension to get file name => STITLE
FILE_PATH = " $( dirname " ${ FILE } " ) "
FILE_NAME = " $( basename " ${ FILE } " ) "
FILE_EXT = " ${ FILE_NAME ##*. } "
FILE_TITLE = " ${ FILE_NAME %.* } "
# OPEN default browser and search TMDB
zenity --question --width 300 --text " Ouvrir https://www.themoviedb.org pou récupérer le numéro d'identification de $( echo ${ FILE_TITLE } | sed 's/_/%20/g' ) ? "
[ $? = = 0 ] && xdg-open " https://www.themoviedb.org/search?query= $( echo ${ FILE_TITLE } | sed 's/_/%20/g' ) "
MEDIAID = $( zenity --entry --title= "Identification TMDB" --text= "Copiez le nom de la page du film. Ex: 301528-toy-story-4 pour une adresse https://www.themoviedb.org/movie/301528-toy-story-4)" --entry-text= "" )
[ [ $MEDIAID = = "" ] ] && exit 1
2022-11-22 19:13:55 +01:00
MEDIAID = $( echo $MEDIAID | rev | cut -d '/' -f 1 | rev) ## REmoving/That/Part/keeping/MEDIAID
2022-09-04 12:20:55 +02:00
CMED = $( echo $MEDIAID | cut -d '-' -f 1)
TMTL = $( echo $MEDIAID | cut -d '-' -f 2-) # contient la fin du nom de fichier tmdb (peut servir?)
if ! [ [ " $CMED " = ~ ^[ 0-9] +$ ] ]
then
2023-04-26 21:20:36 +02:00
zenity --warning --width ${ large } --text "Vous devez renseigner un numéro! Merci de recommencer... Seules les vidéos référencées sur The Movie Database sont acceptées. Sinon importez en mode 'Video'" && exit 1
2022-09-04 12:20:55 +02:00
fi
MEDIAID = $CMED
MEDIAKEY = " TMDB_ $MEDIAID "
# VIDEO TITLE
2022-11-22 19:13:55 +01:00
### CHECK IF PREVIOUS ajouter_video (usefull for Serie)
2023-04-26 21:20:36 +02:00
[ [ -f ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt ] ] \
&& PRE = $( cat ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt | cut -d ';' -f 4) \
2022-11-20 12:57:41 +01:00
|| PRE = ${ FILE_TITLE }
###
TITLE = $( zenity --entry --width 300 --title "Titre" --text "Indiquez le titre de la vidéo" --entry-text= " ${ PRE } " )
2022-09-04 12:20:55 +02:00
[ [ $TITLE = = "" ] ] && exit 1
2023-01-07 17:14:57 +01:00
TITLE = $( echo " ${ TITLE } " | detox --inline ) # Clean TITLE (NO ;)
2022-09-04 12:20:55 +02:00
# VIDEO YEAR
2022-11-20 12:57:41 +01:00
### CHECK IF PREVIOUS ajouter_video (Serie case)
2023-04-26 21:20:36 +02:00
[ [ -f ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt ] ] \
&& PRE = $( cat ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt | cut -d ';' -f 3) \
2022-12-04 15:06:09 +01:00
|| PRE = ""
2022-11-20 12:57:41 +01:00
YEAR = $( zenity --entry --width 300 --title "Année" --text "Indiquez année de la vidéo. Exemple: 1985" --entry-text= " ${ PRE } " )
2022-09-04 12:20:55 +02:00
# VIDEO RESOLUTION
FILE_RES = $( ffprobe -v error -select_streams v:0 -show_entries stream = width,height -of csv = s = x:p= 0 " ${ FILE } " | cut -d "x" -f 2)
RES = ${ FILE_RES %? } 0p # Rounding. Replace last digit with 0
# VIDEO SEASON or SAGA
2022-11-20 12:57:41 +01:00
### CHECK IF PREVIOUS ajouter_video (Serie case)
2023-04-26 21:20:36 +02:00
[ [ -f ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt ] ] \
&& PRE = $( cat ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt | cut -d ';' -f 5 | cut -d '_' -f 2)
2022-11-20 12:57:41 +01:00
[ [ " ${ CAT } " = = "serie" ] ] && SAISON = $( zenity --entry --width 300 --title " ${ CHOICE } Saison " --text "Indiquez SAISON et EPISODE. Exemple: S02E05" --entry-text= " ${ PRE } " )
2022-09-04 12:20:55 +02:00
[ [ " ${ CAT } " = = "film" ] ] && SAISON = $( zenity --entry --width 300 --title " ${ CHOICE } Saga " --text "Indiquez une SAGA (optionnel). Exemple: James Bond" --entry-text= "" )
2022-11-19 21:28:00 +01:00
[ [ $SAISON ] ] && SAISON = " _ $SAISON "
2022-09-04 12:20:55 +02:00
# VIDEO GENRES
FILM_GENRES = $( zenity --list --checklist --title= "GENRE" --height= ${ haut } \
2022-11-22 19:13:55 +01:00
--text= " Choisissez le(s) genre(s) de \" ${ TITLE } \" " \
2022-09-04 12:20:55 +02:00
--column= "Use" \
--column= "Feature" \
FALSE '+18' \
FALSE Action\
FALSE Animation\
2022-12-17 13:19:45 +01:00
FALSE 'Arts Martiaux' \
2022-09-04 12:20:55 +02:00
FALSE Aventure\
FALSE Autre\
FALSE Biographie\
FALSE Biopic\
FALSE Comedie\
2022-12-17 13:19:45 +01:00
FALSE 'Comedie Dramatique' \
FALSE 'Comedie Musicale' \
2022-09-04 12:20:55 +02:00
FALSE Crime\
FALSE Documentaire\
FALSE Drame\
FALSE Divers\
FALSE Educatif\
FALSE Enfant\
2022-12-17 13:19:45 +01:00
FALSE Horreur\
2022-09-04 12:20:55 +02:00
FALSE Espionnage\
FALSE Famille\
FALSE Fantastique\
FALSE Guerre\
FALSE Histoire\
FALSE Historique\
FALSE Judiciaire\
FALSE Opera\
FALSE Medical\
FALSE Musique\
FALSE Mystere\
FALSE Peplum\
FALSE Policier\
FALSE Romance\
2022-12-17 13:19:45 +01:00
FALSE 'Science Fiction' \
2022-09-04 12:20:55 +02:00
FALSE Soap\
FALSE Spectacle\
FALSE Sport\
FALSE Telefilm\
FALSE Thriller\
FALSE Western\
TRUE ${ PLAYER // /- } )
# FORMAT GENRES ["genre1","genre2"] # USE IF YOU ACTIVATE KODI COMPATIBILITY
GENRES = " [\" $( echo ${ FILM_GENRES } | sed s/\| /\" ,\" /g) \"] "
2022-12-10 03:26:20 +01:00
# CONVERT INPUT TO MP4 #######################
[ [ $FILE_EXT != "mp4" ] ] \
&& espeak "Converting to M P 4. Please wait" \
2023-02-17 14:01:02 +01:00
&& echo " CONVERT TO MP4 : ffmpeg -loglevel quiet -i ${ FILE_PATH } / ${ FILE_NAME } -c:v libx264 -c:a aac ${ FILE_PATH } / $FILE_TITLE .mp4 " \
&& ffmpeg -loglevel quiet -i " ${ FILE_PATH } / ${ FILE_NAME } " -c:v libx264 -c:a aac " ${ FILE_PATH } / $FILE_TITLE .mp4 " \
2022-12-10 03:26:20 +01:00
&& FILE_EXT = "mp4" && FILE_NAME = " $FILE_TITLE .mp4 " \
&& espeak "M P 4 ready"
2023-04-26 21:20:36 +02:00
mkdir -p ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /
2022-12-04 15:06:09 +01:00
2023-04-26 21:20:36 +02:00
[ [ ! -s " $HOME /Astroport/ ${ PLAYER } / ${ CAT } / ${ MEDIAID } / ${ TITLE } ${ SAISON } . ${ FILE_EXT } " ] ] \
&& cp " ${ FILE_PATH } / ${ FILE_NAME } " " $HOME /Astroport/ ${ PLAYER } / ${ CAT } / ${ MEDIAID } / ${ TITLE } ${ SAISON } . ${ FILE_EXT } " \
2022-12-02 19:38:05 +01:00
&& [ $? != 0 ] \
&& zenity --warning --width ${ large } --text " (☓‿‿☓) ${ FILE_PATH } / ${ FILE_NAME } vers ~/Astroport - EXIT - " && exit 1
2022-09-04 12:20:55 +02:00
2022-11-21 21:30:58 +01:00
FILE_NAME = " ${ TITLE } ${ SAISON } . ${ FILE_EXT } "
2022-09-04 12:20:55 +02:00
2023-04-26 21:20:36 +02:00
## CREATE "~/Astroport/${PLAYER}/${CAT}/${MEDIAID}/ajouter_video.txt"
2022-09-04 12:20:55 +02:00
URLENCODE_FILE_NAME = $( echo ${ FILE_NAME } | jq -Rr @uri)
2023-04-26 21:20:36 +02:00
echo " ${ CAT } ; ${ MEDIAID } ; ${ YEAR } ; ${ TITLE } ; ${ SAISON } ; ${ GENRES } ;_IPNSKEY_; ${ RES } ;/ipfs/_IPFSREPFILEID_/ $URLENCODE_FILE_NAME " > ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt
2022-09-04 12:20:55 +02:00
# _IPFSREPFILEID_ is replaced later
2022-12-04 19:12:02 +01:00
#######################################################
######## NOT CREATING TIDDLER JSON... SWALLOW IS POST-PROCESSED
## new_file_in_astroport.sh ACTIVATES CONTRACT MODE !!
#######################################################
#######################################################
2022-09-04 12:20:55 +02:00
; ;
2022-11-22 19:13:55 +01:00
# video _ _
2022-09-04 12:20:55 +02:00
#__ _(_) __| | ___ ___
#\ \ / / |/ _` |/ _ \/ _ \
# \ V /| | (_| | __/ (_) |
# \_/ |_|\__,_|\___|\___/
# TIMESTAMP INDEX
2022-12-11 04:13:47 +01:00
video)
2022-09-04 12:20:55 +02:00
2023-04-26 21:20:36 +02:00
mkdir -p ~/Astroport/${ PLAYER } /video
2022-12-02 19:38:05 +01:00
espeak "Add your personnal video in TW"
2022-10-31 17:22:40 +01:00
2023-04-24 21:32:14 +02:00
#~ zenity --warning --width 600 --text 'DEV-DEBUG : REGISTER https://git.p2p.legal'
2022-09-04 12:20:55 +02:00
## GENERAL MEDIAKEY for uploaded video. Title + Decription + hashtag + hashipfs
# SELECT FILE TO ADD TO ASTROPORT/KODI
2022-12-02 19:38:05 +01:00
FILE = $( zenity --file-selection --title= "Sélectionner votre vidéo" )
2022-09-04 12:20:55 +02:00
echo " ${ FILE } "
[ [ $FILE = = "" ] ] && exit 1
# Remove file extension to get file name => STITLE
FILE_PATH = " $( dirname " ${ FILE } " ) "
FILE_NAME = " $( basename " ${ FILE } " ) "
FILE_EXT = " ${ FILE_NAME ##*. } "
FILE_TITLE = " ${ FILE_NAME %.* } "
2022-12-02 19:38:05 +01:00
2023-01-02 00:15:36 +01:00
#~ # MUST CONVERT MKV TO MP4
#~ [[ $FILE_EXT != "mp4" ]] \
#~ && ffmpeg -loglevel quiet -i "${FILE_PATH}/${FILE_NAME}" -c:v libx264 -c:a aac "${FILE_PATH}/$FILE_TITLE.mp4" \
#~ && FILE_EXT="mp4" && FILE_NAME="$FILE_TITLE.mp4"
2022-12-02 19:38:05 +01:00
2022-09-04 12:20:55 +02:00
# VIDEO TITLE
2023-04-24 21:55:27 +02:00
TITLE = $( zenity --entry --width 600 --title "Titre" --text "Indiquez le titre de cette vidéo" --entry-text= " ${ FILE_TITLE } " )
2022-09-04 12:20:55 +02:00
[ [ $TITLE = = "" ] ] && exit 1
2023-01-14 01:56:10 +01:00
TITLE = $( echo " ${ TITLE } " | detox --inline ) # Clean TITLE (NO ;)
2022-09-04 12:20:55 +02:00
## video_timestamp INDEX
MEDIAID = " $( date -u +%s%N | cut -b1-13) "
2023-04-26 21:20:36 +02:00
mkdir -p ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /
2022-09-04 12:20:55 +02:00
MEDIAKEY = " VIDEO_ ${ MEDIAID } "
2022-12-15 03:50:40 +01:00
## CREATE SIMPLE JSON (EXPERIENCE WITH it)
2023-04-26 21:20:36 +02:00
jq -n --arg ts " $MEDIAID " --arg title " $TITLE " --arg desc " $DESCRIPTION " --arg htag " $HASHTAG " '{"timestamp":$ts,"ipfs":"_IPFSREPFILEID_","ipns":"_IPNSKEY_","title":$title,"desc":$desc,"tag":$htag}' > ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /video.json
2022-12-02 19:38:05 +01:00
2022-12-15 03:50:40 +01:00
## MOVE FILE FOR new_file_in_astroport POST TREATMENT
2023-04-26 21:20:36 +02:00
[ [ ! -s " $HOME /Astroport/ ${ PLAYER } / ${ CAT } / ${ MEDIAID } / ${ TITLE } ${ SAISON } . ${ FILE_EXT } " ] ] \
&& cp " ${ FILE_PATH } / ${ FILE_NAME } " " $HOME /Astroport/ ${ PLAYER } / ${ CAT } / ${ MEDIAID } / ${ TITLE } ${ SAISON } . ${ FILE_EXT } "
2022-12-02 19:38:05 +01:00
2022-09-04 12:20:55 +02:00
FILE_NAME = " ${ TITLE } . ${ FILE_EXT } "
2022-12-04 19:12:02 +01:00
#######################################################
######## NOT CREATING TIDDLER JSON... SWALLOW IS POST-PROCESSED
## new_file_in_astroport.sh FOR OWN CREATION CONTRACTING MODE !!
#######################################################
#######################################################
2022-09-04 12:20:55 +02:00
; ;
########################################################################
# CASE ## DEFAULT
########################################################################
*)
2022-12-11 04:13:47 +01:00
[ ! $2 ] && zenity --warning --width ${ large } --text " Impossible d'interpréter votre commande $CAT "
2022-09-04 12:20:55 +02:00
exit 1
; ;
esac
2022-11-22 19:13:55 +01:00
########################################################################
########################################################################
########################################################################
########################################################################
2022-11-21 21:30:58 +01:00
########################################################################
# Screen capture
########################################################################
2023-04-14 14:19:20 +02:00
if [ [ $( echo $DISPLAY | cut -d ':' -f 1) = = "" ] ] ; then
sleep 1
import -window root ~/.zen/tmp/screen.png
fi
2022-11-21 21:30:58 +01:00
###################################
### MOVING FILE TO ~/astroport ####
###################################
2023-04-26 21:20:36 +02:00
mkdir -p ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /
mv ~/.zen/tmp/screen.png ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /screen.png
2022-11-21 21:30:58 +01:00
2022-09-04 12:20:55 +02:00
########################################################################
# ADD $FILE to IPFS / ASTROPORT / KODI
2024-06-29 11:14:00 +02:00
echo " (♥‿‿♥) new_file_in_astroport.sh \" $HOME /Astroport/ ${ PLAYER } / ${ CAT } / ${ MEDIAID } /\" \" ${ FILE_NAME } \" " " $3 " " $PLAYER "
2023-04-26 21:20:36 +02:00
[ [ -f ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt ] ] && cat ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /ajouter_video.txt
# LOG NOISE # [[ -f ~/Astroport/${PLAYER}/${CAT}/${MEDIAID}/video.json ]] && cat ~/Astroport/${PLAYER}/${CAT}/${MEDIAID}/video.json
2022-09-04 12:20:55 +02:00
########################################################################
2023-04-26 21:20:36 +02:00
## CREATION DU FICHIER ~/Astroport/${PLAYER}/Add_${MEDIAKEY}_script.sh
2022-09-04 12:20:55 +02:00
########################################################################
### AJOUT DANS IPFS #######################################################
########################################################################
####################################new_file_in_astroport.sh##################
########################################################################
2023-04-26 21:20:36 +02:00
if [ [ ! -s ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /${ MEDIAKEY } .dragdrop.json ] ] ; then
2022-12-02 15:14:19 +01:00
[ [ " $CAT " = = "film" || " $CAT " = = "serie" ] ] && CHOICE = "TMDB"
2022-09-04 12:20:55 +02:00
2022-12-02 15:14:19 +01:00
timestamp = $( date -u +%s%N | cut -b1-13)
2022-09-04 12:20:55 +02:00
2022-12-15 03:50:40 +01:00
## CREATE BASH SCRIPT
2022-09-04 12:20:55 +02:00
2023-04-26 21:20:36 +02:00
echo " MEDIAKEY= ${ MEDIAKEY } " > ~/Astroport/${ PLAYER } /Add_${ MEDIAKEY } _script.sh
2022-09-04 12:20:55 +02:00
2022-12-02 15:14:19 +01:00
## ACTIVATE h265 conversion .?
#[[ $CHOICE == "TMDB" ]] && echo "echo \"Encoder ${FILE_NAME} en h265 avant import ? Tapez sur ENTER.. Sinon saisissez qqch avant...\"
#reponse=\$1
#[[ ! \$reponse ]] && read reponse
#if [[ ! \$reponse ]]; then
2023-04-26 21:20:36 +02:00
# ffmpeg -i \"$HOME/Astroport/${PLAYER}/${CAT}/${MEDIAID}/${FILE_NAME}\" -vcodec libx265 -crf 28 $HOME/Astroport/${PLAYER}/${MEDIAID}.mp4
# mv \"$HOME/Astroport/${PLAYER}/${CAT}/${MEDIAID}/${FILE_NAME}\" \"$HOME/Astroport/${PLAYER}/${CAT}/${MEDIAID}/${FILE_NAME}.old\"
# mv $HOME/Astroport/${PLAYER}/${MEDIAID}.mp4 \"$HOME/Astroport/${PLAYER}/${CAT}/${MEDIAID}/${FILE_NAME}.mp4\"
# ${MY_PATH}/tools/new_file_in_astroport.sh \"$HOME/Astroport/${PLAYER}/${CAT}/${MEDIAID}/\" \"${FILE_NAME}.mp4\"
#else" >> ~/Astroport/${PLAYER}/Add_${MEDIAKEY}_script.sh
2022-09-04 12:20:55 +02:00
2022-12-02 15:14:19 +01:00
# $3 is the G1PUB of the PLAYER
2024-06-29 11:14:00 +02:00
echo " ${ MY_PATH } /tools/new_file_in_astroport.sh \" $HOME /Astroport/ ${ PLAYER } / ${ CAT } / ${ MEDIAID } /\" \" ${ FILE_NAME } \" \" $G1PUB \" \" $PLAYER \" " >> ~/Astroport/${ PLAYER } /Add_${ MEDIAKEY } _script.sh
2022-09-04 12:20:55 +02:00
2023-04-26 21:20:36 +02:00
#[[ $CHOICE == "TMDB" ]] && echo "fi" >> ~/Astroport/${PLAYER}/Add_${MEDIAKEY}_script.sh
2022-09-04 12:20:55 +02:00
2023-04-26 21:20:36 +02:00
echo " mv ~/Astroport/ ${ PLAYER } /Add_ ${ MEDIAKEY } _script.sh \" $HOME /Astroport/ ${ PLAYER } / ${ FILE_NAME } _DONE.sh\"
" >> ~/Astroport/ ${ PLAYER } /Add_ ${ MEDIAKEY } _script.sh
2022-09-04 12:20:55 +02:00
2023-04-26 21:20:36 +02:00
chmod +x ~/Astroport/${ PLAYER } /Add_${ MEDIAKEY } _script.sh
2022-09-04 12:20:55 +02:00
2022-12-02 15:14:19 +01:00
########################################################################
2022-12-02 19:38:05 +01:00
echo " (♥‿‿♥) $MEDIAKEY IPFS MIAM (ᵔ◡◡ᵔ) "
2022-12-02 17:45:45 +01:00
# zenity --warning --width 360 --text "(♥‿‿♥) $MEDIAKEY IPFS MIAM (ᵔ◡◡ᵔ)"
2022-09-04 12:20:55 +02:00
2022-12-02 15:14:19 +01:00
espeak " Adding $CAT to I P F S. Please Wait "
2022-09-04 12:20:55 +02:00
2022-12-15 03:50:40 +01:00
## RUN BASH SCRIPT
2023-04-26 21:20:36 +02:00
bash ~/Astroport/${ PLAYER } /Add_${ MEDIAKEY } _script.sh "noh265"
2022-09-04 12:20:55 +02:00
2022-12-15 03:50:40 +01:00
## OR PUT IN YOUR QUEUE
## CREATING TIMELINE FOR BATCH TREATMENT
#~ mkdir -p ~/.zen/tmp/${IPFSNODEID}/ajouter_media.sh/
#~ echo "${MEDIAKEY}" > ~/.zen/tmp/${IPFSNODEID}/ajouter_media.sh/${MOATS}
##
2022-12-02 15:14:19 +01:00
fi
2022-09-04 12:20:55 +02:00
2022-12-15 03:50:40 +01:00
#######################################
########################## TIDDLER JSON READY
#######################################
2023-04-26 21:20:36 +02:00
if [ [ -s ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /${ MEDIAKEY } .dragdrop.json ] ] ; then
2022-12-11 04:13:47 +01:00
espeak "Updating T W"
2022-11-20 12:57:41 +01:00
2022-12-11 04:13:47 +01:00
########################################################################
## ADD TIDDLER TO TW
########################################################################
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
## GETTING LAST TW via IPFS or HTTP GW
2024-04-14 17:37:53 +02:00
LIBRA = $( head -n 2 ${ MY_PATH } /A_boostrap_nodes.txt | tail -n 1 | xargs | cut -d ' ' -f 2)
2023-12-31 15:06:34 +01:00
rm -f ~/.zen/tmp/astronaut_TW.html > /dev/null 2>& 1
2024-04-02 11:49:53 +02:00
[ [ $YOU ] ] \
&& echo " ipfs --timeout 120s cat --progress=false /ipns/ ${ ASTRONAUTENS } ( $YOU ) " \
&& ipfs --timeout 120s cat --progress= false /ipns/${ ASTRONAUTENS } > ~/.zen/tmp/astronaut_TW.html
2023-12-31 15:06:34 +01:00
#~ [[ ! -s ~/.zen/tmp/astronaut_TW.html ]] && echo "curl -m 12 $LIBRA/ipns/${ASTRONAUTENS}" && curl -m 12 -so ~/.zen/tmp/astronaut_TW.html "$LIBRA/ipns/${ASTRONAUTENS}"
[ [ ! -s ~/.zen/tmp/astronaut_TW.html ] ] && espeak "WARNING. WARNING. impossible to find your TW online"
2022-12-11 04:13:47 +01:00
[ [ ! -s ~/.zen/game/players/${ PLAYER } /ipfs/moa/index.html ] ] && espeak "FATAL ERROR. No player TW copy found ! EXIT" && exit 1
## TODO : CHECK CACHE LAST MODIFIED
echo "%%%%%%%%%%%%%% I GOT YOUR TW %%%%%%%%%%%%%%%%%%%%%%%%%%"
2023-12-31 15:06:34 +01:00
[ [ -s ~/.zen/tmp/astronaut_TW.html ] ] \
&& cp -f ~/.zen/tmp/astronaut_TW.html ~/.zen/game/players/${ PLAYER } /ipfs/moa/index.html \
2022-12-15 03:50:40 +01:00
&& espeak "TW Found" \
|| espeak "USING LOCAL COPY"
2022-12-11 04:13:47 +01:00
###############################
2022-11-03 00:24:21 +01:00
2022-12-29 14:51:05 +01:00
echo " Nouveau MEDIAKEY dans TW $PSEUDO / ${ PLAYER } : $myIPFS /ipns/ $ASTRONAUTENS "
2022-11-20 12:57:41 +01:00
tiddlywiki --load ~/.zen/game/players/${ PLAYER } /ipfs/moa/index.html \
2023-04-26 21:20:36 +02:00
--import ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /${ MEDIAKEY } .dragdrop.json "application/json" \
2022-09-04 12:20:55 +02:00
--output ~/.zen/tmp --render " $:/core/save/all " "newindex.html" "text/plain"
if [ [ -s ~/.zen/tmp/newindex.html ] ] ; then
2022-11-20 12:57:41 +01:00
2023-04-14 14:19:20 +02:00
################################################
## UPDATE TW CHAIN WITH PREVIOUSLY RECORDED CHAIN
tiddlywiki --load ~/.zen/tmp/newindex.html \
--output ~/.zen/tmp/${ MOATS } \
--render '.' 'Astroport.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport'
ASTROPORT = $( cat ~/.zen/tmp/${ MOATS } /Astroport.json | jq -r .[ ] .astroport)
CURCHAIN = $( cat ~/.zen/tmp/${ MOATS } /Astroport.json | jq -r .[ ] .chain | rev | cut -f 1 -d '/' | rev) # Remove "/ipfs/" part
[ [ $CURCHAIN = = "" || $CURCHAIN = = "null" ] ] && CURCHAIN = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" # AVOID EMPTY
echo " CURCHAIN= $CURCHAIN "
[ [ -s ~/.zen/game/players/$PLAYER /ipfs/moa/.chain ] ] \
&& ZCHAIN = $( cat ~/.zen/game/players/$PLAYER /ipfs/moa/.chain) \
&& echo " # CHAIN : $CURCHAIN -> $ZCHAIN " \
&& sed -i " s~ $CURCHAIN ~ $ZCHAIN ~g " ~/.zen/tmp/newindex.html
################################################
2023-04-26 21:20:36 +02:00
mv ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /${ MEDIAKEY } .dragdrop.json ~/Astroport/${ PLAYER } /${ CAT } /${ MEDIAID } /${ MOATS } .dragdrop.json
2022-11-20 12:57:41 +01:00
espeak "I P N S Publishing. Please wait..."
2022-11-14 15:24:20 +01:00
cp ~/.zen/tmp/newindex.html ~/.zen/game/players/${ PLAYER } /ipfs/moa/index.html
[ [ $DIFF ] ] && cp ~/.zen/game/players/${ PLAYER } /ipfs/moa/.chain \
~/.zen/game/players/${ PLAYER } /ipfs/moa/.chain.$( cat ~/.zen/game/players/${ PLAYER } /ipfs/moa/.moats)
2022-09-04 12:20:55 +02:00
2022-11-14 15:24:20 +01:00
TW = $( ipfs add -Hq ~/.zen/game/players/${ PLAYER } /ipfs/moa/index.html | tail -n 1)
2022-11-19 17:46:00 +01:00
ipfs name publish --allow-offline -t 24h --key= ${ PLAYER } /ipfs/$TW
2022-09-04 12:20:55 +02:00
2022-11-14 15:24:20 +01:00
[ [ $DIFF ] ] && echo $TW > ~/.zen/game/players/${ PLAYER } /ipfs/moa/.chain
echo ${ MOATS } > ~/.zen/game/players/${ PLAYER } /ipfs/moa/.moats
2022-11-03 00:24:21 +01:00
2023-04-14 14:19:20 +02:00
2022-11-03 00:24:21 +01:00
echo "================================================"
2022-12-29 14:51:05 +01:00
echo " ${ PLAYER } : $myIPFS /ipns/ $ASTRONAUTENS "
2022-11-03 00:24:21 +01:00
echo "================================================"
2022-09-04 12:20:55 +02:00
echo
2022-11-20 12:57:41 +01:00
2024-01-11 16:59:16 +01:00
[ [ $XDG_SESSION_TYPE = = 'x11' || $XDG_SESSION_TYPE = = 'wayland' ] ] && xdg-open " http://ipfs.localhost:8080/ipns/ $ASTRONAUTENS "
2022-12-03 16:54:40 +01:00
2022-11-20 12:57:41 +01:00
else
espeak "Warning. Could not import Tiddler. You must add it by hand."
2022-09-04 12:20:55 +02:00
fi
2022-12-11 04:13:47 +01:00
espeak "OK We did it"
else
espeak "Sorry. No Tiddler found"
fi
2022-12-03 16:54:40 +01:00
end = ` date +%s`
dur = ` expr $end - $start `
2022-12-11 04:13:47 +01:00
espeak " It tooks $dur seconds to acomplish "
2022-10-31 17:22:40 +01:00
2022-09-04 12:20:55 +02:00
exit 0