Astro le petit robot amical
This commit is contained in:
parent
b2e566410f
commit
4a7a9f7ec6
@ -82,7 +82,9 @@ do
|
||||
|
||||
echo "# CREATION TW"
|
||||
##########################################################################################
|
||||
# ipfs cat /ipfs/bafybeierk6mgrlwpowdcfpvibujhg2b6upjfl3gryw2k72f7smxt6cqtiu > ~/.zen/Astroport.ONE/templates/twdefault.html
|
||||
# ipfs key import _MEDIAKEY_ ~/.zen/Astroport.ONE/templates/_MEDIAKEY_.keystore.key
|
||||
##############
|
||||
# ipfs cat /ipfs/bafybeidi66vug7jl6lj2zxnhdd5ux27udo64yyl5kq7tehsmdvcg4675ay > ~/.zen/Astroport.ONE/templates/twdefault.html
|
||||
##########################################################################################
|
||||
cp ~/.zen/Astroport.ONE/templates/twdefault.html ~/.zen/game/world/$WISHKEY/index.html
|
||||
|
||||
@ -97,7 +99,7 @@ do
|
||||
|
||||
# IPNS KEY is WISHKEY / VOEUXNS
|
||||
sed -i "s~_MEDIAKEY_~${WISHKEY}~g" ~/.zen/game/world/$WISHKEY/index.html
|
||||
sed -i "s~k2k4r8naeti1ny2hsk3a0ziwz22urwiu633hauluwopf4vwjk4x68qgk~${VOEUXNS}~g" ~/.zen/game/world/$WISHKEY/index.html
|
||||
sed -i "s~k2k4r8kxfnknsdf7tpyc46ks2jb3s9uvd3lqtcv9xlq9rsoem7jajd75~${VOEUXNS}~g" ~/.zen/game/world/$WISHKEY/index.html
|
||||
# ASTROPORT LOCAL IP RELAY == Smartphone doesn't resolve LAN DNS. So using Astroport Station IP
|
||||
sed -i "s~ipfs.infura.io~tube.copylaradio.com~g" ~/.zen/game/world/$WISHKEY/index.html
|
||||
sed -i "s~127.0.0.1~$myIP~g" ~/.zen/game/world/$WISHKEY/index.html
|
||||
|
674
ajouter_video.sh
Executable file
674
ajouter_video.sh
Executable file
@ -0,0 +1,674 @@
|
||||
#!/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
|
||||
ME="${0##*/}"
|
||||
|
||||
########################################################################
|
||||
[[ $(which ipfs) == "" ]] && echo "ERREUR! Installez ipfs" && echo "wget https://git.p2p.legal/axiom-team/astrXbian/raw/master/.install/ipfs_alone.sh -O /tmp/ipfs_install.sh && chmod +x /tmp/ipfs_install.sh && /tmp/ipfs_install.sh" && exit 1
|
||||
[[ $(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
|
||||
|
||||
# Check who is .current PLAYER
|
||||
PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null) || ( echo "noplayer" && exit 1 )
|
||||
PSEUDO=$(cat ~/.zen/game/players/.current/.pseudo 2>/dev/null) || ( echo "nopseudo" && exit 1 )
|
||||
G1PUB=$(cat ~/.zen/game/players/.current/.g1pub 2>/dev/null) || ( echo "nog1pub" && exit 1 )
|
||||
PLAYERNS=$(cat ~/.zen/game/players/.current/.playerns 2>/dev/null) || ( echo "noplayerns" && exit 1 )
|
||||
|
||||
ASTRONAUTENS=$(ipfs key list -l | grep -w "${PLAYER}" | cut -d ' ' -f 1)
|
||||
[[ $ASTRONAUTENS == "" ]] && echo "ASTRONAUTE manquant" && exit 1
|
||||
|
||||
URL="$1"
|
||||
if [ $URL ]; then
|
||||
echo "URL: $URL"
|
||||
REVSOURCE="$(echo "$URL" | awk -F/ '{print $3}' | rev)_"
|
||||
[ ! $2 ] && IMPORT=$(zenity --entry --width 640 --title="$URL => Astroport" --text="Que copier depuis cette source ?" --entry-text="Video" MP3 Web) || IMPORT="Youtube"
|
||||
[[ $IMPORT == "Video" ]] && IMPORT="Youtube"
|
||||
CHOICE="$IMPORT"
|
||||
fi
|
||||
|
||||
[[ $CHOICE == "Web" ]] && CHOICE="Page" #&& CHOICE=$(zenity --entry --width 640 --title="$URL => Astroport" --text="Cette source Web est à enregistrer comme " --entry-text="Page" WebSite)
|
||||
|
||||
# REMOVE GtkDialog errors for zenity
|
||||
shopt -s expand_aliases
|
||||
alias zenity='zenity 2> >(grep -v GtkDialog >&2)'
|
||||
|
||||
# GET SCREEN DIMENSIONS
|
||||
screen=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/')
|
||||
width=$(echo $screen | cut -d 'x' -f 1)
|
||||
height=$(echo $screen | cut -d 'x' -f 2)
|
||||
large=$((width-300))
|
||||
haut=$((height-200))
|
||||
|
||||
########################################################################
|
||||
PLAYER=$(cat ~/.zen/game/players/.current/.player)
|
||||
|
||||
########################################################################
|
||||
## CADRE EXCEPTION COPIE PRIVE
|
||||
# https://www.legifrance.gouv.fr/codes/article_lc/LEGIARTI000006278917/2008-12-11/
|
||||
if [[ ! -f ~/.zen/game/players/.current/legal ]]; then
|
||||
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 !"
|
||||
echo "$G1PUB" > ~/.zen/game/players/.current/legal
|
||||
# next step
|
||||
;;
|
||||
1)
|
||||
echo "Refus conditions"
|
||||
rm -f ~/.zen/game/players/.current/legal
|
||||
exit 1
|
||||
;;
|
||||
-1)
|
||||
echo "Erreur."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
## CHECK IF ASTROPORT/CRON/IPFS IS RUNNING
|
||||
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
|
||||
[[ ! $YOU ]] && RUN=$(zenity --entry --width 300 --title="Astroport IPFS OFF" --text="Activer Astroport ?" --entry-text="OUI" NON) && [[ $RUN == "" || $RUN == "NON" ]] && exit 1
|
||||
[[ $YOU && ! $1 ]] && RUN=$(zenity --entry --width 300 --title="Astroport IPFS ON" --text="Désactiver Astroport ? Non, vous voulez ajouter un Media?" --entry-text="OUI" NON)
|
||||
## DES/ACTIVATION ASTROPORT
|
||||
if [[ $RUN == "OUI" ]]; then
|
||||
STRAP=$(ipfs bootstrap)
|
||||
BOOT=$(zenity --entry --width 300 --title="Catégorie" --text="$STRAP Changez de Bootstrap" --entry-text="Aucun" astrXbian Public)
|
||||
[[ $BOOT == "Aucun" ]] && ipfs bootstrap rm --all
|
||||
[[ $BOOT == "astrXbian" ]] && for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#"); do ipfs bootstrap add $bootnode; done
|
||||
[[ $BOOT == "Public" ]] && for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_public.txt | grep -Ev "#"); do ipfs bootstrap add $bootnode; done
|
||||
REP=$(~/.zen/Astroport.ONE/tools/cron_VRFY.sh) && zenity --warning --width 600 --text "$REP"
|
||||
fi
|
||||
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
|
||||
[[ $YOU == "" ]] && echo "IPFS not running" && exit 1
|
||||
|
||||
########################################################################
|
||||
# CHOOSE CATEGORY (remove anime, not working!)
|
||||
[[ $CHOICE == "" ]] && CHOICE=$(zenity --entry --width 300 --title="Catégorie" --text="Choisissez la catégorie de votre ajout" --entry-text="Film" Serie Youtube AstroBlog Video)
|
||||
[[ $CHOICE == "" ]] && exit 1
|
||||
|
||||
# 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
|
||||
########################################################################
|
||||
# CASE ## ASTRONAUTE
|
||||
# _ _
|
||||
# __ _ ___| |_ _ __ ___ _ __ __ _ _ _| |_ ___
|
||||
# / _` / __| __| '__/ _ \| '_ \ / _` | | | | __/ _ \
|
||||
# | (_| \__ \ |_| | | (_) | | | | (_| | |_| | || __/
|
||||
# \__,_|___/\__|_| \___/|_| |_|\__,_|\__,_|\__\___|
|
||||
#
|
||||
#
|
||||
########################################################################
|
||||
astroblog)
|
||||
|
||||
# INSTASCAN G1PUB CAPTURE
|
||||
~/.zen/Astroport.ONE/tools/instascan_login.sh "ONE"
|
||||
|
||||
zenity --warning --width 300 --text "$PLAYER. Prêt à enregistrer votre video ?"
|
||||
|
||||
## RECORD WEBCAM VIDEO
|
||||
~/.zen/Astroport.ONE/tools/vlc_webcam.sh
|
||||
|
||||
|
||||
exit 0
|
||||
;;
|
||||
########################################################################
|
||||
# CASE ## YOUTUBE
|
||||
# _ _
|
||||
# _ _ ___ _ _| |_ _ _| |__ ___
|
||||
#| | | |/ _ \| | | | __| | | | '_ \ / _ \
|
||||
#| |_| | (_) | |_| | |_| |_| | |_) | __/
|
||||
# \__, |\___/ \__,_|\__|\__,_|_.__/ \___|
|
||||
# |___/
|
||||
########################################################################
|
||||
youtube)
|
||||
|
||||
YTURL="$URL"
|
||||
[[ $YTURL == "" ]] && YTURL=$(zenity --entry --width 300 --title "Lien ou identifiant à copier" --text "Indiquez le lien (URL) ou l'ID de la vidéo" --entry-text="")
|
||||
[[ $YTURL == "" ]] && exit 1
|
||||
|
||||
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"
|
||||
|
||||
/usr/local/bin/youtube-dl -f '[ext=mp4]+best[height<=480]+[filesize<300M]' \
|
||||
--no-playlist --write-info-json \
|
||||
--no-mtime -o "${YTEMP}/%(id)s&%(title)s.%(ext)s" $YTURL
|
||||
|
||||
# Get filename, extract ID, make destination dir and move copy.
|
||||
YFILE=$(ls -S ${YTEMP} | head -n 1)
|
||||
FILE_NAME="$(basename "${YFILE}")"
|
||||
FILE_EXT="${FILE_NAME##*.}"
|
||||
|
||||
JSON_FILE=$(echo ${FILE_NAME} | sed "s/${FILE_EXT}/json/g")
|
||||
|
||||
YID=$(echo "${FILE_NAME}" | cut -d "&" -f 1)
|
||||
YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | sed "s/[(][^)]*[)]//g" | sed -e 's/[^A-Za-z0-9._-]/_/g' | sed -e 's/__/_/g' ) # Remove YoutubeID_ and (what is in perentheses)
|
||||
[[ $(which detox) ]] && YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | detox --inline)
|
||||
MEDIAID="$REVSOURCE${YID}"
|
||||
TITLE="${YNAME%.*}"
|
||||
MEDIAKEY="YOUTUBE_${MEDIAID}"
|
||||
## CORRECT PARAMETERS to Make Kodi compatible YASTRXBIAN FILE
|
||||
|
||||
[ ! $2 ] && GENRES=$(zenity --list --checklist --title="GENRE" --height=${haut} \
|
||||
--text="Choisissez le(s) genre(s) d'information(s) contenue(s) dans cette vidéo \"${TITLE}\" publiée sur OASIS" \
|
||||
--column="Use" \
|
||||
--column="Feature" \
|
||||
FALSE Savoir \
|
||||
FALSE Nature \
|
||||
FALSE Habiter \
|
||||
FALSE Nourrir \
|
||||
FALSE Deplacer \
|
||||
FALSE Guerir \
|
||||
FALSE Divertir \
|
||||
FALSE Musique \
|
||||
FALSE DIY \
|
||||
FALSE Science \
|
||||
FALSE Humain \
|
||||
FALSE Animal \
|
||||
TRUE Eveil \
|
||||
TRUE ${PLAYER// /-}) || GENRES="${PLAYER// /-}"
|
||||
|
||||
# FORMAT GENRES genre1|genre2|genre3
|
||||
|
||||
FILE_PATH="$HOME/astroport/youtube/$MEDIAID"
|
||||
mkdir -p ${FILE_PATH} && mv -f ${YTEMP}/* ${FILE_PATH}/
|
||||
# rename FILE_NAME to YNAME (URL clean)
|
||||
mv "${FILE_PATH}/${FILE_NAME}" "${FILE_PATH}/${YNAME}" && FILE_NAME="${YNAME}"
|
||||
# get & rename video.json
|
||||
jsonfile=$(ls ${FILE_PATH}/*.json)
|
||||
mv "${jsonfile}" "${FILE_PATH}/video.json"
|
||||
|
||||
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
|
||||
|
||||
## CREATE "~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt" and video.json
|
||||
URLENCODE_FILE_NAME=$(echo ${FILE_NAME} | jq -Rr @uri)
|
||||
|
||||
## KEEPS KODI COMPATIBILITY (BROKEN astroport.py !! ) : TODO DEBUG
|
||||
echo "youtube;${MEDIAID};$(date -u +%s%N | cut -b1-13);${TITLE};${SAISON};${GENRES};_IPNSKEY_;${RES};/ipfs/_IPFSREPFILEID_/$URLENCODE_FILE_NAME" > ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt
|
||||
|
||||
# _IPFSREPFILEID_ is replaced later
|
||||
|
||||
rm -Rf ${YTEMP}
|
||||
|
||||
;;
|
||||
|
||||
########################################################################
|
||||
# CASE ## WEB
|
||||
web)
|
||||
|
||||
## wget current URL -> index.html ## TEST ## TEST httrack ??
|
||||
[[ ! $(which httrack) ]] && zenity --warning --width ${large} --text "Utilitaire de copie de site web absent.. Lancez la commande 'sudo apt install httrack'" && exit 1
|
||||
echo "httrack --mirror $URL" # TODO : FOR NOW NOT WORKING
|
||||
FILE_NAME="index.html"
|
||||
REVSOURCE="$(echo "$URL" | rev | sha256sum | cut -d ' ' -f 1)_"; echo $REVSOURCE # URL="https://discuss.ipfs.io/t/limit-ipfs-get-command/3573/6"
|
||||
MEDIAID="$REVSOURCE" # MEDIAID=1252ff59950395070a0cc56bb058cbb1ccfd2f8d8a32476acaf472f62b14d97d_
|
||||
MEDIAKEY="WWW_${MEDIAID}" # MEDIAKEY=PAGE_1252ff59950395070a0cc56bb058cbb1ccfd2f8d8a32476acaf472f62b14d97d_
|
||||
FILE_PATH="$HOME/astroport/web/$MEDIAID";
|
||||
mkdir -p $FILE_PATH
|
||||
|
||||
wget -mpck --user-agent="" -e robots=off --wait 1 "$URL" > ${FILE_PATH}/
|
||||
|
||||
echo "web;${MEDIAID};$(date -u +%s%N | cut -b1-13);${TITLE};${SAISON};${GENRES};_IPNSKEY_;${RES};/ipfs/_IPFSREPFILEID_/$FILE_NAME" > ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt
|
||||
|
||||
zenity --warning --width ${large} --text "Vérifiez que la copie de votre site se trouve bien dans ${FILE_PATH}/"
|
||||
|
||||
;;
|
||||
|
||||
|
||||
########################################################################
|
||||
# CASE ## PAGE
|
||||
page)
|
||||
|
||||
## record one page to PDF
|
||||
[[ ! $(which chromium) ]] && zenity --warning --width ${large} --text "Utilitaire de copie de page web absent.. Lancez la commande 'sudo apt install chromium'" && exit 1
|
||||
cd /tmp/ && rm -f output.pdf
|
||||
chromium --headless --no-sandbox --print-to-pdf $URL
|
||||
|
||||
TITLE=$(zenity --entry --width 480 --title "Titre" --text "Quel nom de fichier à donner à cette page ? " --entry-text="${URL}")
|
||||
[[ $TITLE == "" ]] && exit 1
|
||||
FILE_NAME="$(echo "${TITLE}" | detox --inline).pdf" ## TODO make it better
|
||||
|
||||
MEDIAID="$REVSOURCE$(echo "${TITLE}" | detox --inline)"
|
||||
MEDIAKEY="PAGE_${MEDIAID}"
|
||||
FILE_PATH="$HOME/astroport/page/$MEDIAID"
|
||||
mkdir -p ${FILE_PATH} && mv output.pdf ${FILE_PATH}/${FILE_NAME}
|
||||
|
||||
echo "page;${MEDIAID};$(date -u +%s%N | cut -b1-13);${TITLE};${SAISON};${GENRES};_IPNSKEY_;${RES};/ipfs/_IPFSREPFILEID_/$FILE_NAME" > ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt
|
||||
|
||||
;;
|
||||
|
||||
########################################################################
|
||||
# CASE ## MP3
|
||||
# _____
|
||||
# _ __ ___ _ __|___ /
|
||||
#| '_ ` _ \| '_ \ |_ \
|
||||
#| | | | | | |_) |__) |
|
||||
#|_| |_| |_| .__/____/
|
||||
# |_|
|
||||
########################################################################
|
||||
mp3)
|
||||
|
||||
zenity --warning --width 600 --text 'WARNING. HEAVY DEBUG ZONE . Join us at https://git.p2p.legal'
|
||||
|
||||
# Create TEMP directory
|
||||
YTEMP="$HOME/.zen/tmp/$(date -u +%s%N | cut -b1-13)"
|
||||
mkdir -p ${YTEMP}
|
||||
|
||||
artist=$(zenity --entry --width 400 --title "Extraction MP3 depuis Youtube" --text "Artiste recherché ou Lien Youtube" --entry-text="")
|
||||
[[ $artist == "" ]] && exit 1
|
||||
|
||||
## CHECK if artist is LINK or ID
|
||||
length=${#artist}
|
||||
islink=$(echo "$artist" | grep "http")
|
||||
if [[ ! $islink && $length != 11 ]]
|
||||
then
|
||||
# Ask for song name
|
||||
song=$(zenity --entry --width 300 --title "Titre à chercher sur Youtube" --text "Titre recherché" --entry-text="")
|
||||
[[ $song == "" ]] && exit 1
|
||||
else
|
||||
song=$(zenity --entry --width 300 --title "Confirmer ID" --text "Titre recherché (ou confirmer la saisie précédente)" --entry-text="$artist")
|
||||
[[ "$song" == "$artist" ]] && song=""
|
||||
fi
|
||||
|
||||
# Download mp3 from 1st youtube search video result (--write-info-json)
|
||||
/usr/local/bin/youtube-dl --default-search ytsearch1: \
|
||||
--ignore-errors --no-mtime \
|
||||
--embed-thumbnail --metadata-from-title "%(artist)s - %(title)s" --add-metadata \
|
||||
--extract-audio --audio-format mp3 -o "${YTEMP}/%(id)s&%(title)s.%(ext)s" "$artist $song"
|
||||
|
||||
ls ${YTEMP}
|
||||
# Get filename, extract ID, make destination dir and move copy.
|
||||
YFILE=$(ls -t ${YTEMP} | head -n 1)
|
||||
FILE_NAME="$(basename "${YFILE}")"
|
||||
FILE_EXT="${FILE_NAME##*.}"
|
||||
|
||||
YID=$(echo "${FILE_NAME}" | cut -d "&" -f 1)
|
||||
YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | sed "s/[(][^)]*[)]//g" | sed -e 's/[^A-Za-z0-9._-]/_/g' | sed -e 's/__/_/g') # Remove YoutubeID_ and (what is in perentheses)
|
||||
[[ $(which detox) ]] && YNAME="$(echo "${FILE_NAME}" | cut -d "&" -f 2- | detox --inline)"
|
||||
|
||||
[[ ! $islink && "$song" != "" ]] && FILE_PATH="$HOME/astroport/$CAT/$artist/_o-o_" \
|
||||
|| FILE_PATH="$HOME/astroport/$CAT/${YID}"
|
||||
|
||||
mkdir -p "${FILE_PATH}" && mv -f ${YTEMP}/* "${FILE_PATH}/"
|
||||
# Remove "&" from FILE_NAME rename to YNAME
|
||||
mv "${FILE_PATH}/${FILE_NAME}" "${FILE_PATH}/${YNAME}" && FILE_NAME="${YNAME}"
|
||||
|
||||
MEDIAID="${YID}"
|
||||
TITLE="${YNAME%.*}"
|
||||
GENRES="[\"$PLAYER\"]"
|
||||
GROUPES="_IPNSKEY_" # USE GROUPS TO RECORD IPNS MEDIAKEY
|
||||
MEDIAKEY="MP3_$MEDIAID"
|
||||
|
||||
rm -Rf ${YTEMP}
|
||||
# zenity --warning --width ${large} --text "MP3 copié"
|
||||
echo "~/.zen/Astroport.ONE/tools/new_mp3_in_astroport.sh \"${FILE_PATH}/\" \"${FILE_NAME}\""
|
||||
~/.zen/Astroport.ONE/tools/new_mp3_in_astroport.sh "${FILE_PATH}/" "${FILE_NAME}" > /tmp/${CHOICE}_${MEDIAID}.log 2>&1
|
||||
|
||||
cat /tmp/${CHOICE}_${MEDIAID}.log
|
||||
|
||||
exit 0
|
||||
|
||||
;;
|
||||
|
||||
########################################################################
|
||||
# __ _ _
|
||||
# / _(_) |_ __ ___
|
||||
#| |_| | | '_ ` _ \
|
||||
#| _| | | | | | | |
|
||||
#|_| |_|_|_| |_| |_| THE MOVIE DATABASE INDEX
|
||||
#
|
||||
########################################################################
|
||||
film | serie)
|
||||
|
||||
# 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
|
||||
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
|
||||
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." && exit 1
|
||||
fi
|
||||
MEDIAID=$CMED
|
||||
MEDIAKEY="TMDB_$MEDIAID"
|
||||
|
||||
# VIDEO TITLE
|
||||
TITLE=$(zenity --entry --width 300 --title "Titre" --text "Indiquez le titre de la vidéo" --entry-text="${FILE_TITLE}")
|
||||
[[ $TITLE == "" ]] && exit 1
|
||||
TITLE=$(echo "${TITLE}" | sed "s/[(][^)]*[)]//g" | sed -e 's/;/_/g' ) # Clean TITLE (NO ;)
|
||||
|
||||
# VIDEO YEAR
|
||||
YEAR=$(zenity --entry --width 300 --title "Année" --text "Indiquez année de la vidéo. Exemple: 1985" --entry-text="")
|
||||
|
||||
# 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
|
||||
#RES=$(zenity --entry --width 300 --title="Résolution" --text="Résolution de la vidéo" --entry-text="${FILE_RES}" SD HD 4K 360p 480p 720p 1080p)
|
||||
|
||||
# VIDEO SEASON or SAGA
|
||||
[[ "${CAT}" == "serie" ]] && SAISON=$(zenity --entry --width 300 --title "${CHOICE} Saison" --text "Indiquez SAISON et EPISODE. Exemple: S02E05" --entry-text="")
|
||||
[[ "${CAT}" == "film" ]] && SAISON=$(zenity --entry --width 300 --title "${CHOICE} Saga" --text "Indiquez une SAGA (optionnel). Exemple: James Bond" --entry-text="")
|
||||
|
||||
# VIDEO GENRES
|
||||
FILM_GENRES=$(zenity --list --checklist --title="GENRE" --height=${haut}\
|
||||
--text="Choisissez le(s) genre(s) de la vidéo \"${TITLE}\""\
|
||||
--column="Use"\
|
||||
--column="Feature"\
|
||||
FALSE '+18'\
|
||||
FALSE Action\
|
||||
FALSE Animation\
|
||||
FALSE 'Arts martiaux'\
|
||||
FALSE Aventure\
|
||||
FALSE Autre\
|
||||
FALSE Biographie\
|
||||
FALSE Biopic\
|
||||
FALSE Comedie\
|
||||
FALSE 'Comedie dramatique'\
|
||||
FALSE 'Comedie musicale'\
|
||||
FALSE Crime\
|
||||
FALSE Documentaire\
|
||||
FALSE Drame\
|
||||
FALSE Divers\
|
||||
FALSE Educatif\
|
||||
FALSE Enfant\
|
||||
FALSE 'Epouvante horreur'\
|
||||
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\
|
||||
FALSE 'Science fiction'\
|
||||
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)\"]"
|
||||
|
||||
########################################################################
|
||||
# Screen capture is used as thumbnail
|
||||
########################################################################
|
||||
if [[ $(echo $DISPLAY | cut -d ':' -f 1) == "" ]]; then
|
||||
zenity --warning --width 300 --text "Cliquez nous capturons votre écran comme vignette MEDIA"
|
||||
sleep 1
|
||||
import -window root /tmp/screen.png
|
||||
fi
|
||||
|
||||
###################################
|
||||
### MOVING FILE TO ~/astroport ####
|
||||
###################################
|
||||
mkdir -p ~/astroport/${CAT}/${MEDIAID}/
|
||||
mv /tmp/screen.png ~/astroport/${CAT}/${MEDIAID}/screen.png
|
||||
|
||||
mv -f "${FILE_PATH}/${FILE_NAME}" "$HOME/astroport/${CAT}/${MEDIAID}/${TITLE}.${FILE_EXT}"
|
||||
|
||||
if [ $? == 0 ]; then
|
||||
zenity --warning --width ${large} --text "Votre fichier ~/astroport/${CAT}/${MEDIAID}/${TITLE}.${FILE_EXT} est prêt à embarquer. Cliquez sur OK, nous allons préparer son script d'ajout à Astroport..."
|
||||
else
|
||||
zenity --warning --width ${large} --text "Impossible de déplacer votre fichier ${FILE_PATH}/${FILE_NAME} vers ~/astroport - EXIT -"
|
||||
exit 1
|
||||
fi
|
||||
FILE_NAME="${TITLE}.${FILE_EXT}"
|
||||
|
||||
|
||||
## CREATE "~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt"
|
||||
URLENCODE_FILE_NAME=$(echo ${FILE_NAME} | jq -Rr @uri)
|
||||
echo "${CAT};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};_IPNSKEY_;${RES};/ipfs/_IPFSREPFILEID_/$URLENCODE_FILE_NAME" > ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt
|
||||
# _IPFSREPFILEID_ is replaced later
|
||||
|
||||
;;
|
||||
# _ _
|
||||
#__ _(_) __| | ___ ___
|
||||
#\ \ / / |/ _` |/ _ \/ _ \
|
||||
# \ V /| | (_| | __/ (_) |
|
||||
# \_/ |_|\__,_|\___|\___/
|
||||
# TIMESTAMP INDEX
|
||||
|
||||
video)
|
||||
|
||||
zenity --warning --width 600 --text 'DEVELOPPEMENT. SVP. Inscrivez-vous sur https://git.p2p.legal'
|
||||
|
||||
## GENERAL MEDIAKEY for uploaded video. Title + Decription + hashtag + hashipfs
|
||||
# SELECT FILE TO ADD TO ASTROPORT/KODI
|
||||
FILE=$(zenity --file-selection --title="Sélectionner le fichier vidéo à 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%.*}"
|
||||
# VIDEO TITLE
|
||||
TITLE=$(zenity --entry --width 300 --title "Titre" --text "Indiquez le titre de la vidéo" --entry-text="${FILE_TITLE}")
|
||||
[[ $TITLE == "" ]] && exit 1
|
||||
TITLE=$(echo "${TITLE}" | sed "s/[(][^)]*[)]//g" | sed -e 's/;/_/g' ) # Clean TITLE (NO ;)
|
||||
|
||||
OUTPUT=$(zenity --forms --width ${large} --title="METADATA" --text="Ajouter des métadonnées" --separator=";" --add-entry="Sous titres" --add-entry="Hashtag(s)")
|
||||
[[ $? != 0 ]] && echo "FAIL" && exit 1
|
||||
|
||||
DESCRIPTION=$(awk -F ';' '{print $1}' <<<$OUTPUT)
|
||||
HASHTAG=$(awk -F ';' '{print $2}' <<<$OUTPUT)
|
||||
|
||||
## video_timestamp INDEX
|
||||
MEDIAID="$(date -u +%s%N | cut -b1-13)"
|
||||
mkdir -p ~/astroport/${CAT}/${MEDIAID}/
|
||||
MEDIAKEY="VIDEO_${MEDIAID}"
|
||||
|
||||
## CREATE SIMPLE JSON
|
||||
jq -n --arg ts "$MEDIAID" --arg title "$TITLE" --arg desc "$DESCRIPTION" --arg htag "$HASHTAG" '{"timestamp":$ts,"ipfs":"_IPFSREPFILEID_","ipns":"_IPNSKEY_","title":$title,"desc":$desc,"htag":$htag}' > ~/astroport/${CAT}/${MEDIAID}/video.json
|
||||
## MOVE FILE TO IMPORT ZONE
|
||||
mv -f "${FILE_PATH}/${FILE_NAME}" "$HOME/astroport/${CAT}/${MEDIAID}/${TITLE}.${FILE_EXT}"
|
||||
FILE_NAME="${TITLE}.${FILE_EXT}"
|
||||
|
||||
;;
|
||||
|
||||
########################################################################
|
||||
# CASE ## DEFAULT
|
||||
########################################################################
|
||||
*)
|
||||
|
||||
zenity --warning --width ${large} --text "Impossible d'interpréter votre commande $CAT"
|
||||
exit 1
|
||||
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
## Extract thumbnail
|
||||
MIME=$(file --mime-type $HOME/astroport/${CAT}/${MEDIAID}/${TITLE}.${FILE_EXT} | rev | cut -d ' ' -f 1 | rev)
|
||||
|
||||
[[ $(echo $MIME | grep video) ]] && ffmpeg -i $HOME/astroport/${CAT}/${MEDIAID}/${TITLE}.${FILE_EXT} -r 1/300 -vf scale=-1:120 -vcodec png $HOME/astroport/${CAT}/${MEDIAID}/${CAT}.png
|
||||
[[ ! -f ~/astroport/${CAT}/${MEDIAID}/${CAT}.png ]] && echo "DEFAULT THUMBNAIL NEEDED"
|
||||
|
||||
########################################################################
|
||||
# ADD $FILE to IPFS / ASTROPORT / KODI
|
||||
echo "new_file_in_astroport.sh \"$HOME/astroport/${CAT}/${MEDIAID}/\" \"${FILE_NAME}\"" $3
|
||||
[[ -f ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt ]] && cat ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt
|
||||
# LOG NOISE # [[ -f ~/astroport/${CAT}/${MEDIAID}/video.json ]] && cat ~/astroport/${CAT}/${MEDIAID}/video.json
|
||||
########################################################################
|
||||
## CREATION DU FICHIER ajouter_video.txt OK
|
||||
########################################################################
|
||||
### AJOUT DANS IPFS #######################################################
|
||||
########################################################################
|
||||
####################################new_file_in_astroport.sh##################
|
||||
########################################################################
|
||||
[[ "$CAT" == "film" || "$CAT" == "serie" ]] && CHOICE="TMDB"
|
||||
|
||||
timestamp=$(date -u +%s%N | cut -b1-13)
|
||||
|
||||
## OLD CODE !!! ADD TO ASTROPORT SCRIPT
|
||||
## NOW CREATE TIDDLER INTO PLAYER TW
|
||||
|
||||
echo "MEDIAKEY=${MEDIAKEY}" > ~/astroport/Add_${MEDIAKEY}_script.sh
|
||||
|
||||
## 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
|
||||
# ffmpeg -i \"$HOME/astroport/${CAT}/${MEDIAID}/${FILE_NAME}\" -vcodec libx265 -crf 28 $HOME/astroport/${MEDIAID}.mp4
|
||||
# mv \"$HOME/astroport/${CAT}/${MEDIAID}/${FILE_NAME}\" \"$HOME/astroport/${CAT}/${MEDIAID}/${FILE_NAME}.old\"
|
||||
# mv $HOME/astroport/${MEDIAID}.mp4 \"$HOME/astroport/${CAT}/${MEDIAID}/${FILE_NAME}.mp4\"
|
||||
# ~/.zen/Astroport.ONE/tools/new_file_in_astroport.sh \"$HOME/astroport/${CAT}/${MEDIAID}/\" \"${FILE_NAME}.mp4\"
|
||||
#else" >> ~/astroport/Add_${MEDIAKEY}_script.sh
|
||||
|
||||
# $3 is the G1PUB of the PLAYER
|
||||
echo "~/.zen/Astroport.ONE/tools/new_file_in_astroport.sh \"$HOME/astroport/${CAT}/${MEDIAID}/\" \"${FILE_NAME}\" \"$G1PUB\"" >> ~/astroport/Add_${MEDIAKEY}_script.sh
|
||||
|
||||
#[[ $CHOICE == "TMDB" ]] && echo "fi" >> ~/astroport/Add_${MEDIAKEY}_script.sh
|
||||
|
||||
echo "rm -f /tmp/\${MEDIAKEY}.pass
|
||||
rm -f /tmp/\${MEDIAKEY}.dunikey ## REMOVE KEYS
|
||||
mv ~/astroport/Add_${MEDIAKEY}_script.sh ~/astroport/Done_${FILE_NAME}.sh
|
||||
" >> ~/astroport/Add_${MEDIAKEY}_script.sh
|
||||
|
||||
chmod +x ~/astroport/Add_${MEDIAKEY}_script.sh
|
||||
|
||||
########################################################################
|
||||
## USE PLAYER G1PUB AS MEDIA WALLET
|
||||
MEDIAPUBKEY=$(cat ~/.zen/game/players/.current/.g1pub)
|
||||
G1BALANCE=$(~/.zen/Astroport.ONE/tools/jaklis/jaklis.py balance -p $G1PUB)
|
||||
|
||||
########################################################################
|
||||
echo "# ZENBALANCE for ${MEDIAKEY} , WALLET $MEDIAPUBKEY"
|
||||
########################################################################
|
||||
FILE_BSIZE=$(du -b "$HOME/astroport/${CAT}/${MEDIAID}/${FILE_NAME}" | 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] }')
|
||||
|
||||
#G1BALANCE=$(~/.zen/Astroport.ONE/tools/jaklis/jaklis.py balance -p $G1PUB) && [[ "$G1BALANCE" == "null" ]] && G1BALANCE=0 || G1BALANCE=$(echo "$G1BALANCE" | cut -d '.' -f 1)
|
||||
#if [[ $G1BALANCE -gt 0 ]]; then
|
||||
# [ ! $2 ] && G1AMOUNT=$(zenity --entry --width 400 --title "VIRER DE LA MONNAIE LIBRE AU MEDIAKEY (MAX $G1BALANCE)" --text "Combien de JUNE (G1) souhaitez-vous offrir à ce MEDIA ($FILE_SIZE)" --entry-text="")
|
||||
# [[ ! "$G1AMOUNT" =~ ^[0-9]+$ ]] && G1AMOUNT=0
|
||||
# ~/.zen/Astroport.ONE/tools/jaklis/jaklis.py -k ~/.zen/secret.dunikey pay -p ${MEDIAPUBKEY} -a $G1AMOUNT -c "#ASTROPORT:${MEDIAKEY} DON"
|
||||
# ZENBALANCE=$(echo "100 * $G1AMOUNT" | bc -l | cut -d '.' -f 1)
|
||||
#else
|
||||
ZENBALANCE=0
|
||||
#fi
|
||||
########################################################################
|
||||
|
||||
## CHOOSE LIGHT OR COMPLETE
|
||||
if [ $1 ]; then
|
||||
bash ~/astroport/Add_${MEDIAKEY}_script.sh "noh265"
|
||||
[ $? == 0 ] && echo "${MEDIAKEY} is RECORDED in ASTROPORT. GOOD." && exit 0
|
||||
|
||||
else
|
||||
zenity --question --width 300 --text "OK! ~/astroport/Add_${MEDIAKEY}_script.sh ($FILE_SIZE). Voulez-vous lancer immédiatement l'ajout dans Astroport ?"; \
|
||||
[ $? == 0 ] && bash ~/astroport/Add_${MEDIAKEY}_script.sh "noh265" \
|
||||
&& [[ $(cat ~/.zen/game/players/.current/.playerns 2>/dev/null) ]] \
|
||||
&& xdg-open "http://127.0.0.1:8080/ipns/$(cat ~/.zen/game/players/.current/.playerns)" \
|
||||
|| ( zenity --warning --width 300 --text "Désolé une erreur est survenue... cat /tmp/${MEDIAKEY}.log" && exit 1 )\
|
||||
fi
|
||||
|
||||
|
||||
zenity --warning --width 300 --text "Ajout du Tiddler $MEDIAKEY à votre TW 'moa' $PLAYER"
|
||||
|
||||
|
||||
########################################################################
|
||||
## ADD TIDDLER TO TW
|
||||
########################################################################
|
||||
VOEUXLIST=($(cat /home/fred/.zen/game/players/.current/voeux/*/.title)) # LIST PLAYER VOEUX
|
||||
echo "${VOEUXLIST}"
|
||||
# TODO : Make it work Add FALSE between each voeu in VOEUXLIST
|
||||
# VCHOOSE=$(zenity --list --checklist --title="VOEUX"\
|
||||
# --text="Choisissez le voeux ou ajouter \"${TITLE}\""\
|
||||
# --column="Use"\
|
||||
# --column="Feature"\
|
||||
# ${VOEUXLIST})
|
||||
## CHOOSE VOEU TW
|
||||
## ADD TIDDLER TO VOEUTW
|
||||
## ADD VOEUTW TO IPFS...
|
||||
## OR ADD TO PLAYER TW
|
||||
## TODO MAKE FUNCTION, idem dans G1VOEUX !!
|
||||
echo "Nouveau MEDIAKEY dans MOA $PSEUDO / $PLAYER : http://127.0.0.1:8080/ipns/$ASTRONAUTENS"
|
||||
tiddlywiki --verbose --load ~/.zen/game/players/$PLAYER/ipfs/moa/index.html \
|
||||
--import ~/astroport/${TYPE}/${REFERENCE}/${MEDIAKEY}.dragdrop.json "application/json" \
|
||||
--output ~/.zen/tmp --render "$:/core/save/all" "newindex.html" "text/plain"
|
||||
|
||||
echo "PLAYER TW Update..."
|
||||
if [[ -s ~/.zen/tmp/newindex.html ]]; then
|
||||
echo "Mise à jour ~/.zen/game/players/$PLAYER/ipfs/moa/index.html"
|
||||
cp -f ~/.zen/tmp/newindex.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
|
||||
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
|
||||
echo "Avancement blockchain TW $PLAYER : $MOATS"
|
||||
cp ~/.zen/game/players/$PLAYER/ipfs/moa/.chain ~/.zen/game/players/$PLAYER/ipfs/moa/.chain.$MOATS
|
||||
|
||||
TW=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ipfs/moa/index.html | tail -n 1)
|
||||
echo "ipfs name publish --key=$PLAYER /ipfs/$TW"
|
||||
ipfs name publish --key=$PLAYER /ipfs/$TW
|
||||
|
||||
# MAJ CACHE TW $PLAYER
|
||||
echo $TW > ~/.zen/game/players/$PLAYER/ipfs/moa/.chain
|
||||
echo $MOATS > ~/.zen/game/players/$PLAYER/ipfs/moa/.moats
|
||||
echo
|
||||
fi
|
||||
|
||||
exit 0
|
BIN
templates/_MEDIAKEY_.keystore.key
Normal file
BIN
templates/_MEDIAKEY_.keystore.key
Normal file
Binary file not shown.
55
templates/boris/youtube_watch_step2.html
Normal file
55
templates/boris/youtube_watch_step2.html
Normal file
@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>_TITLE_ in Astroport</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Refresh" content="7;URL=/ipns/_IPNSLINK_/_G1PUB_/">
|
||||
<link rel='stylesheet' href='/ipfs/QmdfupE5bVqM1qcxyD22t4y6REPLHP9j1C6mekJugKX4Mf' type='text/css' />
|
||||
<link rel='stylesheet' href='/ipfs/QmbAmMY2m5QDaZnoHMQP7F7sRy2uWVfCE5QWyhA8fjeN4f' type='text/css' />
|
||||
|
||||
<link rel='icon' type='image/png' href='/ipfs/QmZEZVw7ZKJqceDNbCMd6YEy5Poxeg3RXMboqwwBrZpS8Q' />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h6>
|
||||
<a href='/'><span>ASTROPORT</span> <q>_PLAYER_</q></a>
|
||||
</h6>
|
||||
</header>
|
||||
<main>
|
||||
<article>
|
||||
|
||||
<h1>_TITLE_</h1>
|
||||
|
||||
<p>Lancement de la video dans 7 secondes...</p>
|
||||
|
||||
<p class="pubkey-and-copy-button">
|
||||
Ce fichier vous est servi par une station amie. Faites lui un don pour la remercier :
|
||||
<input type="text" id="pubkey" readonly value="_G1PUB_" />
|
||||
<button id="copy">Tip !</button>
|
||||
</p>
|
||||
|
||||
<p id="successMsg">
|
||||
La clef de la station amie est maintenant copiée dans le presse-papier. Vous pouvez la coller dans le client Ğ1 de votre choix (Cesium par exemple) afin de faire votre don 😉
|
||||
</p>
|
||||
<script>
|
||||
function copy() {
|
||||
|
||||
var copyText = document.querySelector("input#pubkey");
|
||||
copyText.select();
|
||||
document.execCommand("copy");
|
||||
|
||||
var successMsg = document.querySelector("#successMsg");
|
||||
successMsg.style.opacity = "1";
|
||||
|
||||
var copyButton = document.querySelector("button#copy");
|
||||
copyButton.style.animation = "none";
|
||||
|
||||
}
|
||||
|
||||
|
||||
document.querySelector("button#copy").addEventListener("click", copy);
|
||||
</script>
|
||||
</article>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
32
templates/boris/youtube_watch_step3.html
Normal file
32
templates/boris/youtube_watch_step3.html
Normal file
@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>_TITLE_ in Astroport</title>
|
||||
<meta charset="UTF-8">
|
||||
<link rel='stylesheet' href='/ipfs/QmdfupE5bVqM1qcxyD22t4y6REPLHP9j1C6mekJugKX4Mf' type='text/css' />
|
||||
<link rel='stylesheet' href='/ipfs/QmbAmMY2m5QDaZnoHMQP7F7sRy2uWVfCE5QWyhA8fjeN4f' type='text/css' />
|
||||
|
||||
<link rel='icon' type='image/png' href='/ipfs/QmZEZVw7ZKJqceDNbCMd6YEy5Poxeg3RXMboqwwBrZpS8Q' />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h6>
|
||||
<a href='/ipns/_IPFSNODEID_/._IPFSNODEID_/'><span>ASTROPORT</span> <q>_PLAYER_</q></a>
|
||||
</h6>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<article>
|
||||
<video autoplay="autoplay" controls>
|
||||
<source src="/ipfs/_IPFSREPFILEID_/_URLENCODE_FILE_NAME_">
|
||||
<a href="/ipfs/_IPFSREPFILEID_/_URLENCODE_FILE_NAME_">_TITLE_</a>
|
||||
</video>
|
||||
|
||||
<h1 class="video-title">
|
||||
_TITLE_
|
||||
</h1>
|
||||
</article>
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -460,7 +460,7 @@ Error message and password prompt
|
||||
{"title":"$:/Import-2","text":"The following tiddlers were imported:\n\n# [[$:/plugins/danielo515/encryptTiddler]]","status":"complete"},
|
||||
{"created":"20220504002111585","title":"$:/ipfs/saver/api","modified":"20220504002111585","tags":"$:/ipfs/core","text":"$:/ipfs/saver/api/http/localhost/5001"},
|
||||
{"created":"20220504002114786","title":"$:/ipfs/saver/gateway","modified":"20220504002114786","tags":"$:/ipfs/core","text":"$:/ipfs/saver/gateway/http/localhost"},
|
||||
{"title":"$:/ipfs/saver/ipns/key","modified":"20220703190130626","tags":"$:/ipfs/core","text":"k2k4r8naeti1ny2hsk3a0ziwz22urwiu633hauluwopf4vwjk4x68qgk"},
|
||||
{"title":"$:/ipfs/saver/ipns/key","modified":"20220703190130626","tags":"$:/ipfs/core","text":"k2k4r8kxfnknsdf7tpyc46ks2jb3s9uvd3lqtcv9xlq9rsoem7jajd75"},
|
||||
{"created":"20220504002122946","title":"$:/ipfs/saver/ipns/name","modified":"20220703190120758","tags":"$:/ipfs/core","text":"_MEDIAKEY_"},
|
||||
{"created":"20220504002017358","text":"no","title":"$:/ipfs/saver/unpin","modified":"20220703191512781","tags":"bluelightav.eth"},
|
||||
{"created":"20220504002017817","text":"no","title":"$:/ipfs/saver/verbose","modified":"20220504002017817","tags":"bluelightav.eth"},
|
||||
|
@ -189,6 +189,8 @@ Error message and password prompt
|
||||
|
||||
<li>$:/config/story-river/bottom-right-panel</li>
|
||||
|
||||
<li>$:/config/story-river/dragging-enable</li>
|
||||
|
||||
<li>$:/config/story-river/dragging-enabled</li>
|
||||
|
||||
<li>$:/config/story-river/follow-active-column</li>
|
||||
@ -440,6 +442,7 @@ Error message and password prompt
|
||||
{"title":"$:/config/scroll-x-duration","created":"20220403193008167","modified":"20220411211937170","type":"text/vnd.tiddlywiki","text":"800","revision":"0","bag":"default"},
|
||||
{"created":"20220624002307623","text":"no","title":"$:/config/sq/streams/enable-breadcrumbs","description":"Enable breadcrumbs in nodes","caption":"Show breadcrumbs","settings-template":"$:/plugins/sq/streams/ui/templates/settings/input-switch","modified":"20220624002307623"},
|
||||
{"created":"20220421184632774","text":"yes","title":"$:/config/story-river/bottom-right-panel","modified":"20220504185548393","type":"text/vnd.tiddlywiki","revision":"0","bag":"default"},
|
||||
{"created":"20220904095821724","title":"$:/config/story-river/dragging-enable","text":"no","modified":"20220904095821724"},
|
||||
{"title":"$:/config/story-river/dragging-enabled","created":"20220416140144769","modified":"20220416140144769","type":"text/vnd.tiddlywiki","text":"no","revision":"0","bag":"default"},
|
||||
{"created":"20220504185647722","title":"$:/config/story-river/follow-active-column","text":"no","modified":"20220504185650273"},
|
||||
{"title":"$:/config/story-river/hide-scrollbars","created":"20220423053107345","modified":"20220423072822748","type":"text/vnd.tiddlywiki","text":"no","revision":"0","bag":"default"},
|
||||
@ -462,8 +465,8 @@ Error message and password prompt
|
||||
{"title":"$:/Import-2","text":"The following tiddlers were imported:\n\n# [[$:/plugins/danielo515/encryptTiddler]]","status":"complete"},
|
||||
{"created":"20220504002111585","title":"$:/ipfs/saver/api","modified":"20220504002111585","tags":"$:/ipfs/core","text":"$:/ipfs/saver/api/http/localhost/5001"},
|
||||
{"created":"20220504002114786","title":"$:/ipfs/saver/gateway","modified":"20220504002114786","tags":"$:/ipfs/core","text":"$:/ipfs/saver/gateway/http/localhost"},
|
||||
{"title":"$:/ipfs/saver/ipns/key","modified":"20220703190130626","tags":"$:/ipfs/core","text":"k2k4r8naeti1ny2hsk3a0ziwz22urwiu633hauluwopf4vwjk4x68qgk"},
|
||||
{"created":"20220504002122946","title":"$:/ipfs/saver/ipns/name","modified":"20220703190120758","tags":"$:/ipfs/core","text":"_MEDIAKEY_"},
|
||||
{"title":"$:/ipfs/saver/ipns/key","modified":"20220904100154309","tags":"$:/ipfs/core","text":"k2k4r8kxfnknsdf7tpyc46ks2jb3s9uvd3lqtcv9xlq9rsoem7jajd75"},
|
||||
{"created":"20220504002122946","title":"$:/ipfs/saver/ipns/name","modified":"20220904100041168","tags":"$:/ipfs/core","text":"_MEDIAKEY_"},
|
||||
{"created":"20220504002017358","text":"no","title":"$:/ipfs/saver/unpin","modified":"20220703191512781","tags":"bluelightav.eth"},
|
||||
{"created":"20220504002017817","text":"no","title":"$:/ipfs/saver/verbose","modified":"20220504002017817","tags":"bluelightav.eth"},
|
||||
{"title":"$:/isEncrypted","text":"no","revision":"0","bag":"default"},
|
||||
@ -492,14 +495,14 @@ Error message and password prompt
|
||||
{"created":"20220624001727362","title":"$:/state/sq/streams/current-edit-tiddler-295684372","text":"Astroport/20220624001916671","modified":"20220624001916680"},
|
||||
{"created":"20220504002254925","title":"$:/state/tab--1963855381","text":"$:/core/ui/ControlPanel/Theme","modified":"20220816144222799"},
|
||||
{"created":"20220816143924601","title":"$:/state/tab--86143343","text":"$:/core/ui/ControlPanel/Plugins/Installed/Themes","modified":"20220816143924601"},
|
||||
{"created":"20220504001402061","title":"$:/state/tab-1749438307","text":"$:/core/ui/ControlPanel/Info","modified":"20220822140830140"},
|
||||
{"created":"20220504001402061","title":"$:/state/tab-1749438307","text":"$:/core/ui/ControlPanel/Info","modified":"20220904100414524"},
|
||||
{"created":"20220504002015133","title":"$:/state/tab-2065006209","text":"$:/core/ui/ControlPanel/Saving/Ipfs","modified":"20220504005954202"},
|
||||
{"created":"20220504003502994","title":"$:/state/tab/moresidebar-1850697562","text":"$:/core/ui/MoreSideBar/Recent","modified":"20220504003524859"},
|
||||
{"created":"20220504003457433","title":"$:/state/tab/sidebar--595412856","text":"$:/core/ui/SideBar/Recent","modified":"20220504185413926"},
|
||||
{"created":"20220504002003357","title":"$:/state/user-panel/visibility","text":"no","modified":"20220624002230943"},
|
||||
{"title":"$:/status/RequireReloadDueToPluginChange","text":"no"},
|
||||
{"title":"$:/Story/Default","bottom-right-panel":"yes","columns":"1 2 3","created":"20220428183227840","dragging-enable":"yes","follow-active-column":"no","hide-scrollbars":"no","horizontal-columns":"2","modified":"20220428183227841","no-tiddler-box-shadows":"no","palette":"$:/palettes/Vanilla","panel-position":"right","panel-show-numbers":"no","panel-width-above-1170px":"35%","panel-width-below-1170px":"50%","panel-width-below-768px":"90%","river-obscured":"yes","scroll-snap-type":"none","show-edit-preview-per-tiddler":"yes","story-1":"Palettes Tips [[Ceci n’est pas une pipe.]] [[Configuration Options]]","story-2":"[[The plugin]] [[Keyboard Shortcuts]] [[The Birth of Venus]] [[Star me on GitHub]]","story-3":"[[Responsive Video]] [[Differences between FireFox and Chromium]] [[The Great Wave off the Coast of Kanagawa]]","story-river-padding":"15","tiddler-border":"1","tiddler-margin":"10","type":"text/vnd.tiddlywiki","view":"vertical","revision":"0","bag":"default"},
|
||||
{"created":"20220822140825914","title":"$:/StoryList","text":"","list":"MadeInZion_G1_ASTROPORT.png Carte","modified":"20220822140854970"},
|
||||
{"title":"$:/StoryList","created":"20220904095636665","text":"","list":"MadeInZion_G1_ASTROPORT.png Carte","modified":"20220904095636665"},
|
||||
{"created":"20220409124735965","title":"$:/StoryList-2","list":"G1Voeu Astroport","modified":"20220822140718188","type":"text/vnd.tiddlywiki","revision":"0","bag":"default"},
|
||||
{"title":"$:/StoryList-24","list":"","type":"text/vnd.tiddlywiki","revision":"0","bag":"default"},
|
||||
{"title":"$:/StoryList-3","created":"20220402104129655","list":"","modified":"20220501113142260","type":"text/vnd.tiddlywiki","revision":"0","bag":"default"},
|
||||
|
@ -46,7 +46,7 @@ for yurl in $(cat ~/.zen/tmp/tiddlers.json | jq -r '.[].text' | grep 'http'); do
|
||||
ILINK=$(ipfs add -q "$HOME/.zen/tmp/tube/$FILE" | tail -n 1)
|
||||
echo "/ipfs/$ILINK ready"
|
||||
|
||||
MIME=$(file --mime-type "$HOME/.zen/tmp/tube/$FILE" | cut -d ':' -f 2 | cut -d ' ' -f 2)
|
||||
MIME=$(file --mime-type "$HOME/.zen/tmp/tube/$FILE" | rev | cut -d ' ' -f 1 | rev)
|
||||
|
||||
TEXT="<video controls width=360><source src='/ipfs/"${ILINK}"' type='"${MIME}"'></video><h1>"${FILE}"</h1>"
|
||||
|
||||
|
@ -155,7 +155,7 @@ G1PUB=$(cat /tmp/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
||||
ASTRONAUTENS=$(ipfs key list -l | grep -w "${PLAYER}" | cut -d ' ' -f 1)
|
||||
# La Clef IPNS porte comme nom G1PUB.
|
||||
sed -i "s~_MEDIAKEY_~${PLAYER}~g" ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/moa/index.html
|
||||
sed -i "s~k2k4r8naeti1ny2hsk3a0ziwz22urwiu633hauluwopf4vwjk4x68qgk~${ASTRONAUTENS}~g" ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/moa/index.html
|
||||
sed -i "s~k2k4r8kxfnknsdf7tpyc46ks2jb3s9uvd3lqtcv9xlq9rsoem7jajd75~${ASTRONAUTENS}~g" ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/moa/index.html
|
||||
sed -i "s~ipfs.infura.io~tube.copylaradio.com~g" ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/moa/index.html
|
||||
|
||||
myIP=$(hostname -I | awk '{print $1}' | head -n 1)
|
||||
|
256
tools/ipns_TAG_refresh.sh
Executable file
256
tools/ipns_TAG_refresh.sh
Executable file
@ -0,0 +1,256 @@
|
||||
#!/bin/bash
|
||||
########################################################################
|
||||
# Author: Fred (support@qo-op.com)
|
||||
# Version: 2020.04.28
|
||||
# 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##*/}"
|
||||
countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|grep' | wc -l)
|
||||
[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0
|
||||
|
||||
echo '########################################################################
|
||||
# \\///
|
||||
# qo-op
|
||||
############# '$MY_PATH/$ME'
|
||||
########################################################################
|
||||
# ex: ./'$ME'
|
||||
########################################################################'
|
||||
|
||||
echo "CHOOSE THE WAY YOU ARE GIVING ACCES TO YOUR MEDIAKEY !!"
|
||||
echo "CONCEPT IS HERE. REWRITE NEEDED"
|
||||
exit 1
|
||||
|
||||
########################################################################
|
||||
########################################################################
|
||||
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID)
|
||||
[[ ! $IPFSNODEID ]] && echo 'ERROR missing IPFS Node id !! IPFS is not installed !?' && exit 1
|
||||
########################################################################
|
||||
[[ ! -f ~/.zen/secret.dunikey ]] && exit 1
|
||||
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
||||
########################################################################
|
||||
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
|
||||
[[ ! $YOU ]] && echo "IPFS NOT RUNNING. EXIT" && exit 1
|
||||
########################################################################
|
||||
XZUID=$(cat ~/.zen/ipfs/.$IPFSNODEID/.player)
|
||||
# echo "## FRIENDS IPFS PINGing"
|
||||
# for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do [[ $g1pub ]] && ipfs ping --timeout=3s -n 3 /ipfs/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null; done
|
||||
|
||||
|
||||
echo "
|
||||
_ _ _ _
|
||||
/ \ / \ / \ / \
|
||||
( I | P | N | S )
|
||||
\_/ \_/ \_/ \_/
|
||||
|
||||
ZENTAG / MEDIAKEY : IPNS REFRESH
|
||||
"
|
||||
echo "I am /ipns/$IPFSNODEID controling and refreshing my MEDIAKEY IPNS"
|
||||
########################################################################
|
||||
# REFRESH IPNS SELF PUBLISH
|
||||
########################################################################
|
||||
# ~/.zen/astrXbian/zen/ipns_self_publish.sh
|
||||
########################################################################
|
||||
|
||||
count=0
|
||||
# [[ ! -d ~/.zen/ipfs/.${IPFSNODEID}/KEY/ ]] && exit 0
|
||||
|
||||
## TAKE CARE OF MY KEY
|
||||
for mediakey in $(ls ~/.zen/ipfs/.${IPFSNODEID}/KEY/ 2>/dev/null | shuf ); # Alternative search
|
||||
do
|
||||
[[ "${mediakey}" == "" ]] && continue ## prevent empty mediakey
|
||||
# [[ ! $(echo "${mediakey}" | grep "TMDB_") ]] && continue ## REFRESH ONLY TMDB (level 1), youtube is level 0
|
||||
IPNSLINK=$(ipfs key list -l | grep ${mediakey} | cut -d ' ' -f 1)
|
||||
[[ "${IPNSLINK}" == "" ]] && continue ## prevent empty IPNSLINK
|
||||
echo "We are refreshing http://127.0.0.1:8080/ipns/${IPNSLINK}"
|
||||
count=$((count+1)) && echo "$count) "
|
||||
FILE_NAME=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.ipfs.filename)
|
||||
TITLE=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.title)
|
||||
|
||||
## REFRESH MORE THAN 6 HOURS TIMESTAMP KEY
|
||||
TIMESTAMP=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.timestamp) # INITIAL TIMESTAMP
|
||||
[[ -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/.timestamp ]] && TIMESTAMP=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/.timestamp) # LAST REFRESH
|
||||
timestamp=$(date -u +%s%N | cut -b1-13)
|
||||
STAMPDIFF=$((timestamp - TIMESTAMP))
|
||||
echo "Last Update : $(date -d @$TIMESTAMP | cut -b1-10)" # remove millisecond part
|
||||
echo "${mediakey} LAST UPDATED $STAMPDIFF milliseconds AGO"
|
||||
[ $STAMPDIFF -lt 21600000 ] && continue # 6h = 21600000 ms , 10h = 36000000 ms
|
||||
|
||||
source=$(echo $mediakey | cut -d '_' -f 1)
|
||||
|
||||
ANNONCE=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.gchange.ad 2>/dev/null)
|
||||
|
||||
## Use natools to decrypt "/tmp/${mediakey}_filelink.txt
|
||||
[[ -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.ipfs.filelink.natools.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.ipfs.filelink.natools.encrypt" -o "/tmp/${mediakey}_filelink.txt"
|
||||
URLENCODE_FILE_NAME=$(cat /tmp/${mediakey}_filelink.txt | rev | cut -d '/' -f 1 | rev | jq -Rr @uri)
|
||||
IPFSREPFILEID=$(cat /tmp/${mediakey}_filelink.txt | rev | cut -d '/' -f 2- | rev | cut -d '/' -f 3)
|
||||
|
||||
echo "IPFS MEDIA link : /ipfs/$IPFSREPFILEID/$URLENCODE_FILE_NAME"
|
||||
|
||||
## TREAT OLD DATA from new_file_in_astroport.sh (LATER can be removed)
|
||||
if [[ ! -f $HOME/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/content.json && -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/video.json ]]; then
|
||||
mediakeyfile=$($MY_PATH/tools/give_me_keystore_filename.py $mediakey)
|
||||
$MY_PATH/tools/natools.py privkey -f ipfs-keystore -k $HOME/.ipfs/keystore/$mediakeyfile -F pubsec -o /tmp/${mediakey}.dunikey
|
||||
# PubFromDunikey=$(cat /tmp/${mediakey}.dunikey | grep "sec" | cut -d ' ' -f2 | base58 -d | tail -c+33 | base58)
|
||||
PubFromDunikey=$(cat /tmp/${mediakey}.dunikey | grep "pub" | cut -d ' ' -f2)
|
||||
echo "$PubFromDunikey" > $HOME/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/MEDIAPUBKEY
|
||||
fi
|
||||
|
||||
MEDIAPUBKEY=$(cat $HOME/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/MEDIAPUBKEY)
|
||||
echo "MEDIA G1 WALLET = $MEDIAPUBKEY"
|
||||
BALANCE=$(~/.zen/astrXbian/zen/jaklis/jaklis.py balance -p ${MEDIAPUBKEY}) && [[ $BALANCE == null || "$BALANCE" == "" ]] && BALANCE=0
|
||||
ZENBALANCE=$(echo "100 * $BALANCE" | bc -l | cut -d '.' -f 1)
|
||||
|
||||
TUBELINK="https://tube.copylaradio.com$(cat /tmp/${mediakey}_filelink.txt)"
|
||||
LOCALTUBELINK="http://127.0.0.1:8080$(cat /tmp/${mediakey}_filelink.txt)"
|
||||
|
||||
### IPNS LINK CAN EVOLVE (REFRESH EVERY 12 H TO MAINTAIN ALIVE IN THE SWARM)
|
||||
### This index.html is ipns link root, 1st welcome page for MEDIAKEY -> *** Redirect to CONTRACTS or LOGIN processing HERE ***
|
||||
|
||||
echo "=======> Mediakey Welcome index.html
|
||||
IPNSLINK=$IPNSLINK
|
||||
IPFSNODEID=$IPFSNODEID
|
||||
XZUID=$XZUID
|
||||
G1PUB=$G1PUB
|
||||
TITLE=$TITLE"
|
||||
cat /home/$YOU/.zen/astrXbian/www/boris/youtube_watch_step2.html \
|
||||
| sed "s/\${IPNSLINK}/$IPNSLINK/g" \
|
||||
| sed "s/\${IPFSNODEID}/$IPFSNODEID/g" \
|
||||
| sed "s/\${XZUID}/$XZUID/g" \
|
||||
| sed "s/\${G1PUB}/$G1PUB/g" \
|
||||
| sed "s/\${TITLE}/$TITLE/g" \
|
||||
> /tmp/${mediakey}_index.html
|
||||
mv /tmp/${mediakey}_index.html ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/index.html
|
||||
|
||||
[ ! -s ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/index.html ] && echo "Problem creating ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/index.html. EXIT" && exit 1
|
||||
|
||||
########################################################################
|
||||
### Scenario are G1PUB subdivized. Thus each friend can establish own contract
|
||||
# ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/index.html
|
||||
########################################################################
|
||||
|
||||
## Write KEY id (provide verification)
|
||||
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.id ]] && echo ${mediakey} > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.id
|
||||
|
||||
## THIS MAKES FRENCH COPY RIGHT LAW RESPECT
|
||||
## LOCALHOST REDIRECT FOR INTERNAL KODI DEFCON 3 (swarm.key) ASTROPORT STATION MODE
|
||||
# echo "<meta charset=\"UTF-8\"><meta http-equiv=\"Refresh\" content=\"0;URL=http://127.0.0.1:8080$(cat /tmp/${mediakey}_filelink.txt)\">" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/index.html
|
||||
# echo "<meta charset=\"UTF-8\"><meta http-equiv=\"Refresh\" content=\"0;URL=https://tube.copylaradio.com$(cat /tmp/${mediakey}_filelink.txt)\">" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/index.html
|
||||
|
||||
## DEMO PERIOD
|
||||
## NICE FINAL STREAMING PAGE # TODO ACTIVATE DOWNLOAD FOR AVI or MKV
|
||||
FILETYPE="${LOCALTUBELINK##*.}"
|
||||
MIMETYPE="video/$FILETYPE" && HTMLTAG="video"
|
||||
[[ "$FILETYPE" == "avi" ]] && MIMETYPE="video/x-msvideo"
|
||||
[[ "$FILETYPE" == "mkv" ]] && MIMETYPE="video/x-matroska"
|
||||
[[ "$FILETYPE" == "mp3" ]] && MIMETYPE="audio/mpeg" && HTMLTAG="audio"
|
||||
|
||||
echo "=======> Mediakey Contract index.html "
|
||||
cat /home/$YOU/.zen/astrXbian/www/boris/youtube_watch_step3.html \
|
||||
| sed "s/\${TITLE}/$TITLE/g" \
|
||||
| sed "s/\${IPFSNODEID}/$IPFSNODEID/g" \
|
||||
| sed "s/\${XZUID}/$XZUID/g" \
|
||||
| sed "s/\${IPFSREPFILEID}/$IPFSREPFILEID/g" \
|
||||
| sed "s/\${URLENCODE_FILE_NAME}/$URLENCODE_FILE_NAME/g" \
|
||||
> ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/index.html
|
||||
|
||||
|
||||
if [[ "$source" == "YOUTUBE" ]]
|
||||
then
|
||||
echo "$source"
|
||||
# mutiTUBE - activate .views.counter
|
||||
# echo "<meta http-equiv=\"Refresh\" content=\"0;URL=https://tube.copylaradio.com/ipns/$IPNSLINK/${G1PUB}/go\">" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/index.html
|
||||
# TODO go/index.php from nginx proxy acting act as gateway (= Easy Round robin DNS tube.copylaradio.com is dynamic IP swap swarm nodes from node performance...)
|
||||
fi
|
||||
# ln -s /$HOME/.zen/astrXbian/www /var/www/astrxbian
|
||||
# Testez vos application à même la blockchain en la copiant dans ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/go/
|
||||
# Proposez de l'ajouter au dépot des applications web2.0 dans ../www/
|
||||
|
||||
########################################################################
|
||||
# EXAMPLE TO ACTIVATE SECURITY : FORCE SIGNATURE VERIFICATION for each sensible file
|
||||
########################################################################
|
||||
echo "~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.views.counter"
|
||||
if [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.views.counter.sign ]]; then
|
||||
echo "0" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.views.counter
|
||||
$MY_PATH/tools/natools.py sign -f pubsec -k "$HOME/.zen/secret.dunikey" -i ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.views.counter -o ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.views.counter.sign
|
||||
fi
|
||||
|
||||
$MY_PATH/tools/natools.py verify -p "${G1PUB}" -i "$HOME/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/${G1PUB}/.views.counter.sign" -o "/tmp/verified_msg" && echo "c'est bon" || echo "c'est pas bon"
|
||||
# Each time a station modify .views.counter it signs, log and timestamp then publish new IPNS to swarm.
|
||||
# If a "faulty" blockchain appears (Mediakey collision)...
|
||||
# Message are sent to warn friends they have to manualy validate data conflict and merge back their mutual chain.
|
||||
|
||||
########################################################################
|
||||
## CHAIN & IPNS REFRESH
|
||||
########################################################################
|
||||
# ipfs nanochain progression
|
||||
I=$(ipfs add -qrH ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/ | tail -n 1)
|
||||
echo "CHAIN: $I"
|
||||
OLDCHAIN=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/.chain)
|
||||
echo "OLDCHAIN: $OLDCHAIN"
|
||||
if [[ "$OLDCHAIN" != "$I" ]] # MODIFY CHAIN only if something was changed
|
||||
then
|
||||
echo "UPDATING CHAIN"
|
||||
echo "$(date -u +%s%N | cut -b1-13)" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/.timestamp
|
||||
echo $I > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${mediakey}/.chain
|
||||
fi
|
||||
echo "${mediakey} NAME PUBLISHING "
|
||||
# KEY ZenTag IPNS name publish
|
||||
J=$(ipfs name publish --quieter -k ${mediakey} /ipfs/${I})
|
||||
|
||||
echo "$id REFRESHED ${I}
|
||||
https://tube.copylaradio.com/ipns/$J
|
||||
http://127.0.0.1:8080/ipns/$J"
|
||||
########################################################################
|
||||
########################################################################
|
||||
break ## ONE BY ONE (cron_MINUTE.sh task every 7 mn)
|
||||
done
|
||||
|
||||
########################################################################
|
||||
########################################################################
|
||||
## TAKE CARE OF PIN CREATED THROUGH autoPINfriends.sh
|
||||
## Then refresh MEDIAKEY IPNS/IPFS RELATION
|
||||
## CORRECT ISSUE : https://git.p2p.legal/axiom-team/astrXbian/issues/25
|
||||
########################################################################
|
||||
for ipnslink in $(ls ~/.zen/PIN/*/IPNSLINK 2>/dev/null | shuf ); do
|
||||
ipnsid=$(cat $ipnslink)
|
||||
ipfsid=$(echo $ipnslink | cut -d '/' -f 6)
|
||||
mediakey=$(cat ~/.zen/PIN/${ipfsid}/MEDIAKEY)
|
||||
|
||||
# [[ ! $(echo "${mediakey}" | grep "TMDB_") ]] && continue ## REFRESH ONLY TMDB (level 1), youtube is level 0
|
||||
|
||||
[[ ! $(ipfs key list | grep ${mediakey}) ]] && echo "ERROR MISSING MEDIAKEY" && continue
|
||||
|
||||
## GET ACTUAL IPNS .chain VALUE
|
||||
mkdir -p /tmp/${mediakey}
|
||||
echo "${mediakey} GET IPNS"
|
||||
ipfs get -o /tmp/${mediakey} /ipns/$ipnsid
|
||||
[ $? -ne 0 ] && continue
|
||||
[ ! -s /tmp/${mediakey}/index.html ] && continue ## DO NOT REPUBLISH empty index.html
|
||||
|
||||
## REFRESH MORE THAN 6 HOURS TIMESTAMP KEY
|
||||
TIMESTAMP=$(cat /tmp/${mediakey}/.timestamp 2>/dev/null) # LAST REFRESH
|
||||
[[ ! $TIMESTAMP ]] && TIMESTAMP=$(cat /tmp/${mediakey}/*/.timestamp 2>/dev/null | tail -n 1 ) # INITIAL TIMESTAMP
|
||||
timestamp=$(date -u +%s%N | cut -b1-13)
|
||||
STAMPDIFF=$((timestamp - TIMESTAMP))
|
||||
echo "Last Update : $(date -d @$TIMESTAMP | cut -b1-10)" # remove millisecond part
|
||||
echo "PIN WAS LAST UPDATED $STAMPDIFF milliseconds AGO"
|
||||
[ $STAMPDIFF -lt 39600000 ] && continue # 11h = 39600000 ms / 12h = 43200000 ms
|
||||
|
||||
echo "Refresh MEDIAKEY PIN"
|
||||
NEWIPFS=$(ipfs add -rHq /tmp/${mediakey}/ | tail -n 1)
|
||||
|
||||
## PUBLISH IT
|
||||
ipfs name publish -k ${mediakey} --quieter /ipfs/$NEWIPFS
|
||||
|
||||
echo "$id PIN PUBLISH REFRESHED /ipfs/$NEWIPFS
|
||||
https://tube.copylaradio.com/ipns/$ipnsid
|
||||
http://127.0.0.1:8080/ipns/$ipnsid"
|
||||
|
||||
rm -Rf /tmp/${mediakey}
|
||||
|
||||
break ## DO ONE BY ONE
|
||||
done
|
||||
|
||||
########################################################################
|
502
tools/new_file_in_astroport.sh
Executable file
502
tools/new_file_in_astroport.sh
Executable file
@ -0,0 +1,502 @@
|
||||
#!/bin/bash
|
||||
########################################################################
|
||||
# Author: Fred (support@qo-op.com)
|
||||
# Version: 0.3
|
||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||
########################################################################
|
||||
# COPY ~/astroport/* files to IPFS
|
||||
# Publish INDEX ~/.zen/game/players/$PLAYER/ipfs/.*/${PREFIX}ASTRXBIAN
|
||||
######## #### ### ## #
|
||||
MY_PATH="`dirname \"$0\"`" # relative
|
||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||
ME="${0##*/}"
|
||||
countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|grep' | wc -l)
|
||||
[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0
|
||||
start=`date +%s`
|
||||
|
||||
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
|
||||
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID)
|
||||
[[ ! $IPFSNODEID ]] && echo 'ERROR missing IPFS Node id !! IPFS is not responding !?' && exit 1
|
||||
|
||||
|
||||
|
||||
|
||||
# ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN
|
||||
# Astropot/Kodi/Vstream source reads ${PREFIX}ASTRXBIAN from http://127.0.0.1:8080/.$IPFNODEID/
|
||||
# Index File Format (could be enhanced) is using Kodi TMDB enhancement
|
||||
# https://github.com/Kodi-vStream/venom-xbmc-addons/wiki/Voir-et-partager-sa-biblioth%C3%A8que-priv%C3%A9e#d%C3%A9clarer-des-films
|
||||
########################################################################
|
||||
## RUN inotifywait process ~/astroport/ NEW FILE DETECT
|
||||
# /usr/bin/inotifywait -r -e close_write -m /home/$YOU/astroport | while read dir flags file; do ~/.zen/Astroport.ONE/tools/new_file_in_astroport.sh "$dir" "$file"; done &
|
||||
# mkdir -p ~/astroport/youtube
|
||||
# mkdir -p ~/astroport/mp3
|
||||
########################################################################
|
||||
path="$1"
|
||||
|
||||
if [[ "$path" == "" ]]; then
|
||||
echo "## BATCH RUN. READ FIFO FILE."
|
||||
fi
|
||||
# Add trailing / if needed
|
||||
length=${#path}
|
||||
last_char=${path:length-1:1}
|
||||
[[ $last_char != "/" ]] && path="$path/"; :
|
||||
|
||||
file="$2"
|
||||
|
||||
G1PUB="$3"
|
||||
|
||||
echo "~/.zen/Astroport.ONE/tools/new_file_in_astroport.sh PATH/ \"$path\" FILE \"$file\" G1PUB \"$G1PUB\" "
|
||||
|
||||
extension="${file##*.}"
|
||||
TITLE="${file%.*}"
|
||||
|
||||
# .part file false flag correcting (inotify mode)
|
||||
[[ ! -f "${path}${file}" ]] && file="${TITLE%.*}" && extension="${TITLE##*.}" && [[ ! -f "${path}${file}" ]] && er="NO FILE" && echo "$er" && exit 1
|
||||
|
||||
# GET PLAYER
|
||||
PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null);
|
||||
[[ ! $PLAYER ]] && echo "No current player. Please Login" && exit 1
|
||||
|
||||
## Indicate what is the IPFSNODEID copying
|
||||
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}
|
||||
|
||||
[[ ! $(echo "$path" | cut -d '/' -f 4 | grep 'astroport') ]] && er="Les fichiers sont à placer dans ~/astroport/ MERCI" && echo "$er" && exit 1
|
||||
TYPE=$(echo "$path" | cut -d '/' -f 5 ) # ex: /home/$YOU/astroport/... TYPE(film, youtube, mp3, video, page)/ REFERENCE /
|
||||
CAT=$(echo "$TYPE" | awk '{ print tolower($0) }')
|
||||
|
||||
echo $CAT
|
||||
|
||||
PREFIX=$(echo "$TYPE" | head -c 1 | awk '{ print toupper($0) }' ) # ex: F, Y, M ou Y
|
||||
# File is placed in ROOT ~/astroport ?
|
||||
if [[ $PREFIX == "" ]]
|
||||
then
|
||||
[[ "$USER" != "xbian" ]] && zenity --warning --width 300 --text "Désolé votre fichier ne peut pas être traité"
|
||||
er="$er | WARNING. $TYPE is root file UNTREATED" && echo "$er" && exit 1
|
||||
fi
|
||||
|
||||
########################################################################
|
||||
# EXTRACT INDEX REFERENCE : TMDB or YOUTUBE (can be extended with new )
|
||||
########################################################################
|
||||
case ${CAT} in
|
||||
video)
|
||||
INDEXPREFIX="VIDEO_"
|
||||
REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
|
||||
TITLE="${file%.*}"
|
||||
;;
|
||||
youtube)
|
||||
INDEXPREFIX="YOUTUBE_"
|
||||
REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
|
||||
TITLE="${file%.*}"
|
||||
;;
|
||||
page)
|
||||
## DIFFERENT TREATMENT
|
||||
INDEXPREFIX="PAGE_"
|
||||
REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
|
||||
TITLE="${file%.*}"
|
||||
;;
|
||||
mp3)
|
||||
## DIFFERENT TREATMENT
|
||||
INDEXPREFIX="MP3_"
|
||||
REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
|
||||
TITLE=$(echo "$file" | cut -d "&" -f 2-)
|
||||
er="$er | Please use new_mp3_in_astroport.sh ... EXIT"
|
||||
echo "$er"
|
||||
exit 1
|
||||
;;
|
||||
film | serie)
|
||||
INDEXPREFIX="TMDB_"
|
||||
REFERENCE=$(echo "$path" | cut -d '/' -f 6 ) # Path contains TMDB id
|
||||
if ! [[ "$REFERENCE" =~ ^[0-9]+$ ]] # ${REFERENCE} NOT A NUMBER
|
||||
then
|
||||
er="$er | ERROR: $path BAD TMDB code. Get it from https://www.themoviedb.org/ or use your 06 phone number"
|
||||
echo "$er"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
## TODO ADD "httrack" for website copying
|
||||
## httrack "https://wiki.lowtechlab.org" -O "./wiki.lowtechlab.org" "+*.lowtechlab.org/*" -v -%l "fr"
|
||||
##
|
||||
*)
|
||||
er="$CAT inconnu" && echo "$er" && exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
MEDIAKEY="${INDEXPREFIX}${REFERENCE}"
|
||||
|
||||
########################################################################
|
||||
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/
|
||||
echo "ADDING ${path}${file} to IPFS and create ${PREFIX}ASTRXBIAN INDEX"
|
||||
echo "~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN"
|
||||
echo "-----------------------------------------------------------------"
|
||||
|
||||
IPFS=$(ipfs add -wq "${path}${file}")
|
||||
IPFSREPFILEID=$(echo $IPFS | cut -d ' ' -f 2)
|
||||
IPFSID=$(echo $IPFS | cut -d ' ' -f 1)
|
||||
[[ $IPFSREPFILEID == "" ]] && echo "ipfs add ERROR" && exit 1
|
||||
echo "-----------------------------------------------------------------"
|
||||
echo "IPFS $file DIRECTORY: ipfs ls /ipfs/$IPFSREPFILEID"
|
||||
echo "-----------------------------------------------------------------"
|
||||
echo "New $TYPE INDEX ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN "
|
||||
|
||||
URLENCODE_FILE_NAME=$(echo ${file} | jq -Rr @uri)
|
||||
|
||||
### MEDIAKEY FORGE
|
||||
########################################################################
|
||||
## CREATE NEW ipns KEY : ${MEDIAKEY}
|
||||
########################################################################
|
||||
## IPFS SELF IPNS DATA STORAGE
|
||||
## ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/
|
||||
########################################################################
|
||||
if [[ ! $(ipfs key list | grep -w "${MEDIAKEY}") ]]; then
|
||||
echo "CREATING NEW IPNS $MEDIAKEY"
|
||||
## IPNS KEY CREATION ?
|
||||
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}
|
||||
KEY=$(ipfs key gen "${MEDIAKEY}")
|
||||
# KEYFILE=$(ls -t ~/.ipfs/keystore/ | head -n 1) # get name of last created key (could be fooled during stargate exchange)
|
||||
KEYFILE=$(~/.zen/Astroport.ONE/tools/give_me_keystore_filename.py "${MEDIAKEY}") # better method applied
|
||||
fi
|
||||
|
||||
## IS IT NEW IPNS KEY?
|
||||
if [[ $KEY ]]; then
|
||||
# memorize IPNS key filename for easiest exchange
|
||||
echo "$KEYFILE" > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.key.keystore_filename
|
||||
# Publishing IPNS key
|
||||
echo "$KEY" > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link
|
||||
# CREATE .zen = ZEN economic value
|
||||
touch ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.zen
|
||||
# CREATE other encrypted copies for friends depending DEFCON & stars
|
||||
# > STARGATE 1 - 2 - 3 - 4 - 5 !!
|
||||
################ ENCRYPT keystore/$KEYFILE
|
||||
else
|
||||
KEY=$(cat ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link)
|
||||
KEYFILE=$(cat ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.key.keystore_filename)
|
||||
echo "## ALREADY EXISTING IPNS KEY $KEYFILE ($KEY)"
|
||||
fi
|
||||
|
||||
[[ ! $KEY ]] && echo "FATAL ERROR" && exit 1
|
||||
########################################################################
|
||||
## add default metadata (TODO = use json file?)
|
||||
########################################################################
|
||||
FILE_BSIZE=$(du -b "${path}${file}" | awk '{print $1}')
|
||||
echo "${FILE_BSIZE}" > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.filesize
|
||||
echo "${file}" > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipfs.filename
|
||||
echo "${TITLE}" > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.title
|
||||
echo "$(date -u +%s%N | cut -b1-13)" > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.timestamp
|
||||
## INIT MEDIAKEY .views.counter
|
||||
echo "0" > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.views.counter
|
||||
########################################################################
|
||||
|
||||
########################################################################
|
||||
# Prepare IPFS links (then cyphered to manage exchange regulation)
|
||||
########################################################################
|
||||
echo "/ipfs/$IPFSREPFILEID/${file}" > ~/.zen/tmp/.ipfs.filelink
|
||||
echo "$IPFSID" > ~/.zen/tmp/.ipfsid
|
||||
########################################################################
|
||||
|
||||
########################################################################
|
||||
################ ask autoPIN to one shuffle A_boostrap_nodes
|
||||
########################################################################
|
||||
PINIPFSnode=$(cat ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | grep -Ev "#" | shuf | tail -n 1)
|
||||
nodeid=${PINIPFSnode##*/}
|
||||
PINnode=$(~/.zen/Astroport.ONE/tools/ipfs_to_g1.py $nodeid)
|
||||
|
||||
echo "ASK AUTOPIN to $PINnode"
|
||||
## CREATE $PINnode IPFS communication directory
|
||||
if [[ ! -d ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode} && "$PINnode" != "$G1PUB" ]]; then
|
||||
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}
|
||||
## ENCRYPT .ipfsid & .ipfs.filelink (THESE FILES ARE
|
||||
$MY_PATH/natools.py encrypt -p $PINnode -i ~/.zen/tmp/.ipfs.filelink -o "~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.ipfs.filelink.encrypt"
|
||||
$MY_PATH/natools.py encrypt -p $PINnode -i ~/.zen/tmp/.ipfsid -o "~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.ipfsid.encrypt"
|
||||
# .ipfsid.encrypt is searched by each Station running ./zen/tools/autoPINfriends.sh
|
||||
fi
|
||||
|
||||
## Ask PIN to myself
|
||||
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${G1PUB}
|
||||
$MY_PATH/natools.py encrypt -p $G1PUB -i ~/.zen/tmp/.ipfs.filelink -o "~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${G1PUB}/.ipfs.filelink.encrypt"
|
||||
$MY_PATH/natools.py encrypt -p $G1PUB -i ~/.zen/tmp/.ipfsid -o "~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${G1PUB}/.ipfsid.encrypt"
|
||||
|
||||
|
||||
########################################################################
|
||||
## GREAT natools can convert IPNS MEDIAKEY into .dunikey file
|
||||
########################################################################
|
||||
# CREATING QRCODE
|
||||
$MY_PATH/natools.py privkey -f ipfs-keystore -k $HOME/.ipfs/keystore/$KEYFILE -F pubsec -o ~/.zen/tmp/${MEDIAKEY}.dunikey
|
||||
# PubFromDunikey=$(cat ~/.zen/tmp/${MEDIAKEY}.dunikey | grep "sec" | cut -d ' ' -f2 | base58 -d | tail -c+33 | base58) ## HOWTO EXTRACT PUBKEY FROM SECKEY
|
||||
PubFromDunikey=$(cat ~/.zen/tmp/${MEDIAKEY}.dunikey | grep "pub" | cut -d ' ' -f2)
|
||||
qrencode -s 6 -o "$HOME/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/QR.png" "$PubFromDunikey"
|
||||
echo "$PubFromDunikey" > $HOME/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/MEDIAPUBKEY
|
||||
|
||||
########################################################################
|
||||
## MEDIAKEY => DUNIKEY + PASS 6 DIGITS openssl protection
|
||||
########################################################################
|
||||
PASS=$(echo "${RANDOM}${RANDOM}${RANDOM}${RANDOM}" | tail -c-7) && echo "$PASS" > ~/.zen/tmp/${MEDIAKEY}.pass
|
||||
openssl enc -aes-256-cbc -salt -in ~/.zen/tmp/${MEDIAKEY}.dunikey -out "$HOME/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/dunikey.enc" -k $PASS
|
||||
|
||||
## STATION & BOOTSTRAP ACCESS TO PASS
|
||||
$MY_PATH/natools.py encrypt -p $G1PUB -i ~/.zen/tmp/${MEDIAKEY}.pass -o $HOME/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.pass.encrypt
|
||||
$MY_PATH/natools.py encrypt -p $PINnode -i ~/.zen/tmp/${MEDIAKEY}.pass -o $HOME/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.pass.encrypt
|
||||
|
||||
## DECODE MEDIAKEY.dunikey ##
|
||||
# ~/.zen/Astroport.ONE/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.pass.encrypt" -o "~/.zen/tmp/${MEDIAKEY}.pass"
|
||||
# openssl enc -aes-256-cbc -d -in "$HOME/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/dunikey.enc" -out "~/.zen/tmp/${MEDIAKEY}.dunikey" -k $(cat "~/.zen/tmp/${MEDIAKEY}.pass")
|
||||
rm ~/.zen/tmp/${MEDIAKEY}.dunikey
|
||||
|
||||
########################################################################
|
||||
## GET .ipfs/keystore file MAHE .ipns.mediakey.encrypt
|
||||
# used in ipns_TAG_refresh.sh & autoPINfriends.sh
|
||||
########################################################################
|
||||
$MY_PATH/natools.py encrypt -p $G1PUB -i $HOME/.ipfs/keystore/$KEYFILE -o $HOME/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.mediakey.encrypt
|
||||
$MY_PATH/natools.py encrypt -p $PINnode -i $HOME/.ipfs/keystore/$KEYFILE -o $HOME/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.ipns.mediakey.encrypt
|
||||
|
||||
## Init zen, views counters & visitor
|
||||
echo "0" > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.zen
|
||||
echo "0" > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.views.counter
|
||||
echo "anonymous" > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.visitor
|
||||
########################################################################
|
||||
# MEMORIZE my PIN
|
||||
mkdir -p ~/.zen/PIN/${IPFSREPFILEID}/
|
||||
touch ~/.zen/PIN/${IPFSREPFILEID}/${G1PUB}
|
||||
# echo "$(ipfs key list -l | grep ${MEDIAKEY} | cut -d ' ' -f 1)" > ~/.zen/PIN/${ipfsrepidfile}/IPNSLINK # NO!! CHOOSE TODO Would let PINing nodes change index.html///
|
||||
|
||||
########################################################################
|
||||
## encrypt links for myself
|
||||
########################################################################
|
||||
$MY_PATH/natools.py encrypt -p ${G1PUB} -i ~/.zen/tmp/.ipfs.filelink -o ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipfs.filelink.natools.encrypt
|
||||
$MY_PATH/natools.py encrypt -p ${G1PUB} -i ~/.zen/tmp/.ipfsid -o ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipfsid.encrypt
|
||||
rm ~/.zen/tmp/.ipfs.filelink
|
||||
rm ~/.zen/tmp/.ipfsid
|
||||
########################################################################
|
||||
|
||||
########################################################################
|
||||
## ADD "ajouter_video.txt" and "video.json" will be SELF IPNS publish data
|
||||
## ENCRYPT TO STOP CLEAR DATA LEAKING
|
||||
[[ -f ~/astroport/${TYPE}/${REFERENCE}/ajouter_video.txt ]] && cp -f ~/astroport/${TYPE}/${REFERENCE}/ajouter_video.txt ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/
|
||||
[[ -f ~/astroport/${TYPE}/${REFERENCE}/screen.png ]] && cp -f ~/astroport/${TYPE}/${REFERENCE}/screen.png ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/
|
||||
[[ -f ~/astroport/${TYPE}/${REFERENCE}/youtube.png ]] && cp -f ~/astroport/${TYPE}/${REFERENCE}/youtube.png ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/screen.png
|
||||
[[ -f ~/astroport/${TYPE}/${REFERENCE}/video.json ]] &&\
|
||||
cp -f ~/astroport/${TYPE}/${REFERENCE}/video.json ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ &&\
|
||||
cp -f ~/astroport/${TYPE}/${REFERENCE}/video.json ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/
|
||||
########################################################################
|
||||
|
||||
########################################################################
|
||||
## EXPLANATIONS
|
||||
########################################################################
|
||||
# What is being in ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/
|
||||
# is published on http://127.0.0.1:8080/ipns/$KEY/ AND ipfs ls /ipns/$KEY/
|
||||
########################################################################
|
||||
########################################################################
|
||||
# CONTRACTS, are small App (fulljs or jquery + nginx backend app server)
|
||||
# They must decrypt IPFS after succeeding a chalenge (, +/- n zen, ...)
|
||||
########################################################################
|
||||
# Contract App Examples (ipns_TAG_refresh.sh makes MEDIAKEY evolution)
|
||||
# Counting video views = +1 .views.counter => decrypt key
|
||||
# Balancing Zen wallets = -n form source = +n for destination => decrypt key
|
||||
########################################################################
|
||||
# Astroport/Gchange USE as public/private media copy friend of friends swarm
|
||||
# one star level (no encrypt)
|
||||
# index.html is presenting Astroport/Kodi service then redirect to
|
||||
# $G1PUB/index.html contains redirection to ipfs link
|
||||
## NEW RELEASE
|
||||
## Create TW5 index.html to give easy control access to MEDIAKEY and KEY owner
|
||||
########################################################################
|
||||
|
||||
########################################################################
|
||||
## IPNS access to index.html
|
||||
## Level 1 (not crypted) -> Redirect to ipfs streaming link
|
||||
|
||||
IPNSLINK=$(ipfs key list -l | grep -w ${MEDIAKEY} | cut -d ' ' -f 1)
|
||||
## FIRST REDIRECT PAGE ${MEDIAKEY}/index.html
|
||||
# https://tube.copylaradio.com/ipns/$IPNSLINK
|
||||
#envsubst < ./www/boris/youtube_watch_step2.html > ~/.zen/game/players/$PLAYER/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/index.html
|
||||
|
||||
echo "=======> Mediakey Welcome index.html "
|
||||
cat ~/.zen/Astroport.ONE/templates/boris/youtube_watch_step2.html \
|
||||
| sed "s/_IPNSLINK_/$IPNSLINK/g" \
|
||||
| sed "s/_IPFSNODEID_/$IPFSNODEID/g" \
|
||||
| sed "s/_PLAYER_/$PLAYER/g" \
|
||||