forked from qo-op/bunkerbox
Compare commits
21 Commits
Author | SHA1 | Date |
---|---|---|
fred | 1b24fef56f | |
fred | a1bb442f9b | |
fred | 24f17bff85 | |
fred | 1c125dbb18 | |
fred | 2106e33025 | |
fred | 980a790826 | |
fred | b099dcfaf6 | |
fred | 6b5aef215d | |
fred | 0b43802a97 | |
fred | 948fe6b8dd | |
fred | b65951d648 | |
fred | 01b2977b9f | |
fred | 3e5582763e | |
fred | d728bc7264 | |
fred | abf7cb9cd9 | |
fred | cccb06c1e0 | |
fred | 8ad26c7aa1 | |
fred | 823a5f758e | |
fred | 4a62d602fc | |
fred | 2d504528db | |
fred | 5df729f2a7 |
108
crowdbunker.sh
108
crowdbunker.sh
|
@ -7,8 +7,14 @@
|
|||
mkdir -p ~/.zen/bunkerbox # BunkerBOX temp directory
|
||||
# Fred MadeInZion, [20/03/2022 23:03]
|
||||
# Script qui capture et transfert dans IPFS le flux des nouvelles vidéos de https://crowdbunker.com/
|
||||
# le resultat est inscrit dans une chaine video accessible localement ou publiée au travers de qo-op
|
||||
# ou du TestNET astrXbian, videoclub entre amis d'amis...
|
||||
# le resultat est inscrit dans une chaine video accessible localement ou publiée au travers de la clef paratgée entre toutes les station scraper "qo-op"
|
||||
# ~/.zen/bunkerbox/ contient les fichiers publiés sur le CDN
|
||||
# ~/.zen/bunkerbox/cache/$VUID/media (cache de la copie)
|
||||
# ~/.zen/bunkerbox/history.json et history_${hier}.json permettent de parcourir les captures de chaque jour
|
||||
# ~/.zen/bunkerbox/history_qo-op.json : Historique diffusé actuellement par 'qo-op'
|
||||
# ~/.zen/bunkerbox/history.${CHANNEL}.json : Historique des channels crowdbunker
|
||||
# ~/.zen/bunkerbox/homepage/ : Zone de publication des fichiers publiés sur "qo-op"
|
||||
|
||||
|
||||
MY_PATH="`dirname \"$0\"`" # relative
|
||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||
|
@ -27,7 +33,7 @@ MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
|
|||
|
||||
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || echo " warning ipfs daemon not running"
|
||||
isLAN=$(hostname -I | awk '{print $1}' | head -n 1 | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
|
||||
IPFSNODEID=$(ipfs id --timeout=1s | jq -r .ID)
|
||||
IPFSNODEID=$(ipfs id --timeout=12s | jq -r .ID)
|
||||
howmany=$(cat /tmp/ipfsbunk.timeout)
|
||||
if [[ ! $IPFSNODEID ]]; then
|
||||
## wait a howmany timeout before restarting ipfs
|
||||
|
@ -170,13 +176,14 @@ echo "##########################################################################
|
|||
## NO OR EMPTY HISTORY? COPY from TEMPLATE (PROGRAM START)
|
||||
[[ ! -f ~/.zen/bunkerbox/history.json || $(cat ~/.zen/bunkerbox/history.json 2>/dev/null) == "" ]] && cp ${MY_PATH}/templates/data/history.json ~/.zen/bunkerbox/history.json
|
||||
|
||||
# get latest history.json publishes with (shared?) 'qo-op' IPNS key
|
||||
# get latest history.json. Please publish with conscienciously privately shared 'qo-op' IPNS key.
|
||||
# Use DNSLink to integrate into your DNS plan
|
||||
if [[ "$(cat ~/.zen/bunkerbox/choice 2>/dev/null)" == "qo-op" ]]; then
|
||||
[[ $(cat ~/.zen/bunkerbox/history_qo-op.json | jq .Videos[].link | grep $VUID) ]] && echo "VIDEO DEJA DANS LE CACHE... CONTINUE" && continue
|
||||
IPNS="$(ipfs key list -l | grep -w 'qo-op' | cut -f 1 -d ' ')"
|
||||
IPNSL="/ipns/$IPNS"
|
||||
ipfs get -o ~/.zen/bunkerbox/history_qo-op.json $IPNSL/history.json # Get actual IPNS qo-op history.json
|
||||
# Missing file... reseting
|
||||
# Missing file ? reseting
|
||||
[[ ! -f ~/.zen/bunkerbox/history_qo-op.json || $(cat ~/.zen/bunkerbox/history_qo-op.json 2>/dev/null) == "" ]] && cp ${MY_PATH}/templates/data/history.json ~/.zen/bunkerbox/history_qo-op.json
|
||||
[[ $(cat ~/.zen/bunkerbox/history_qo-op.json | jq .Videos[].link | grep $VUID) ]] && echo "VIDEO DEJA DANS LE RESEAU... CONTINUE" && echo && cp ~/.zen/bunkerbox/history_qo-op.json ~/.zen/bunkerbox/history.json && continue
|
||||
# JSON FUSION
|
||||
|
@ -237,7 +244,7 @@ echo "##########################################################################
|
|||
######################### ######################### #########################
|
||||
## CONSTRUCT 'MOA' CHANNEL PUBLICATION ZONE ```rm -Rf ~/.zen/bunkerbox/channels/${CHANNEL} to reset```
|
||||
AmIBootStrap=$(cat ~/.zen/astrXbian/A_boostrap_nodes.txt 2>/dev/null | grep $IPFSNODEID)
|
||||
if [[ ! -f ~/.zen/bunkerbox/homepage/tw/${CHANNEL}/twindex.html ]]; then
|
||||
if [[ ! -f ~/.zen/bunkerbox/homepage/tw/${CHANNEL}/index.html ]]; then
|
||||
mkdir -p ~/.zen/bunkerbox/homepage/tw/${CHANNEL}/
|
||||
mkdir -p ~/.zen/bunkerbox/channels/${CHANNEL}/
|
||||
# New tiddlywiki with moa key
|
||||
|
@ -277,17 +284,78 @@ echo "##########################################################################
|
|||
# cp ~/.ipfs/keystore/${channelfilename} ~/.zen/bunkerbox/channels/${CHANNEL}/qo-op_${CHANNEL}.key
|
||||
|
||||
echo $channelkey > ~/.zen/bunkerbox/channels/${CHANNEL}/channelkey
|
||||
echo "## PUBLISHING qo-op_${CHANNEL} /ipns/$channelkey"
|
||||
TW5=$(ipfs add -rwHq ~/.zen/bunkerbox/channels/${CHANNEL}/* | tail -n 1)
|
||||
ipfs name publish --key=qo-op_${CHANNEL} /ipfs/$TW5
|
||||
echo "LINK IT into HOMEPAGE "
|
||||
echo "<meta http-equiv=\"refresh\" content=\"0;URL=/ipns/$channelkey\">" > ~/.zen/bunkerbox/homepage/tw/${CHANNEL}/index.html
|
||||
echo "DONE ###"
|
||||
# else
|
||||
echo "$CHANNEL IS UP. KEY IS CREATED. WAITING FOR SYNCING. PRINTING KNOWN MOA KEY."
|
||||
ipfs key list -l | grep -w "qo-op_${CHANNEL}"
|
||||
# fi
|
||||
cp -f ~/.zen/bunkerbox/channels/${CHANNEL}/twindex.html ~/.zen/bunkerbox/homepage/tw/${CHANNEL}/index.html
|
||||
|
||||
fi
|
||||
|
||||
#~ echo "LINK TW into HOMEPAGE "
|
||||
#~ echo "<meta http-equiv=\"refresh\" content=\"0;URL=/ipns/$channelkey\">" > ~/.zen/bunkerbox/homepage/tw/${CHANNEL}/index.html
|
||||
#~ echo "DONE ###"
|
||||
TWINDEX="$HOME/.zen/bunkerbox/homepage/tw/${CHANNEL}/index.html"
|
||||
|
||||
TWMODEL="/ipfs/bafybeieqeozaj4nplyh7dmr2lecbzzrgt2mqs3rzbgdxlb43erhfzc37oq"
|
||||
## OLD index style REPLACE
|
||||
[[ $(cat ${TWINDEX} | head -n 1 | grep -w '"refresh"') ]] \
|
||||
&& echo "============= NEW TW MODEL ="
|
||||
ipfs cat $TWMODEL | sed \
|
||||
-e "s~_BIRTHDATE_~${MOATS}~g" \
|
||||
-e "s~_PSEUDO_~${CHANNEL}~g" \
|
||||
-e "s~_MOAID_~${channelkey}~g" \
|
||||
-e "s~_QOOP_~${IPNSL}~g" \
|
||||
-e "s~_IPFSNODEID_~${IPFSNODEID}~g" \
|
||||
-e "s~_MOAKEY_~qo-op_${CHANNEL}~g" \
|
||||
-e "s~k2k4r8kxfnknsdf7tpyc46ks2jb3s9uvd3lqtcv9xlq9rsoem7jajd75~${channelkey}~g" \
|
||||
> ${TWINDEX}
|
||||
|
||||
echo "$CHANNEL IS UP. KEY IS CREATED. WAITING FOR SYNCING. PRINTING KNOWN MOA KEY."
|
||||
ipfs key list -l | grep -w "qo-op_${CHANNEL}"
|
||||
echo "TODO: ADD MP4 VIDEO TIIDDLER INTO TW"
|
||||
|
||||
if [[ $(which tiddlywiki) ]]; then
|
||||
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
|
||||
FILE_BSIZE=$(du -b "$HOME/.zen/bunkerbox/cache/$VUID/media/" | awk '{print $1}' | tail -n 1)
|
||||
FILE_SIZE=$(echo "${FILE_BSIZE}" | awk '{ split( "B KB MB GB TB PB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } printf "%.2f %s", $1, v[s] }')
|
||||
|
||||
## LET'S DO THAT : MAKE A TIDDLER
|
||||
TEXT="<video controls preload='none' width='100%' height='360' poster='/ipfs/$IPFSROOT/$VUID.jpg'><source src='/ipfs/$IPFSROOT/$VUID.m3u8' type='application/x-mpegURL' /></video>"
|
||||
echo '[
|
||||
{
|
||||
"text": "'${TEXT}'",
|
||||
"title": "'${TITLE}'",
|
||||
"created": "'${MOATS}'",
|
||||
"resolution": "'${VSIZE}'",
|
||||
"duration": "'${DURATION}'",
|
||||
"mime": "'${MIME}'",
|
||||
"channel": "'${CHANNEL}'",
|
||||
"filesize": "'${FILE_SIZE}'",
|
||||
"size": "'${FILE_BSIZE}'",
|
||||
"poster": "'/ipfs/${IPFSROOT}/${VUID}.jpg'",
|
||||
"ipfsroot": "'/ipfs/${IPFSROOT}'",
|
||||
"ipfs": "'/ipfs/${IPFSROOT}/${VUID}.m3u8'",
|
||||
"mediakey": "'${VUID}'",
|
||||
"modified": "'${MOATS}'",
|
||||
"tags": "'BunkerBOX Astroport.ONE ipfs'"
|
||||
}
|
||||
]' > ~/.zen/bunkerbox/homepage/tw/${CHANNEL}/tiddler.${VUID}.json
|
||||
|
||||
echo " ~/.zen/bunkerbox/homepage/tw/${CHANNEL}/tiddler.${VUID}.json READY"
|
||||
|
||||
tiddlywiki --load ${TWINDEX} \
|
||||
--import ~/.zen/bunkerbox/homepage/tw/${CHANNEL}/tiddler.${VUID}.json "application/json" \
|
||||
--output ~/.zen/tmp --render "$:/core/save/all" "newindex.html" "text/plain"
|
||||
|
||||
if [[ -s ~/.zen/tmp/newindex.html ]]; then
|
||||
echo "OK TIDDLER. PUBLISHING. WAIT ..."
|
||||
cp ~/.zen/tmp/newindex.html ${TWINDEX}
|
||||
#~ TW5=$(ipfs add -rwHq ~/.zen/bunkerbox/channels/${CHANNEL}/* | tail -n 1)
|
||||
#~ echo "## PUBLISHING qo-op_${CHANNEL} /ipfs/$TW5"
|
||||
#~ ipfs name publish --key=qo-op_${CHANNEL} /ipfs/$TW5
|
||||
else
|
||||
echo "ERROR INSERTING TIDDLER"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
######################### ######################### #########################
|
||||
else
|
||||
echo "VIDEO ALREADY THERE"
|
||||
|
@ -299,8 +367,7 @@ echo "##########################################################################
|
|||
if [[ ! $IsThere ]]; then
|
||||
echo "Add $INDEX to ~/.zen/bunkerbox/cache/$VUID/media/history.json"
|
||||
## history.json Videos.link is the HTML code displayed in index.html with pagination.js (related to)
|
||||
cat ~/.zen/bunkerbox/history.json | jq '.Videos += [{"link": "<a id='"'_TSVUID_'"' href='"'_INDEX_'"'><img src='"'_INDEX_/_VUID_.jpg'"' height=80 ></a><br>'"'_TITLE_'"'"}]' > ~/.zen/bunkerbox/cache/$VUID/media/history.json
|
||||
# sed -i "s~_TSVUID_~$TS$VUID~g" ~/.zen/bunkerbox/cache/$VUID/media/history.json # Makes different chain for each creator !!
|
||||
cat ~/.zen/bunkerbox/history.json | jq '.Videos += [{"link": "<a id='"'_VUID_'"' href='"'_INDEX_'"'><img src='"'_INDEX_/_VUID_.jpg'"' height=80 ></a><br>'"'_TITLE_'"'"}]' > ~/.zen/bunkerbox/cache/$VUID/media/history.json
|
||||
sed -i "s~_INDEX_~$INDEX~g" ~/.zen/bunkerbox/cache/$VUID/media/history.json
|
||||
sed -i "s~_VUID_~$VUID~g" ~/.zen/bunkerbox/cache/$VUID/media/history.json
|
||||
sed -i "s~_TITLE_~$TITLE~g" ~/.zen/bunkerbox/cache/$VUID/media/history.json
|
||||
|
@ -410,7 +477,10 @@ echo "##########################################################################
|
|||
sed -i "s~_VUID_~$INDEX/$VUID~g" ~/.zen/bunkerbox/homepage/index.html
|
||||
sed -i "s/_WHO_/$(date -u "+%Y-%m-%d#%H:%M:%S")@$IPFSNODEID/g " ~/.zen/bunkerbox/homepage/index.html
|
||||
sed -i "s~_TITLE_~$TITLE~g" ~/.zen/bunkerbox/homepage/index.html
|
||||
TAGS=$(${MY_PATH}/tools/get_tagcloud_data.sh $IPNS)
|
||||
|
||||
${MY_PATH}/tools/get_tagcloud_data.sh $IPNS
|
||||
TAGS=$(cat ~/.zen/tmp/chan_cloud.json | jq -c .[])
|
||||
|
||||
sed -i "s~_TAGCLOUD_~$TAGS~g" ~/.zen/bunkerbox/homepage/index.html
|
||||
|
||||
# Copy json's
|
||||
|
|
|
@ -58,9 +58,6 @@
|
|||
</center>
|
||||
|
||||
<div id="videosList"><div class="wrapper"></div></div>
|
||||
<center>
|
||||
<div id="channels" class="row justify-center"></div>
|
||||
</center>
|
||||
|
||||
|
||||
<article>
|
||||
|
@ -86,7 +83,13 @@
|
|||
<a href="_IPNSL_"> _\/_ </a> powered by <a href="https://astroport.com"><span>"</span>Astroport<span>"</span></a>
|
||||
</h6>
|
||||
</center>
|
||||
|
||||
<center>
|
||||
<div id="channels" class="row justify-center"></div>
|
||||
</center>
|
||||
|
||||
</main>
|
||||
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
@ -166,11 +169,11 @@ $(document).ready(function() {
|
|||
},
|
||||
tag: {
|
||||
format: '<a href="{tag.link}">{tag.name}</a>: {tag.weight}',
|
||||
maxFontSize: 41, // max font size in pixels
|
||||
minFontSize: 8, // min font size in pixels
|
||||
maxFontSize: 21, // max font size in pixels
|
||||
minFontSize: 4, // min font size in pixels
|
||||
textShadow: true // enable text shadow
|
||||
},
|
||||
_TAGCLOUD_
|
||||
data: _TAGCLOUD_
|
||||
}
|
||||
$('#channels').tagCloud(options);
|
||||
});
|
||||
|
|
|
@ -2,13 +2,24 @@
|
|||
[[ ! $1 ]] && echo "You must provide 'qo-op' IPNS key"&& exit 1
|
||||
# echo create data set to include into tagcloud
|
||||
# HERE YOU CAN MODIFY HOMEPAGE TAGCLOUD PROPERTIES
|
||||
DATA=""
|
||||
IPNS="$1"
|
||||
|
||||
echo '{"data":[]}' > ~/.zen/tmp/chan_cloud.json
|
||||
|
||||
for channel in $(ls ~/.zen/bunkerbox/channels); do
|
||||
[[ -s ~/.zen/bunkerbox/history.${channel}.json ]] && howmuch=$(jq '.Videos | length' ~/.zen/bunkerbox/history.${channel}.json)
|
||||
[[ ! $howmuch ]] && continue
|
||||
|
||||
howmuch=$(jq '.Videos | length' ~/.zen/bunkerbox/history.${channel}.json)
|
||||
DATA="$DATA { name: '"${channel}"', link: '"/ipns/$1/tw/${channel}"', weight: "${howmuch}", tooltip: '"${channel}"' },"
|
||||
echo "Adding $channel ($howmuch videos)"
|
||||
[ $howmuch -gt 99 ] && BIGCHAN="${channel}($howmuch) $BIGCHAN" && howmuch=100
|
||||
[ $howmuch -lt 5 ] && LOWCHAN="${channel}($howmuch) $LOWCHAN" && continue
|
||||
|
||||
cat ~/.zen/tmp/chan_cloud.json | jq '.data += [{"name": "'''$channel'''", "link": "/ipns/'''$IPNS'''/tw/'''$channel'''", "weight": "'''$howmuch'''" ,"tooltip": "'''$channel'''"}]' > ~/.zen/tmp/chan_cloud_plus.json
|
||||
|
||||
cp ~/.zen/tmp/chan_cloud_plus.json ~/.zen/tmp/chan_cloud.json
|
||||
|
||||
done
|
||||
|
||||
echo 'data: [ '$DATA' ]'
|
||||
|
||||
## "data:" dans le template homepage.html
|
||||
# ~/.zen/tmp/chan_cloud.json
|
||||
|
|
Loading…
Reference in New Issue