diff --git a/ASTROBOT/PLAYER.refresh.sh b/ASTROBOT/PLAYER.refresh.sh
index 5eb3390c..f292a35b 100755
--- a/ASTROBOT/PLAYER.refresh.sh
+++ b/ASTROBOT/PLAYER.refresh.sh
@@ -187,7 +187,8 @@ done
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
- [[ $DIFF ]] && cp ~/.zen/game/players/$PLAYER/ipfs/moa/.chain ~/.zen/game/players/$PLAYER/ipfs/moa/.chain.$MOATS
+ [[ $DIFF ]] && cp ~/.zen/game/players/$PLAYER/ipfs/moa/.chain \
+ ~/.zen/game/players/$PLAYER/ipfs/moa/.chain.$(cat ~/.zen/game/players/$PLAYER/ipfs/moa/.moats)
TW=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ipfs/moa/index.html | tail -n 1)
ipfs name publish --allow-offline -t 72h --key=$PLAYER /ipfs/$TW
diff --git a/ASTROBOT/TUBE.copy.sh b/ASTROBOT/TUBE.copy.sh
index 0fb128bc..3e70c3e5 100755
--- a/ASTROBOT/TUBE.copy.sh
+++ b/ASTROBOT/TUBE.copy.sh
@@ -23,40 +23,53 @@ WISHKEY="$2" ## IPNS KEY NAME - G1PUB - PLAYER ...
[[ ! $WISHKEY ]] && echo "Please provide IPFS publish key" && exit 1
TWNS=$(ipfs key list -l | grep -w $WISHKEY | cut -d ' ' -f1)
-# Extract tag=tube from TW into ~/.zen/tmp/tube.json
-rm -f ~/.zen/tmp/tube.json
-tiddlywiki --verbose --load ${INDEX} --output ~/.zen/tmp --render '.' 'tube.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[tube]]'
+# Extract tag=tube from TW into ~/.zen/tmp/$WISHKEY/tube.json
+MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
+mkdir -p ~/.zen/tmp/$WISHKEY
+
+rm -f ~/.zen/tmp/$WISHKEY/tube.json
+tiddlywiki --verbose --load ${INDEX} --output ~/.zen/tmp/$WISHKEY --render '.' 'tube.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[tube]]'
## Extract URL from text field
-for YURL in $(cat ~/.zen/tmp/tube.json | jq -r '.[].text' | grep 'http'); do
+for YURL in $(cat ~/.zen/tmp/$WISHKEY/tube.json | jq -r '.[].text' | grep 'http'); do
echo "Detected $YURL"
- echo "Start Downloading"
-
- mkdir -p ~/.zen/tmp/tube
+ echo "Extracting video playlist"
### GETTING ALL VIDEO IDs (for playlist copy)
- yt-dlp --print "%(id)s" "${YURL}" > ~/.zen/tmp/ytids
+ yt-dlp --print "%(id)s" "${YURL}" >> ~/.zen/tmp/$WISHKEY/ytids.$MOATS
- while read YID;
+done # FINISH YURL loop
+
+###################################################################
+###################################################################
+while read YID;
do
+
+
+ [[ -f ~/.zen/tmp/$WISHKEY/$YID.TW.json ]] && echo "Tiddler json already existing : ~/.zen/tmp/$WISHKEY/$YID.TW.json" && continue
+
# SINGLE VIDEO YURL
ZYURL="https://www.youtube.com/watch?v=$YID";
+ echo "YOUTUBE : $ZYURL"
+
TITLE="$(yt-dlp --print "%(title)s" "${ZYURL}")"
TITLE=${TITLE//[^A-zÀ-ÿ0-9 ]/}
- echo "OK! Going to download $TITLE.mp4 from $ZYURL"
[[ ! $TITLE ]] && continue
+ echo ".... Downloading $TITLE.mp4"
+
# https://github.com/yt-dlp/yt-dlp#format-selection-examples
# SUBS ? --write-subs --write-auto-subs --sub-langs "fr, en, en-orig" --embed-subs
+ # (bv*[height<=720][vcodec~='^((he|a)vc|h26[45])']+ba)
# TODO : DELAY COPY OPERATION... Astro can download quicker at 03:00 AM
- echo "yt-dlp -f \"bv*[ext=mp4][height<=480]+ba/b[height<=480] / bv*[ext=mp4][height<=720]+ba/b[height<=720]\" --no-mtime --embed-thumbnail --add-metadata -o \"$HOME/.zen/tmp/tube/$TITLE.%(ext)s\" ${ZYURL}"
+ echo "yt-dlp -f \"bv*[ext=mp4][height<=480]+ba/b[height<=480] / bv*[ext=mp4][height<=720]+ba/b[height<=720]\" --no-mtime --embed-thumbnail --add-metadata -o \"$HOME/.zen/tmp/$WISHKEY/$TITLE.%(ext)s\" ${ZYURL}"
#############################################################################
## COPY FROM YOUTUBE (TODO DOUBLE COPY & MKV to MP4 OPTIMISATION)
- yt-dlp -f "bv*[ext=mp4][height<=480]+ba/b[height<=480] / bv*[ext=mp4][height<=720]+ba/b[height<=720]" \
+ yt-dlp -f "(bv*[ext=mp4][height<=720]+ba/b[height<=720])" \
-S "filesize:700M" --no-mtime --embed-thumbnail --add-metadata \
--write-subs --write-auto-subs --sub-langs "fr, en, en-orig" --embed-subs \
- -o "$HOME/.zen/tmp/tube/$TITLE.%(ext)s" ${ZYURL}
+ -o "$HOME/.zen/tmp/$WISHKEY/$TITLE.%(ext)s" ${ZYURL}
################################################################################
### ADAPT TO TW RYTHM (DELAY COPY?)
echo
@@ -65,20 +78,24 @@ for YURL in $(cat ~/.zen/tmp/tube.json | jq -r '.[].text' | grep 'http'); do
############################################################################
### CHECK RESULT CONVERT MKV TO MP4
- [[ ! -f "$HOME/.zen/tmp/tube/$ZFILE" ]] && ffmpeg -i "$HOME/.zen/tmp/tube/$TITLE.mkv" -c:v libx264 -c:a aac "$HOME/.zen/tmp/tube/$TITLE.mp4" # TRY TO CONVERT MKV TO MP4
- [[ ! -f "$HOME/.zen/tmp/tube/$ZFILE" ]] && echo "No FILE -- CONTINUE --" && continue
+ [[ ! -f "$HOME/.zen/tmp/$WISHKEY/$ZFILE" ]] && ffmpeg -i "$HOME/.zen/tmp/$WISHKEY/$TITLE.mkv" -c:v libx264 -c:a aac "$HOME/.zen/tmp/$WISHKEY/$TITLE.mp4" # TRY TO CONVERT MKV TO MP4
+ [[ ! -f "$HOME/.zen/tmp/$WISHKEY/$ZFILE" ]] && echo "No FILE -- CONTINUE --" && continue
echo
- echo "FOUND : ~/.zen/tmp/tube/$ZFILE"
+####################################################
+ echo "FOUND : ~/.zen/tmp/$WISHKEY/$ZFILE"
+ FILE_BSIZE=$(du -b "$HOME/.zen/tmp/$WISHKEY/$ZFILE" | awk '{print $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] }')
+ echo "FILE SIZE = $FILE_SIZE ($FILE_BSIZE octets)"
echo "Adding to IPFS"
- ILINK=$(ipfs add -q "$HOME/.zen/tmp/tube/$ZFILE" | tail -n 1)
+ ILINK=$(ipfs add -q "$HOME/.zen/tmp/$WISHKEY/$ZFILE" | tail -n 1)
echo "/ipfs/$ILINK <=> $ZFILE"
- MIME=$(file --mime-type "$HOME/.zen/tmp/tube/$ZFILE" | rev | cut -d ' ' -f 1 | rev)
+ MIME=$(file --mime-type "$HOME/.zen/tmp/$WISHKEY/$ZFILE" | rev | cut -d ' ' -f 1 | rev)
## ADD TAGS
- EXTRATAG=$(yt-dlp --print "crea_%(creator)s chan_%(channel)s sec_%(duration)s list_%(playlist)s" "${ZYURL}")
+ SEC=$(yt-dlp --print "%(duration)s" "${ZYURL}")
## PREPARE VIDEO HTML5 CODE
TEXT="
"
@@ -90,43 +107,40 @@ for YURL in $(cat ~/.zen/tmp/tube.json | jq -r '.[].text' | grep 'http'); do
"title": "'$ZFILE'",
"type": "'text/vnd.tiddlywiki'",
"text": "'$TEXT'",
+ "size": "'${FILE_BSIZE}'",
+ "sec": "'${SEC}'",
"ipfs": "'${ILINK}'",
"youtubeid": "'${YID}'",
"tags": "'ipfs youtube g1tube ${EXTRATAG} ${MIME}'"
}
]
-' > "$HOME/.zen/tmp/tube/$YID.TW.json"
+' > "$HOME/.zen/tmp/$WISHKEY/$YID.TW.json"
- done < ~/.zen/tmp/ytids # FINISH YID loop 1
-
-done # FINISH YURL loop
#################################################################
### ADDING $YID.TW.json to TWNS INDEX.html
#################################################################
-while read YID;
- do
echo "=========================="
echo "Adding $YID tiddler to TW /ipns/$TWNS "
- rm -f ~/.zen/tmp/newindex.html
+ rm -f ~/.zen/tmp/$WISHKEY/newindex.html
- echo ">>> Importing $HOME/.zen/tmp/tube/$YID.TW.json"
+ echo ">>> Importing $HOME/.zen/tmp/$WISHKEY/$YID.TW.json"
tiddlywiki --load $INDEX \
- --import "$HOME/.zen/tmp/tube/$YID.TW.json" "application/json" \
+ --import "$HOME/.zen/tmp/$WISHKEY/$YID.TW.json" "application/json" \
--deletetiddlers '[tag[tube]]' \
- --output ~/.zen/tmp --render "$:/core/save/all" "newindex.html" "text/plain"
+ --output ~/.zen/tmp/$WISHKEY --render "$:/core/save/all" "newindex.html" "text/plain"
- if [[ -s ~/.zen/tmp/newindex.html ]]; then
+ if [[ -s ~/.zen/tmp/$WISHKEY/newindex.html ]]; then
echo "Updating $INDEX"
- cp ~/.zen/tmp/newindex.html $INDEX
+ cp ~/.zen/tmp/$WISHKEY/newindex.html $INDEX
else
- echo "Problem with tiddlywiki command. Missing ~/.zen/tmp/newindex.html"
+ echo "Problem with tiddlywiki command. Missing ~/.zen/tmp/$WISHKEY/newindex.html"
echo "XXXXXXXXXXXXXXXXXXXXXXX"
fi
-done < ~/.zen/tmp/ytids # FINISH YID loop 2
+done < ~/.zen/tmp/$WISHKEY/ytids.$MOATS # FINISH YID loop 1
## FINAL TW IPNS PUBLISHING
echo "ipfs name publish -k $WISHKEY ($INDEX)"
diff --git a/ASTROBOT/VOEUX.refresh.sh b/ASTROBOT/VOEUX.refresh.sh
index 3f028818..9e16644b 100755
--- a/ASTROBOT/VOEUX.refresh.sh
+++ b/ASTROBOT/VOEUX.refresh.sh
@@ -9,85 +9,76 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
################################################################################
# Inspect game wishes, refresh latest IPNS version
-# Backup and chain
+# SubProcess Backup and chain
-[[ $PLAYER == "" ]] && PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null)
############################################
echo "## WORLD VOEUX"
+myIP=$(hostname -I | awk '{print $1}' | head -n 1)
-for v in $(cat ~/.zen/game/players/*/voeux/*/.title); do echo $v ;done
+for v in $(cat ~/.zen/game/players/*/VOEUx/*/.title); do echo $v ;done
-for voeu in $(ls ~/.zen/game/world/);
+for VOEU in $(ls ~/.zen/game/world/);
do
- echo "VOEU : $voeu"
- voeuns=$(ipfs key list -l | grep $voeu | cut -d ' ' -f1)
- echo "http://127.0.0.1:8080/ipns/$voeuns"
- echo
- W=$(cat ~/.zen/game/world/$voeu/.pepper 2>/dev/null)
- echo $W
-
+ ## CLEAN OLD CACHE
rm -Rf ~/.zen/tmp/work
mkdir -p ~/.zen/tmp/work
+ echo "==============================="
+ echo "VOEU : $VOEU"
+ VOEUNS=$(ipfs key list -l | grep $VOEU | cut -d ' ' -f1)
+ WISHNAME=$(cat ~/.zen/game/world/$VOEU/.pepper 2>/dev/null)
+ echo "$WISHNAME"
+ echo "==============================="
- echo "Getting latest online TW..."
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
- echo "$LIBRA/ipns/$voeuns"
- [[ $YOU ]] && ipfs --timeout 12s cat /ipns/$voeuns > ~/.zen/tmp/work/index.html \
- || curl -m 12 -so ~/.zen/tmp/work/index.html "$LIBRA/ipns/$voeuns"
+ echo "$LIBRA/ipns/$VOEUNS"
+ echo "http://$myIP:8080/ipns/$VOEUNS"
+ echo "Getting latest online TW..."
+ [[ $YOU ]] && ipfs --timeout 12s cat /ipns/$VOEUNS > ~/.zen/tmp/work/index.html \
+ || curl -m 12 -so ~/.zen/tmp/work/index.html "$LIBRA/ipns/$VOEUNS"
if [[ ! -s ~/.zen/tmp/work/index.html ]]; then
- echo "UNAVAILABLE WISH! If you want to remove $W $voeu"
- echo "ipfs key rm $voeu && rm -Rf ~/.zen/game/world/$voeu"
+ echo "UNAVAILABLE WISH! If you want to remove $WISHNAME $VOEU"
+ echo "ipfs key rm $VOEU && rm -Rf ~/.zen/game/world/$VOEU"
+ echo "============================================="
+ echo "ipfs name publish -t 72h /ipfs/$(cat ~/.zen/game/world/$VOEU/.chain)"
echo "============================================="
- echo "ipfs name publish -t 72h /ipfs/$(cat ~/.zen/game/world/$voeu/.chain)"
continue
else
- ## Replace tube links with downloaded video
- $MY_PATH/TUBE.copy.sh ~/.zen/tmp/work/index.html $voeu
+ echo "SEARCH VOEU TW FOR tag=tube"
+ ## TAG="tube" tiddler => Dowload youtube video links (playlist accepted) ## WISHKEY=G1PUB !
+ $MY_PATH/TUBE.copy.sh ~/.zen/tmp/work/index.html $VOEU
- ## LAN TO WAN MIGRATION
- myIP=$(hostname -I | awk '{print $1}' | head -n 1)
- sed -i "s~192.168.199.191~${myIP}~g" ~/.zen/tmp/work/index.html
- echo $myIP > ~/.zen/game/world/$voeu/.myIP
- echo "Setting new IP : $myIP"
+ echo "NEXT SEARCH Ŋ1 FRIENDS TW's FOR tag=$WISHNAME"
echo "DIFFERENCE ?"
- DIFF=$(diff ~/.zen/tmp/work/index.html ~/.zen/game/world/$voeu/index.html)
+ DIFF=$(diff ~/.zen/tmp/work/index.html ~/.zen/game/world/$VOEU/index.html)
if [[ $DIFF ]]; then
- echo "Backup & Upgrade TW local copy..."
- cp -f ~/.zen/game/world/$voeu/index.html ~/.zen/game/world/$voeu/index.backup.html
- cp ~/.zen/tmp/work/index.html ~/.zen/game/world/$voeu/index.html
+ echo "Upgrade TW local copy..."
+ cp ~/.zen/tmp/work/index.html ~/.zen/game/world/$VOEU/index.html
else
echo "No change since last Refresh"
fi
fi
- # RECORDING BLOCKCHAIN TIC
+ # RECORDING CHANGES
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
- [[ $DIFF ]] && cp ~/.zen/game/world/$voeu/.chain ~/.zen/game/world/$voeu/.chain.$MOATS
+ [[ $DIFF ]] && cp ~/.zen/game/world/$VOEU/.chain \
+ ~/.zen/game/world/$VOEU/.chain.$(cat ~/.zen/game/world/$VOEU/.moats)
- IPUSH=$(ipfs add -Hq ~/.zen/game/world/$voeu/index.html | tail -n 1)
- ipfs name publish -t 72h --key=${voeu} /ipfs/$IPUSH 2>/dev/null
+ # PUBLISH VOEU TW
+ IPUSH=$(ipfs add -Hq ~/.zen/game/world/$VOEU/index.html | tail -n 1)
+ ipfs name publish -t 72h --key=${VOEU} /ipfs/$IPUSH 2>/dev/null
- [[ $DIFF ]] && echo $IPUSH > ~/.zen/game/world/$voeu/.chain
- echo $MOATS > ~/.zen/game/world/$voeu/.moats
+ [[ $DIFF ]] && echo $IPUSH > ~/.zen/game/world/$VOEU/.chain; \
+ echo $MOATS > ~/.zen/game/world/$VOEU/.moats
rm -Rf ~/.zen/tmp/work
-# if [[ -d ~/.zen/game/players/$PLAYER/voeux/$voeu ]]; then
-# echo "==========================="
-# echo "Voeu$W : commande de suppression"
-# echo "ipfs key rm $voeu
-# rm -Rf ~/.zen/game/world/$voeu
-# rm -Rf ~/.zen/game/players/$PLAYER/voeux/$voeu"
-# echo "==========================="
-# fi
-
echo "================================================"
- echo "$W : http://127.0.0.1:8080/ipns/$voeuns"
+ echo "$WISHNAME : http://$myIP:8080/ipns/$VOEUNS"
echo "================================================"
done