This commit is contained in:
fred 2022-11-29 16:39:58 +01:00
parent 9a552f92b6
commit 1124db1837
4 changed files with 53 additions and 33 deletions

View File

@ -17,7 +17,8 @@ echo "$ME RUNNING"
# ASTROBOT FIRST PROCESS
# "Copier youtube" + (voeu) => CopierYoutube (G1Voeu G1CopierYoutube) = ASTROBOT copy Ŋ1 "(G1CopierYoutube)"
IPFSNODEID=$(ipfs id -f='<id>\n')
# IPFSNODEID=$(ipfs id -f='<id>\n')
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID)
INDEX="$1"
[[ ! $INDEX ]] && echo "ERROR - Please provide path to source TW index.html" && exit 1
@ -90,11 +91,12 @@ cp ~/.zen/tmp/yt-dlp.cache ~/.zen/tmp/$IPFSNODEID/yt-dlp.cache.$WISHKEY
while read LINE;
do
YID=$(echo "$LINE" | cut -d '&' -f 2)
YID=$(echo "$LINE" | cut -d '&' -f 1)
[[ -s ~/.zen/tmp/$IPFSNODEID/$YID.TW.json ]] && echo "Tiddler json already existing : ~/.zen/tmp/$IPFSNODEID/$YID.TW.json" && continue ## TODO :: CHECK IF ALREADY YOURS OR NOT :: THEN ADD2TW / SEND MESSAGE ?
# SINGLE VIDEO YURL
ZYURL=$(echo "$LINE" | cut -d '&' -f 3-)
ZYURL=$(echo "$LINE" | cut -d '&' -f 2-)
echo "COPIE : $ZYURL"
TITLE="$(yt-dlp --print "%(title)s" "${ZYURL}")"
@ -137,6 +139,22 @@ while read LINE;
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)"
#~ ## PREPARE FOR new_file_in_astroport.sh
#~ mkdir -p "$HOME/Astroport/youtube/$YID"
#~ REVSOURCE="$(echo "$ZYURL" | awk -F/ '{print $3}' | rev)_"
#~ MEDIAID="$REVSOURCE${YID}"
#~ URLENCODE_FILE_NAME=$(echo ${ZFILE} | jq -Rr @uri)
#~ echo "youtube;${MEDIAID};$(date -u +%s%N | cut -b1-13);${TITLE};${SAISON};${GENRES};_IPNSKEY_;${RES};/ipfs/_IPFSREPFILEID_/$URLENCODE_FILE_NAME" > ~/Astroport/youtube/$YID/ajouter_video.txt
#~ mv "$HOME/.zen/tmp/yt-dlp/$ZFILE" "$HOME/Astroport/youtube/$YID/"
###
#~ ${MY_PATH}/../tools/new_file_in_astroport.sh "$HOME/Astroport/youtube/$YID" "${ZFILE}" "$G1PUB"
path="$HOME/.zen/tmp/yt-dlp"
file="$ZFILE"
$(${MY_PATH}/../tools/make_video_gifanim_ipfs.sh "$path" "$file" | tail -n 1)
echo "/ipfs/$ANIMH"
## Create gifanime ## TODO Search for similarities BEFORE ADD
echo "Adding to IPFS"
ILINK=$(ipfs add -q "$HOME/.zen/tmp/yt-dlp/$ZFILE" | tail -n 1)
echo "/ipfs/$ILINK <=> $ZFILE"
@ -149,7 +167,7 @@ while read LINE;
PLAYLIST=$(yt-dlp --print "%(playlist)s" "${ZYURL}" | sed -r 's/\<./\U&/g' | sed 's/ //g')
EXTRATAG="$CHANNEL $PLAYLIST"
## PREPARE VIDEO HTML5 CODE
TEXT="<video controls width=100%><source src='/ipfs/"${ILINK}"' type='"${MIME}"'></video><h1><a href='"${ZYURL}"'>"${TITLE}"</a></h1>"
TEXT="<video controls width=100% poster='/ipfs/"${ANIMH}"'><source src='/ipfs/"${ILINK}"' type='"${MIME}"'></video><h1><a href='"${ZYURL}"'>"${TITLE}"</a></h1>"
echo "Creating Youtube ${YID} tiddler : G1CopierYoutube !"
echo $TEXT
@ -157,11 +175,16 @@ while read LINE;
echo '[
{
"created": "'${MOATS}'",
"resolution": "'${RES}'",
"duree": "'${DUREE}'",
"duration": "'${DURATION}'",
"giftime": "'${PROBETIME}'",
"gifanime": "'/ipfs/${ANIMH}'",
"modified": "'${MOATS}'",
"title": "'$ZFILE'",
"type": "'text/vnd.tiddlywiki'",
"text": "'$TEXT'",
"mime": "'$MIME'",
"mime": "'${MIME}'",
"size": "'${FILE_BSIZE}'",
"sec": "'${SEC}'",
"ipfs": "'/ipfs/${ILINK}'",

View File

@ -20,9 +20,9 @@ for PLAYER in $(ls -t ~/.zen/game/players/); do
echo "##################################################################"
echo ">>>>> PLAYER : $PLAYER >>>>>>>>>>>>> REFRESHING TW STATION"
echo "##################################################################"
# Get PLAYER wallet amount
COINS=$($MY_PATH/../tools/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey balance)
echo "+++ WALLET BALANCE _ $COINS (G1) _"
#~ # Get PLAYER wallet amount
#~ COINS=$($MY_PATH/../tools/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey balance)
#~ echo "+++ WALLET BALANCE _ $COINS (G1) _"
## DROP IF WALLET IS EMPTY : TODO
echo "##################################################################"
echo "##################################################################"
@ -71,8 +71,8 @@ isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(
echo "MANUAL PROCEDURE NEEDED"
echo "------------------------------------------------"
echo "http://$myIP:8080/ipfs/"
cat ~/.zen/game/players/$PLAYER/ipfs/moa/.chain.*
echo "ipfs name publish -t 24h --key=$PLAYER /ipfs/"
echo "/ipfs/"$(cat ~/.zen/game/players/$PLAYER/ipfs/moa/.chain.* | tail -n 1)
echo "ipfs name publish -t 24h --key=$PLAYER ..."
echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
continue

View File

@ -30,18 +30,28 @@ ME="${0##*/}"
# Check who is .current PLAYER
PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null)
[[ ${PLAYER} == "" ]] && espeak "ERROR CONNECT YOUR PLAYER - EXIT" && exit 1
PSEUDO=$(cat ~/.zen/game/players/.current/.pseudo 2>/dev/null)
G1PUB=$(cat ~/.zen/game/players/.current/.g1pub 2>/dev/null)
[[ ${PLAYER} == "" ]] \
&& espeak "ERROR NO CONNECTED PLAYER" \
&& OUTPUT=$(zenity --forms --width 480 --title="CONNEXION" --text="Vos Clés ?" --separator="~" --add-entry="Phrase 1" --add-entry="Phrase 2") \
&& SALT=$(awk -F '~' '{print $1}' <<<$OUTPUT) \
&& PEPPER=$(awk -F '~' '{print $2}' <<<$OUTPUT) \
&& PLAYER=$(zenity --entry --width 300 --title "PLAYER" --text "Indiquez votre email" --entry-text="")
[[ ${PLAYER} == "" ]] && exit 1
PSEUDO=$(cat ~/.zen/game/players/${PLAYER}/.pseudo 2>/dev/null)
G1PUB=$(cat ~/.zen/game/players/${PLAYER}/.g1pub 2>/dev/null)
[[ $G1PUB == "" ]] && espeak "ERROR NO G1 PUBLIC KEY FOUND - EXIT" && exit 1
PLAYERNS=$(cat ~/.zen/game/players/.current/.playerns 2>/dev/null) || ( echo "noplayerns" && exit 1 )
PLAYERNS=$(cat ~/.zen/game/players/${PLAYER}/.playerns 2>/dev/null) || ( echo "noplayerns" && exit 1 )
ASTRONAUTENS=$(ipfs key list -l | grep -w "${PLAYER}" | cut -d ' ' -f 1)
[[ $ASTRONAUTENS == "" ]] && echo "ASTRONAUTE manquant" && espeak "Astronaut Key Missing" && exit 1
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID)
myIP=$(hostname -I | awk '{print $1}' | head -n 1)
isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost"
@ -71,7 +81,7 @@ haut=$((height-200))
########################################################################
## CADRE EXCEPTION COPIE PRIVE
# https://www.legifrance.gouv.fr/codes/article_lc/LEGIARTI000006278917/2008-12-11/
if [[ ! -f ~/.zen/game/players/.current/legal ]]; then
if [[ ! -f ~/.zen/game/players/${PLAYER}/legal ]]; then
zenity --width ${large} --height=${haut} --text-info \
--title="Action conforme avec le Code de la propriété intellectuelle" \
--html \
@ -81,12 +91,12 @@ zenity --width ${large} --height=${haut} --text-info \
case $? in
0)
echo "AUTORISATION COPIE PRIVE ASTROPORT OK !"
echo "$G1PUB" > ~/.zen/game/players/.current/legal
echo "$G1PUB" > ~/.zen/game/players/${PLAYER}/legal
# next step
;;
1)
echo "Refus conditions"
rm -f ~/.zen/game/players/.current/legal
rm -f ~/.zen/game/players/${PLAYER}/legal
exit 1
;;
-1)
@ -669,7 +679,7 @@ chmod +x ~/Astroport/Add_${MEDIAKEY}_script.sh
########################################################################
## USE PLAYER G1PUB AS MEDIA WALLET
MEDIAPUBKEY=$(cat ~/.zen/game/players/.current/.g1pub)
MEDIAPUBKEY=$(cat ~/.zen/game/players/${PLAYER}/.g1pub)
G1BALANCE=$(${MY_PATH}/tools/jaklis/jaklis.py balance -p $G1PUB 2>/dev/null )
########################################################################

