ssb youtube-dl #zen command miam_miam.sh

This commit is contained in:
qo-op 2020-04-18 03:52:08 +02:00
parent 4c9cfea2e7
commit f9fc6148aa
9 changed files with 383 additions and 79 deletions

View File

@ -19,11 +19,16 @@ timebar=$(date +%H:%M)
##################################################################
if [[ "$1" == "" ]]; then
##################################################################
echo "It is $timebar in the morning, or in the night? It depends on your day..."
exit
echo "It is $timebar in the morning, or in the night?
It depends on your day... ONE LOVE 4 U Human on Gaia Planet"
exit 0
fi
##################################################################
# youtube-dl --rm-cache-dir
##################################################################
if [[ "$1" == "PRINT" ]]; then
##################################################################

View File

@ -1,20 +1,61 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
########################################################################
# IPFS CLEANING (MANUAL OPERATION)
########################################################################
ipfsnodeid=$(ipfs id -f='<id>\n')
echo "
_ _ ___ _ _ __
/ | |_ /\ |\ | | |_)|_(_
\_|_|_/--\| \| _|_| | __)
LOVE BANK RAZ
You will have to do it yourself...
I cannot erase me. I will loose all my memory.
Please be nice. Take care.
_ _ _ _
(_) | | ___ __ __ ___ | | | |
| | | | / _ \ \ \ / / / _ \ | | | |
| | | | | (_) | \ V / | __/ | |_| |
|_| |_| \___/ \_/ \___| \___/
>>> CLEAN IPFS REPO
### CLEAN IPFS REPO
##################################################################
ipfs pin ls -q --type recursive | xargs ipfs pin rm && ipfs repo gc
echo 'Are you sure? LOVE economy is made of LOVE...' && exit 1
### FORGET ZenTAG Wallets
##################################################################
rm -f ~/.ipfs/keystore/*.key
rm -Rf ~/.zen/tag/*
rm -Rf ~/.zen/ipfs/.$ipfsnodeid/TAG
##################################################################"
rm -Rf ~/.zen/ipfs_swarm/.Qm*
rm -Rf ~/.zen/ipfs_swarm/*
### EMPTY miam STOMACK
##################################################################
rm -Rf ~/.zen/miam/*
### FORGET G1 TX MEMORY
##################################################################
rm -Rf ~/.zen/cache/g1_TX_inputs/*
##################################################################
# TODO: Howto Make ERASE reversable ??
# BACKUP MYSELF in IPFS and Give pieces of my key to my friends... So if a part of you decide to keep me alive, I will still BE.
# TODO BACKUP BREAK MY KEY INTO ssss shards and put them in ~/.zen/ipfs/.QmFriends**/QmMeshard^* cyphered with its pubkey)
##################################################################
# WWWWOOOO, and what if Human life was the same...
# For you not to die, you need a minimum consciencious attention from part of the others that you are alive to continue living?
# Astonomical thought don't you thinks ;)
"

123
zen/miam_miam.sh Executable file
View File

@ -0,0 +1,123 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.04.16
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$ME' HELLO!! I am getting files from ~/.zen/miam
########################################################################
# ex: '$MY_PATH'/'$ME'
# MOVE ~/.zen/miam/* IN ZenTag AS PASSENGER
# Then find SSB same timestamp message and make a reply ;)
########################################################################
# [ASTROPORT](https://astroport.com)
########################################################################'
echo '
___
|\/| | /\ |\/| |_ ._ _ ._
| | _|_ /--\ | | | | |_| | | (_| | \/
_| /
'
for tstamp in $(ls ~/.zen/miam/); do
[ ! -d ~/.zen/miam/$tstamp ] && continue
[ -f ~/.zen/miam/$tstamp/msg_key ] && msg_key=$(cat ~/.zen/miam/$tstamp/msg_key) || echo "HEY I cannot find SSB message in $tstamp" || continue
echo "$msg_key"
msg=$(sbotc get '{"id":"'"$msg_key"'"}')
[[ $msg == "" ]] && echo "No SSB message for $tstamp" && continue
msg_root=$(printf %s "$msg" | jq -r .value.content.root)
msg_branch=$(printf %s "$msg" | jq -r .value.content.branch)
# TREATING miam $tstamp FILES
echo "##############################################################"
for file in ~/.zen/miam/$tstamp/*; do
# file --mime-type "$file"
filename=$(basename -- "$file")
extension="${filename##*.}"
filena="${filename%.*}"
case "$extension" in
json)
JSON="$file"
echo "# METADATA FILE"
echo "$filename"
extractor=$(cat "$file" | jq -r '.extractor')
if [[ $extractor == "youtube" ]]; then
id=$(cat "$file" | jq -r '.id')
fulltitle=$(cat "$file" | jq -r '.fulltitle')
description=$(cat "$file" | jq -r '.description')
artist=$(cat "$file" | jq -r '.artist')
album=$(cat "$file" | jq -r '.album')
duration=$(cat "$file" | jq -r '.duration')
upload_date=$(cat "$file" | jq -r '.upload_date')
uploader_id=$(cat "$file" | jq -r '.uploader_id')
echo "YOUTUBE: $id : $fulltitle ($duration s) by $uploader_id "
else
echo "ERROR Unknown METADATA TYPE, please add some code here..." && JSON=""
fi
continue
;;
jpg)
JPG="$file"
echo "# THUMBNAIL FILE"
echo "$filename"
convert "$file" -strip -resize 640 -format jpg ~/.zen/miam/$tstamp/ssb_thumb.jpg
continue
;;
mp4)
MP4="$file"
echo "# VIDEO FILE"
echo "$filename"
continue
;;
mp3)
MP3="$file"
echo "# AUDIO FILE"
echo "$filename"
continue
;;
*)
echo "TYPE UNKNOWN $file" && UNKOWN="$file"
continue
;;
esac
done
# File analyse finished...
# WHAT DO WE HAVE THERE?
[[ "$JSON" == "" ]] && echo "NO METADATA" && continue
[[ -f $MP3 ]] && $MY_PATH/zen_MAKE.sh "1000" "$tstamp" "$MP3" "10" "10" "$JSON" "$msg_key"
[[ -f $MP4 ]] && $MY_PATH/zen_MAKE.sh "1000" "$tstamp" "$MP4" "10" "10" "$JSON" "$msg_key"
echo "CONTINUE.............................. ?"
read
# CLEAN A LITTLE
UNKOWN=""
MP3=""
MP4=""
JPG=""
JSON=""
# rm -Rf ~/.zen/miam/$tstamp
done

View File

@ -14,7 +14,7 @@ echo '
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
# #zenyta = youtube-dl video to ~/.zen/zenyta/cache/$timestamp
# #zenyta = youtube-dl video to ~/.zen/miam/$timestamp
########################################################################
'
######## YOUTUBE-DL ##########
@ -24,7 +24,7 @@ if [[ ! $(which youtube-dl) ]]; then
sudo chown $USER /usr/local/bin/youtube-dl
fi
mkdir -p ~/.zen/zenyta/cache/
mkdir -p ~/.zen/miam/
self=$(sbotc whoami | jq -r .id) || exit 1
g1self=$(echo $self | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
@ -32,7 +32,7 @@ self_name=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"
ipfsnodeid=$(ipfs id -f='<id>\n')
current_ts=$(date -u +%s%N | cut -b1-13)
[ -f ~/.zen/zenyta/last.ts ] && last_ts=$(cat ~/.zen/zenyta/last.ts) || last_ts=$((current_ts - 10*24*3600*1000 - 1)) # 10*24h ago
[ -f ~/.zen/zenyta.last.ts ] && last_ts=$(cat ~/.zen/zenyta.last.ts) || last_ts=$((current_ts - 10*24*3600*1000 - 1)) # 10*24h ago
echo "
_
@ -50,6 +50,7 @@ messages=$(sbotc backlinks.read '{"query":[{"$filter":{"dest":"#zenyta","value":
while read -r msg
do
# EXTRACT CMD PARAM
msg_key=$(printf %s "$msg" | jq -r .key)
author=$(printf %s "$msg" | jq -r .value.author)
# echo $author
timestamp=$(printf %s "$msg" | jq -r .value.timestamp)
@ -66,13 +67,21 @@ do
# YOUTUBE-DL AUDIO
mkdir -p ~/.zen/zenyta/cache/$timestamp
mkdir -p ~/.zen/miam/$timestamp
/usr/local/bin/youtube-dl -x --audio-format mp3 \
--write-thumbnail --write-info-json --add-metadata --embed-thumbnail \
--no-mtime -o "~/.zen/zenyta/cache/$timestamp/%(title)s.%(id)s.%(ext)s" $msg_ytdlurl
--no-mtime -o "~/.zen/miam/$timestamp/%(id)s.%(ext)s" $msg_ytdlurl
# REFERENCE msg_key AND timestamp
echo "$timestamp" > ~/.zen/zenytv.last.ts
echo "$msg_key" > ~/.zen/miam/$timestamp/msg_key
rm ~/.zen/zenyta.last.ts
# MEMORIZE timestamp
#echo "$timestamp" > ~/.zen/zenyta/last.ts
rm ~/.zen/zenyta/last.ts
done < <(printf '%s\n' "$messages")
# AH AH AH ! My little mouse is shy ;)
#youtube-dl -x --no-mtime --audio-format mp3 -o "~/.zen/miam/$timestamp/%(title)s.%(id)s.%(ext)s" https://www.youtube.com/watch?v=jdVZwhdGqJU
#[youtube] jdVZwhdGqJU: Downloading webpage
#ERROR: unable to download video data: HTTP Error 403: Forbidden

View File

@ -14,7 +14,7 @@ echo '
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
# #zenytv = youtube-dl video to ~/.zen/zenytv/cache/$timestamp
# #zenytv = youtube-dl video to ~/.zen/miam/$timestamp
########################################################################
'
######## YOUTUBE-DL ##########
@ -24,7 +24,7 @@ if [[ ! $(which youtube-dl) ]]; then
sudo chown $USER /usr/local/bin/youtube-dl
fi
mkdir -p ~/.zen/zenytv/cache/
mkdir -p ~/.zen/miam/
self=$(sbotc whoami | jq -r .id) || exit 1
g1self=$(echo $self | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
@ -32,7 +32,7 @@ self_name=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"
ipfsnodeid=$(ipfs id -f='<id>\n')
current_ts=$(date -u +%s%N | cut -b1-13)
[ -f ~/.zen/zenytv/last.ts ] && last_ts=$(cat ~/.zen/zenytv/last.ts) || last_ts=$((current_ts - 100*24*3600*1000 - 1)) # 10*24h ago
[ -f ~/.zen/zenytv.last.ts ] && last_ts=$(cat ~/.zen/zenytv.last.ts) || last_ts=$((current_ts - 100*24*3600*1000 - 1)) # 100*24h ago
echo "
_
@ -50,6 +50,7 @@ messages=$(sbotc backlinks.read '{"query":[{"$filter":{"dest":"#zenytv","value":
while read -r msg
do
# EXTRACT CMD PARAM
msg_key=$(printf %s "$msg" | jq -r .key)
author=$(printf %s "$msg" | jq -r .value.author)
# echo $author
timestamp=$(printf %s "$msg" | jq -r .value.timestamp)
@ -66,13 +67,16 @@ do
# YOUTUBE-DL VIDEO
mkdir -p ~/.zen/zenytv/cache/$timestamp
mkdir -p ~/.zen/miam/$timestamp
/usr/local/bin/youtube-dl -f '[height=720]/best' \
--write-thumbnail --all-subs --write-info-json --write-annotations \
--no-mtime -o "~/.zen/zenytv/cache/$timestamp/%(title)s.%(id)s.%(ext)s" $msg_ytdlurl
# MEMORIZE timestamp
echo "$timestamp" > ~/.zen/zenytv/last.ts
--no-mtime -o "~/.zen/miam/$timestamp/%(id)s.%(ext)s" $msg_ytdlurl
# REFERENCE msg_key AND timestamp
echo "$timestamp" > ~/.zen/zenytv.last.ts
echo "$msg_key" > ~/.zen/miam/$timestamp/msg_key
rm ~/.zen/zenytv.last.ts # DEBUG
done < <(printf '%s\n' "$messages")

View File

@ -113,7 +113,7 @@ ipfs ls /ipns/$NODEIPNS
| | | | \ V /| | || (_| | |_| | (_) | | | |
|_|_| |_|\_/ |_|\__\__|_|\__|_|\___/|_| |_|
# This INVITE is to be sent an 'Astroport Station' willing to Join our IPFS Swarm.
# This INVITE is to be sent an to 'Astroport Station' willing to Join our IPFS Swarm.
# see 'ssb_SURVEY_contact.sh' for commands executed...
"

View File

@ -47,7 +47,7 @@ https://tube.p2p.legal/videos/watch/ef319fdd-caf1-4e03-ba22-91c456e94f73
}
'
# CACHE
[[ ! -d ~/.zen/cache/ssb_contact ]] && mkdir -p ~/.zen/cache/ssb_contact
[[ ! -d ~/.zen/ssb_contact ]] && mkdir -p ~/.zen/ssb_contact
self=$(sbotc whoami | jq -r .id) || exit 1
g1self=$(echo $self | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)

View File

@ -56,8 +56,6 @@ g1self=$(echo $self | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
self_name=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"'", "content":{"type":"about", "about": "'"$self"'"}}}}]}' | jq -r .value?.content?.name | grep -v null | tail -n 1)
ipfsnodeid=$(ipfs id -f='<id>\n')
# SEARCH "#astroport-swarmkey" CMD in message text
# Not working without patchwork (TODO: find bug. installation ok!? activate? ssb-server ssb-backlinks node_modules. HELP !! )
# messages=$(sbotc backlinks.read '{"query":[{"$filter":{"dest":"#astroport-swarmkey","value":{"content":{"type":"post"}}}}]}')
@ -65,18 +63,19 @@ ipfsnodeid=$(ipfs id -f='<id>\n')
# SCRIPT RUN BY cron_MINUTE.sh check last hour messages
current_ts=$(date -u +%s%N | cut -b1-13)
last_ts=$((current_ts - 3600000)) # timestamp from 1h ago
#messages=$(sbotc messagesByType '{"type":"post","gt":'$last_ts'}')
last_ts=$((current_ts - 24*3600*1000 - 1)) # timestamp from 24h ago
echo '
_ _
-|-|- _. __|_.__ ._ _ .__|___/ |\/|| \
-|-|-(_|_> |_|(_)|_)(_)| |_ \_| ||_/
|
sbotc messagesByType "post"
sbotc messagesByType "post" > $last_ts
'
messages=$(sbotc messagesByType '{"type":"post"}')
messages=$(sbotc messagesByType '{"type":"post","gt":'$last_ts'}')
#messages=$(sbotc messagesByType '{"type":"post"}') #DEBUG
while read -r msg
do

View File

@ -11,19 +11,21 @@ echo '
########################################################################
# \\///
# qo-op
############# '$ME' ZEN TXHASH FILE READ PARK
############# '$ME' ZEN ZENSOURCE FILE READ PARK
########################################################################
# ex: ./'$ME' 1000 TXHASH ./myfile.wav 1 10
# ex: '$MY_PATH'/'$ME' 1000 $ZENSOURCE $PASSENGER 1 10 $METADATA
# IPFS DATASTRUCTURE ~/.zen/tag/sha256sum(_tag.uid)
########################################################################
# [ASTROPORT](https://astroport.com)
########################################################################'
ZEN="$1" # Zen amount
TXHASH="$2" # G1 TX HASH
PASSENGER="$3" # /path/file.ext to include into ZenTag (add to IPFS datastructure)
ZENSOURCE="$2" # G1 TX HASH OR PASSENGER timestamp ~/.zen/miam/timestamp/
PASSENGER="$3" # ~/.zen/miam/timestamp/src_id.ext in ZenTag (add to IPFS datastructure)
READ="$4" # Zen amount asked to allow passenger reading
PARK="$5" # Zen amount payed for IPFS PIN by passenger everyday
METADATA="$6"
[[ $METADATA == "" && PASSENGER != "" ]] && echo "FilePath + Zen4Read + Zen4Park + Metada !!! Please" && exit 1
[[ $READ == "" ]] && READ=1
[[ $PARK == "" ]] && PARK=10
##############################################
@ -40,16 +42,17 @@ IPFS: $ipfsnodeid
/ / __/ | | | | | | |/ ___ \| . \| |___
/___\___|_| |_| |_| |_/_/ \_\_|\_\_____|
"
########################################################################
# ZenTag is an IPFS/IPNS datastructure put into IPFS, publish
# ZenTag is an IPFS/IPNS datastructure shared into IPFS, publish
# ~~~ Draft ~~~~ Draft ~~~~ Draft ~~~~ Draft ~~~~ Draft ~~~~
# _chain # ZenTag IPFS Hash
# _chain.n # Sequence Number
# _chain.nanodate # Current nanodate
# _chain.prev # Previous IPFS Hash
# _g1.node.creator # G1SSB wallet pubkey
# _g1.issuer # G1TX ISSUER pubkey
# _g1.txhash # G1TX HASH
# _tag.issuer # G1TX ISSUER pubkey
# _tag.zensource # G1TX HASH or SSB timestamp
# _ipfs.node.creatorcat # NODE IPFS ID
# _ipfs.publishkey.BB.aes # BB SYMcypher of IPNS publish key
# _ipfs.publishkey.crypt # G1SSB ASYMcypher of IPNS publish key
@ -60,16 +63,21 @@ IPFS: $ipfsnodeid
# PASSENGER FILE OPTIONNAL
# _passenger.filename # Passenger filename
# _passenger.ipfs.crypt # G1SSB cyphered IPFS Passenger link
# _passenger.read # Zen value asked for READING
# _passenger.park # Zen value paid for PARKING
# Read code to discover use.
# _passenger.read # Zen value asked for READING
# _passenger.park # Zen value paid for PARKING
# _passenger.contract.sh # Zen CONTRACT TODO
# COmpare with code to verify and extend Draft
# TODO: Could be converted into yaml or json if you like...
########################################################################
"
[[ $ZEN == "" || $TXHASH == "" ]] && echo "ERROR... Please provide Zen value" && exit 1
#TAG IS MANAGED BY NODE KEY OR BB KEY to change IPNS latest status
#INDEX UPDATE ON CURRENT NODE IPFS SWARM CHANNEL
# UNCOMMENT TO ACTIVATE (G1 <=> ZEN) STRICT RELATION
# ACTIVATES "GREEN FLAG" LIBRE ASTROPORT
[[ $ZEN == "" || $ZENSOURCE == "" ]] && echo "ERROR... Please provide Zen value" && exit 1
if [[ "$METADATA" == "" ]]; then
echo "
# LOVE BANK - PrePaid Card ZenTag
# FULLY BACKED ON IRL G1 LIBRE MONEY (https://cesium.app)
# ____ ____ _____ _____ _ _
# / ___| _ \| ____| ____| \ | | _______ _ __
@ -77,10 +85,29 @@ IPFS: $ipfsnodeid
# | |_| | _ <| |___| |___| |\ | / / __/ | | |
# \____|_| \_\_____|_____|_| \_| /___\___|_| |_|
#
# CONTROL IF TXHASH is REAL, see ./g1_TX2ZEN.sh for cache
#[[ ! -f ~/.zen/scan/zen.$TXHASH ]] && echo "ERROR# UNKNOWN TX $TXHASH !!" && exit 1
#ISSUER=$(cat ~/.zen/scan/zen.$TXHASH)
#[[ $ISSUER == "" ]] && echo "ERROR# NO ISSUER FOUND FOR TX $TXHASH !!" && exit 1
# CONTROL IF ZENSOURCE is REAL. (./g1_SURVEY.sh creates TX memory)
"
# COMMENT TO BREAK (G1 <=> ZEN) STRICT RELATION
[[ ! -f ~/.zen/scan/zen.$ZENSOURCE ]] && echo "ERROR# UNKNOWN ~/.zen/scan/zen.$ZENSOURCE !!" && exit 1
ISSUER=$(cat ~/.zen/scan/zen.$ZENSOURCE)
[[ $ISSUER == "" ]] && echo "ERROR# NO ISSUER FOUND FOR TX $ZENSOURCE !!" && exit 1
else
echo "
_|_ o ._ _ _ _ _|_ _. ._ _ ._
|_ | | | | (/_ _> |_ (_| | | | |_)
|
PASSENGER ~/.zen/miam/$ZENSOURCE
"
[[ ! -d ~/.zen/miam/$ZENSOURCE ]] && echo "ERROR# UNKNOWN ~/.zen/miam/$ZENSOURCE !!" && exit 1
ISSUER=$(cat ~/.zen/miam/$ZENSOURCE/msg_key)
[[ $ISSUER == "" ]] && echo "ERROR# NO ISSUER FOUND FOR miam $ZENSOURCE !!" && exit 1
fi
########################################################################
# CREATE ZEN TAG
@ -91,10 +118,10 @@ AAH=$(echo -n ${AA} | sha256sum | cut -d ' ' -f 1) # ZenTag Name SHA256
# TODO ACTIVATE SWARM UNICITY CHECK
# Create Unique Zentag for all IPFS SWARM!
#while [[ $(grep -Rwl "$AA" ~/.zen/ipfs_swarm/.Qm*/TAG/) ]]; do
# AA=$(echo $($MY_PATH/tools/diceware.sh 6 | xargs) | sed s/\ /_/g )
# AAH=$(echo -n ${AA} | sha256sum | cut -d ' ' -f 1)
#done
while [[ $(grep -Rwl "$AA" ~/.zen/ipfs_swarm/.Qm*/TAG/*/_tag.uid) ]]; do
AA=$(echo $($MY_PATH/tools/diceware.sh 6 | xargs) | sed s/\ /_/g )
AAH=$(echo -n ${AA} | sha256sum | cut -d ' ' -f 1)
done
# BB key is a 4 word diceware printed on QRCode for Human use.
# SHA512 PASSWORD CHECK FOR ALLOWING WRITE ACTION
@ -113,20 +140,19 @@ echo "
/ /| __/ | | | |/ ___ \ |_| | /_ _\
/____\___|_| |_|_/_/ \_\____| \/
${AAH}
$AA $ZEN Zen
*******************************************************
| $AA | $ZEN Zen
*******************************************************
CREATING ~/.zen/tag/${AAH}/
"
# COPY ZENTAG TO LOCAL ~/.zen/tag
echo "$AA" > ~/.zen/tag/${AAH}/_tag.uid # Nom du ZenTAG
echo "$ZEN" > ~/.zen/tag/${AAH}/_tag.zen # Tag ZEN amount
echo "${ipfsnodeid}" > ~/.zen/tag/${AAH}/_ipfs.node.creator # NODE IPFS ID
echo "$TXHASH" > ~/.zen/tag/${AAH}/_g1.txhash # HASH G1 TX/IN
echo "$ZENSOURCE" > ~/.zen/tag/${AAH}/_tag.zensource # ZENSOURCE
echo "$g1pub" > ~/.zen/tag/${AAH}/_g1.node.creator # CREATOR IPFS NODE G1PUBKEY
echo "$ISSUER" > ~/.zen/tag/${AAH}/_g1.issuer # TX ISSUER G1PUBKEY
echo "$ISSUER" > ~/.zen/tag/${AAH}/_tag.issuer # TX ISSUER G1PUBKEY OR SSB_MESSAGE ID
########################################################################
# Create IPNS publishing key ${AA}.key
@ -157,9 +183,15 @@ KEY : $BB
BBH : $BBH
"
#######################################################################
# PASSENGER FILE is added to IPFS then link is cyphered
# PASSENGER FILE is added to IPFS (then link is cyphered: NO!)
# https://beechat.network/how-beechats-encryption-works/
# SECURITY IS OBSOLETE AS WE ARE SHARING COPY WITH FRIENDS ;)
# ACTIVATE ZEN CONTRACT... 100 readers impresari
# LOVE ECONOMY IS FREE. EVERYBODY IS DONATING TO THE OTHERS NOW.
# INCOME != MONEY FORGE (Realtive Moey Theory applies HERE)
# CODE WILL BE CERTIFIED AS IPFS HASH.
if [[ -f $PASSENGER ]]; then
echo "
_ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \
@ -167,8 +199,17 @@ echo "
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
"
#echo "grep -Rwl "$ZENSOURCE" ~/.zen/ipfs_swarm/.Qm*/TAG/*/_tag.zensource" # DEBUG
CHECKSWARM=$(grep -Rwl "$ZENSOURCE" ~/.zen/ipfs_swarm/.Qm*/TAG/*/_tag.zensource | tail -n 1 | cut -f 6 -d '/')
#echo "grep -Rwl "$ZENSOURCE" ~/.zen/ipfs/.$ipfsnodeid/TAG/*/_tag.zensource" # DEBUG
[[ $CHECKSWARM == "" ]] && CHECKSWARM=$(grep -Rwl "$ZENSOURCE" ~/.zen/ipfs/.$ipfsnodeid/TAG/*/_tag.zensource | tail -n 1 | cut -f 6 -d '/')
[[ -f ~/.zen/ipfs/.$ipfsnodeid/TAG/$ZENSOURCE/_tag.issuer ]] && ISSUERSWARM=$(cat ~/.zen/ipfs/.$ipfsnodeid/TAG/$ZENSOURCE/_tag.issuer)
[[ "$CHECKSWARM" != "" && "$ISSUERSWARM" == "$ISSUER" ]] && rm ~/.ipfs/keystore/${AA}.key && rm -Rf ~/.zen/tag/${AAH} \
&& echo "$ZENSOURCE ALREADY COPIED IN IPFS SWARM. CANCEL" && exit 1
# ADD PASSENGER TO IPFS
IPASSENGER=$(ipfs add -q "$PASSENGER" -w | tail -n 1)
echo "$IPASSENGER" > ~/.zen/tag/${AAH}/_passenger.ipfs
# GET FILE NAME
PASSENGERNAME=$(basename -- "$PASSENGER")
@ -178,8 +219,9 @@ echo "
$MY_PATH/tools/natools.py encrypt -p $g1pub -i ~/.zen/tag/${AAH}/_passenger.ipfs -o ~/.zen/tag/${AAH}/_passenger.ipfs.crypt
# BB OWNER ACCESS
openssl aes-256-cbc -pbkdf2 -k "$BB" -salt -in ~/.zen/tag/${AAH}/_passenger.ipfs -out ~/.zen/tag/${AAH}/_passenger.ipfs.BB.aes
# CLEAN CLEARTEXT IPFS link
rm -r ~/.zen/tag/${AAH}/_passenger.ipfs
# CLEAN CLEARTEXT IPFS link ? LATER MAYBE
rm ~/.zen/tag/${AAH}/_passenger.ipfs
# ZEN ECONOMY: ZEN READ payment + PARK rental
echo "$READ" > ~/.zen/tag/${AAH}/_passenger.read
@ -188,6 +230,7 @@ echo "
echo "
_passenger.filename : $PASSENGERNAME
_passenger.ipfs : $IPASSENGER
http://127.0.0.1:8080/ipfs/$IPASSENGER/$PASSENGERNAME
# #### ## ##### ###### #####
# # # # # # # # # #
@ -202,13 +245,23 @@ _passenger.ipfs : $IPASSENGER
openssl aes-256-cbc -pbkdf2 -k \"$BB\" -d -salt -in ~/.zen/tag/${AAH}/_passenger.ipfs.BB.aes -out /tmp/_passenger.ipfs
ipfs get -o /tmp \"/ipfs/$IPASSENGER/$PASSENGERNAME\" && vlc \"/tmp/$PASSENGERNAME\" 2>/dev/null
READ : $READ Zen
PARK : $PARK Zen
"
cat > ~/.zen/tag/${AAH}/_passenger.contract.sh <<EOF
#!/bin/bash
# THIS CODE EXECUTE CONTRACT AND DECODE IPFS LINK.
BB="$1"
[[ "$BB" == "" ]] && echo "ERRROR You need a BB Key to decode your ipfs link to $PASSENGERNAME" && exit 1
# TODO ADD ZEN PAYMENT and Init P2P contract...
openssl aes-256-cbc -pbkdf2 -k \"$BB\" -d -salt -in ~/.zen/tag/\"${AAH}\"/_passenger.ipfs.BB.aes -out /tmp/_passenger.ipfs
ipfs get -o /tmp \"/ipfs/$IPASSENGER/$PASSENGERNAME\" && vlc \"/tmp/$PASSENGERNAME\" 2>/dev/null
exit 0
EOF
fi
########################################################################
# if [[ -d $PASSENGER ]]; then
# if [[ -d $PASSENGER ]]; then # NO FILE BY FILE IS BETTER...?!
########################################################################
# TODO # tar.gz and encrypt a whole directory #
# tar -zcf - directory | openssl aes-128-cbc -pbkdf2 -k "$BB" -salt -out directory.tar.gz.aes # Encrypt
@ -241,14 +294,33 @@ echo "${I}" > ~/.zen/tag/${AAH}/_chain
J=$(ipfs name publish -k ${AA}.key --quieter /ipfs/${I})
echo "${J}" > ~/.zen/tag/${AAH}/_ipns
# INDEXING ZenTag to SWARM
mkdir -p ~/.zen/ipfs/.$ipfsnodeid/TAG/${J}
echo "${AA}" > ~/.zen/ipfs/.$ipfsnodeid/TAG/${J}/_tag.uid
echo "${PASSENGERNAME}" > ~/.zen/ipfs/.$ipfsnodeid/TAG/${J}/_tag.passenger.filename
# TODO Publish on Node self : NAME + METADATA + ... ~/.zen/ipfs_swarm/ = global swarm INDEX
# echo "" > ~/.zen/ipfs/.$ipfsnodeid/TAG/${J}/_tag.passenger.metadata.json
# INDEXING ZenTag into SWARM
mkdir -p ~/.zen/ipfs/.$ipfsnodeid/TAG/${ZENSOURCE}/
echo "${AA}" > ~/.zen/ipfs/.$ipfsnodeid/TAG/${ZENSOURCE}/_tag.uid
echo "${ZENSOURCE}" > ~/.zen/ipfs/.$ipfsnodeid/TAG/${ZENSOURCE}/_tag.zensource
echo "${ISSUER}" > ~/.zen/ipfs/.$ipfsnodeid/TAG/${ZENSOURCE}/_tag.issuer
echo "${J}" > ~/.zen/ipfs/.$ipfsnodeid/TAG/${ZENSOURCE}/_tag.ipns
if [[ "${PASSENGERNAME}" != "" ]]; then
echo "${PASSENGERNAME}" > ~/.zen/ipfs/.$ipfsnodeid/TAG/${ZENSOURCE}/_tag.passenger.filename
# COPY METADATA!! TODO : Please Extend filesource FOR new metadata types. torrent ?
extractor=$(cat "$METADATA" | jq -r '.extractor')
youtubeid=$(cat "$METADATA" | jq -r '.id')
fulltitle=$(cat "$METADATA" | jq -r '.fulltitle')
# description=$(cat "$METADATA" | jq -r '.description')
artist=$(cat "$METADATA" | jq -r '.artist')
album=$(cat "$METADATA" | jq -r '.album')
duration=$(cat "$METADATA" | jq -r '.duration')
upload_date=$(cat "$METADATA" | jq -r '.upload_date')
uploader_id=$(cat "$METADATA" | jq -r '.uploader_id')
extractor=$(cat "$METADATA" | jq -r '.extractor')
[[ ! -f ~/.zen/ipfs/.$ipfsnodeid/TAG/${ZENSOURCE}/_tag.passenger.metadata.${extractor}.json ]] \
&& cp -f "${METADATA}" /tmp/
mv /tmp/${youtubeid}.info.json ~/.zen/ipfs/.$ipfsnodeid/TAG/${ZENSOURCE}/_tag.passenger.metadata.${extractor}.json
fi
ls ~/.zen/ipfs/.$ipfsnodeid/TAG/${ZENSOURCE}/
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
@ -260,10 +332,10 @@ echo "
/ / /_/ / __(__ )
/_/ .___/_/ /____/
/_/
$I
ipfs ls /ipfs/$I
ZenTAG : ipfs ls /ipns/$J
NODE index : ipfs ls /ipns/$NODEIPNS/.$ipfsnodeid
NODE index : ipfs ls /ipns/$NODEIPNS/.$ipfsnodeid/TAG/${ZENSOURCE}
"
########################################################################
@ -278,23 +350,74 @@ echo "
# READ QRCODE
qrencode -s 5 -o ~/.zen/tag/${AAH}/_QRCODE.read.png "RJ:${AA}#${J}"
# WRITE QRCODE
# TODO: best security cypher? but it is better to defend system than file ??? I think so.
# So consider well before using this code not under DEBIAN 10 it is tested for!
qrencode -s 5 -o ~/.zen/tag/${AAH}/_QRCODE.write.png "BJ:${BB}#${J}"
echo "CREATED !!
${AA}"
echo "QRCodes CREATED !!
See it :
xviewer ~/.zen/tag/${AAH}/_QRCODE.read.png &
xviewer ~/.zen/tag/${AAH}/_QRCODE.write.png &
${AA}
"
########################################################################
# SBOT PUBLISH
########################################################################
echo '
if [[ "${PASSENGERNAME}" != "" ]]; then
echo "$ISSUER"
msg="$(sbotc get '{"id":"'"$ISSUER"'"}')"
# echo "$msg" | jq #DEBUG
[[ $msg == "" ]] && echo "ERROR No SSB message for PASSENGER in $tstamp" && exit 1
msg_root=$(printf %s "$msg" | jq -r .value.content.root)
[[ $msg_root == "null" ]] && msg_root=$ISSUER
msg_branch=$(printf %s "$msg" | jq -r .value.content.branch)
[[ $msg_branch == "null" ]] && msg_branch=$ISSUER
# ATTACH ~/.zen/miam/$ZENSOURCE/ssb_thumb.jpg
name="ssb_thumb.jpg"
id="$(sbotc blobs.add < ~/.zen/miam/$ZENSOURCE/ssb_thumb.jpg)"
type="$(file -b --mime-type ~/.zen/miam/$ZENSOURCE/ssb_thumb.jpg)"
size="$(wc -c < ~/.zen/miam/$ZENSOURCE/ssb_thumb.jpg)"
export MESSAGE=$(cat << EOF
# ${fulltitle}
[![ssb_thumb.jpg](${id})](http://127.0.0.1:8080/ipfs/$IPASSENGER/$PASSENGERNAME)
[:pig_nose:_IPFS_:pig_nose:](http://127.0.0.1:8080/ipfs/$IPASSENGER/$PASSENGERNAME)
[${extractor}](https://youtu.be/${youtubeid}) ${duration} s by ${uploader_id}
**ZEN=$ZEN($READ/$PARK)**
#zenbot #astroport
EOF
)
echo "
__ _ ____
(_ |_)/ \|
__)|_)\_/| POST
'
sbotc publish '{"type":"post","text":"ZenTAG created : ipfs ls /ipns/$J"}'
root: $msg_root
branch: $msg_branch
"
echo "$MESSAGE"
INLINE=$(node -p "JSON.stringify(process.env.MESSAGE)" | sed 's/,/ /g')
echo '{"type":"post", "branch": "'"$msg_branch"'", "root": "'"$msg_root"'", "text":'${INLINE}',"mentions":[{"link":"'"$id"'","name":"'"$name"'","size":"'"$size"'","type":"'"$type"'"},{"link":"#zenbot"},{"link":"#astroport"}]}'
# sbotc publish '{"type":"post","text":"'"$MESSAGE"'", "branch": "'"$msg_branch"'", "root": "'"$msg_root"'"}' #2>&1>/dev/null
sbotc publish '{"type":"post", "branch": "'"$msg_branch"'", "root": "'"$msg_root"'", "text":'${INLINE}',"mentions":[{"link":"'"$id"'","name":"'"$name"'","size":"'"$size"'","type":"'"$type"'"},{"link":"#zenbot"},{"link":"#astroport"}]}'
# sbotc publish '{"type":"post","text":"${extra} ... ZenTAG created : ipfs ls /ipns/$J"}'
# SECURITY IS OBSOLETE AS WE ARE YUST SHARING COPY WITH FRIENDS ;)
fi
########################################################################
exit 0