View File

@ -69,23 +69,10 @@ MIME=$(file --mime-type -b "${path}${file}")
############# EXTEND MEDIAKEY IDENTIFATORS https://github.com/NapoleonWils0n/ffmpeg-scripts
if [[ $(echo "$MIME" | grep 'video') ]]; then
FILE_RES=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "${path}${file}" | cut -d "x" -f 2)
RES=${FILE_RES%?}0p
DURATION=$(ffprobe -i "${path}${file}" -show_entries format=duration -v quiet -of csv="p=0" | cut -d '.' -f 1)
DUREE=$(ffprobe -i "${path}${file}" -show_entries format=duration -sexagesimal -v quiet -of csv="p=0"| cut -d '.' -f 1)
PROBETIME=$(echo "0.618 * $DURATION" | bc -l | cut -d '.' -f 1)
[[ ! $PROBETIME ]] && PROBETIME="1.0"
## Create gifanime ## TODO Search for similarities BEFORE ADD
echo "(✜‿‿✜) GIFANIME (✜‿‿✜)"
rm -f ~/.zen/tmp/screen.gif
ffmpeg -loglevel quiet -ss $PROBETIME -t 1.6 -loglevel quiet -i "${path}${file}" ~/.zen/tmp/screen.gif
ANIMH=$(ipfs add -q ~/.zen/tmp/screen.gif)
echo "GIFANIM $PROBETIME : /ipfs/$ANIMH"
$(${MY_PATH}/make_video_gifanim_ipfs.sh "$path" "$file" | tail -n 1)
echo "$DUREE GIFANIM ($PROBETIME) : /ipfs/$ANIMH"
fi
########################################################################