forked from qo-op/bunkerbox
the best always comes
This commit is contained in:
parent
42739ab8ca
commit
3db9b35073
|
@ -36,47 +36,48 @@ cat ~/.zen/bunkerbox/crowd.json | jq -r '.posts | .[] | .video.id' > /tmp/vuid.l
|
|||
# Reverse list to start with older videos
|
||||
for VUID in $(tac /tmp/vuid.list); do
|
||||
[[ "$VUID" == "null" ]] && echo "MESSAGE... Bypassing..." && echo && continue
|
||||
echo "====================================================="
|
||||
echo "Bunker BOX : Adding $VUID"
|
||||
mkdir -p ~/.zen/bunkerbox/$VUID/media
|
||||
|
||||
URL="https://api.crowdbunker.com/post/$VUID/details"
|
||||
# echo "WISHING TO EXPLORE $URL ?"; read TEST; [[ "$TEST" != "" ]] && echo && continue
|
||||
curl -s $URL -H "Accept: application/json" -o ~/.zen/bunkerbox/$VUID/$VUID.json
|
||||
curl -s $URL -H "Accept: application/json" -o ~/.zen/bunkerbox/$VUID/media/$VUID.json
|
||||
|
||||
# STREAMING LIVE ?
|
||||
echo ">>> Extracting video caracteristics from ~/.zen/bunkerbox/$VUID/$VUID.json"
|
||||
ISLIVE=$(cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq -r .video.isLiveType)&& [[ "$ISLIVE" == "true" ]] && echo "LIVE... "
|
||||
LIVE=$(cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq -r .video.isLiveActive) && [[ "$LIVE" == "true" ]] && echo "STREAMING... Bypassing..." && echo && continue
|
||||
DURATION=$(cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq -r .video.duration) && [[ $DURATION == 0 ]] && echo "NOT STARTED YET" && echo && continue
|
||||
TITLE=$(cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq -r .video.title | sed "s/'/ /g" | sed 's/"/ /g') # Remove quote
|
||||
CHANNEL=$(cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq -r .channel.name)
|
||||
ORGUID=$(cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq -r .organization.uid)
|
||||
ORGNAME=$(cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq -r .organization.name)
|
||||
ORGBANNER=$(cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq -r .organization.banner.url)
|
||||
echo ">>> Extracting video caracteristics from ~/.zen/bunkerbox/$VUID/media/$VUID.json"
|
||||
ISLIVE=$(cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r .video.isLiveType)&& [[ "$ISLIVE" == "true" ]] && echo "LIVE... "
|
||||
LIVE=$(cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r .video.isLiveActive) && [[ "$LIVE" == "true" ]] && echo "STREAMING... Bypassing..." && echo && continue
|
||||
DURATION=$(cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r .video.duration) && [[ $DURATION == 0 ]] && echo "NOT STARTED YET" && echo && continue
|
||||
TITLE=$(cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r .video.title | sed "s/'/ /g" | sed 's/"/ /g') # Remove quote
|
||||
CHANNEL=$(cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r .channel.name)
|
||||
ORGUID=$(cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r .organization.uid)
|
||||
ORGNAME=$(cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r .organization.name)
|
||||
ORGBANNER=$(cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r .organization.banner.url)
|
||||
|
||||
HLS=$(cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq -r .video.hlsManifest.url)
|
||||
HLS=$(cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r .video.hlsManifest.url)
|
||||
MEDIASOURCE=$(echo $HLS | rev | cut -d '/' -f 2- | rev)
|
||||
echo "$TITLE ($DURATION s)"
|
||||
|
||||
## NO choice made, so ask to continue each loop
|
||||
[[ ! $(cat ~/.zen/bunkerbox/choice 2>/dev/null) ]] && echo "READY TO PROCESS ? ENTER. Any character sent means next." && read TEST && [[ "$TEST" != "" ]] && echo && continue ## NO CHOICE MADE
|
||||
|
||||
start=`date +%s`
|
||||
echo "$HLS"
|
||||
## Download HLS source m3u8 (contains video & audio)
|
||||
curl -s $HLS -o ~/.zen/bunkerbox/$VUID/$VUID.m3u8
|
||||
[[ ! $(cat ~/.zen/bunkerbox/choice 2>/dev/null) ]] && cat ~/.zen/bunkerbox/$VUID/$VUID.m3u8 # DEBUG
|
||||
|
||||
echo ">>>>>>>>>>>>>>>> Downloading VIDEO"
|
||||
# Choose 360p or 480p or 240p
|
||||
# Choose 360p or 480p or 720p or 240p
|
||||
VSIZE=360 && VIDEOHEAD=$(cat ~/.zen/bunkerbox/$VUID/$VUID.m3u8 | grep -B1 ${VSIZE}p | head -n 1) && VIDEOSRC=$(cat ~/.zen/bunkerbox/$VUID/$VUID.m3u8 | grep ${VSIZE}p | tail -n 1 | cut -f 1 -d '.')
|
||||
[[ "$VIDEOSRC" == "" ]] && VSIZE=480 && VIDEOHEAD=$(cat ~/.zen/bunkerbox/$VUID/$VUID.m3u8 | grep -B1 ${VSIZE}p | head -n 1) && VIDEOSRC=$(cat ~/.zen/bunkerbox/$VUID/$VUID.m3u8 | grep ${VSIZE}p | tail -n 1 | cut -f 1 -d '.')
|
||||
[[ "$VIDEOSRC" == "" ]] && VSIZE=720 && VIDEOHEAD=$(cat ~/.zen/bunkerbox/$VUID/$VUID.m3u8 | grep -B1 ${VSIZE}p | head -n 1) && VIDEOSRC=$(cat ~/.zen/bunkerbox/$VUID/$VUID.m3u8 | grep ${VSIZE}p | tail -n 1 | cut -f 1 -d '.')
|
||||
[[ "$VIDEOSRC" == "" ]] && VSIZE=240 &&VIDEOHEAD=$(cat ~/.zen/bunkerbox/$VUID/$VUID.m3u8 | grep -B1 ${VSIZE}p | head -n 1) && VIDEOSRC=$(cat ~/.zen/bunkerbox/$VUID/$VUID.m3u8 | grep ${VSIZE}p | tail -n 1 | cut -f 1 -d '.')
|
||||
## NO VIDEO ?
|
||||
[[ "$VIDEOSRC" == "" ]] && echo "NO COMPATIBLE RESOLUTION VIDEO FOUND." && cat ~/.zen/bunkerbox/$VUID/$VUID.m3u8 && continue
|
||||
|
||||
# THUMBNAIL
|
||||
VTHUMB="$(cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq -r --arg VSIZE "$VSIZE" '.video.thumbnails[] | select(.height == $VSIZE) | .url')"
|
||||
VTHUMB="$(cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r --arg VSIZE "$VSIZE" '.video.thumbnails[] | select(.height == $VSIZE) | .url')"
|
||||
echo ">>>>>>>>>>>>>>>> Downloading $VSIZE Thumbnail"
|
||||
[[ ! -f ~/.zen/bunkerbox/$VUID/media/$VUID.jpg ]] && curl -s $VTHUMB -o ~/.zen/bunkerbox/$VUID/media/$VUID.jpg
|
||||
[[ ! -f ~/.zen/bunkerbox/$VUID/media/$VUID.jpg ]] && cp ${MY_PATH}/images/astroport.jpg ~/.zen/bunkerbox/$VUID/media/$VUID.jpg # CORRECT MISSING THUMB
|
||||
|
@ -110,7 +111,7 @@ ls ~/.zen/bunkerbox/$VUID/media/ # SHOW ALL COLLECTED MEDIA
|
|||
|
||||
##########################################################################
|
||||
##########################################################################
|
||||
|
||||
start=`date +%s`
|
||||
echo "##########################################################################"
|
||||
echo ">>>>>>>>>>>>>>>> ADDING index.html"
|
||||
# COPY index, style, js AND data
|
||||
|
@ -119,31 +120,30 @@ echo "##########################################################################
|
|||
cp ${MY_PATH}/templates/videojs.html ~/.zen/bunkerbox/$VUID/media/index.html
|
||||
cp ${MY_PATH}/images/astroport.jpg ~/.zen/bunkerbox/$VUID/media/
|
||||
|
||||
## NO HISTORY? COPY from TEMPLATE (PROGRAM START)
|
||||
[[ ! -f ~/.zen/bunkerbox/history.json ]] && cp ${MY_PATH}/templates/data/history.json ~/.zen/bunkerbox/history.json
|
||||
## 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
|
||||
|
||||
# qo-op get latest history.json
|
||||
if [[ "$(cat ~/.zen/bunkerbox/choice 2>/dev/null)"=="qo-op" ]]; then
|
||||
if [[ "$(cat ~/.zen/bunkerbox/choice 2>/dev/null)" == "qo-op" ]]; then
|
||||
IPNSL="/ipns/$(cat ~/.zen/bunkerbox/qo-op)"
|
||||
ipfs get -o ~/.zen/bunkerbox/history.qo-op.json $IPNSL/history.json # Get actual IPNS qo-op history.json
|
||||
[[ $(cat ~/.zen/bunkerbox/history.qo-op.json | jq .Videos[].link | grep $VUID) ]] && echo "VIDEO DEJA DANS IPFS... CONTINUE" && echo && cp ~/.zen/bunkerbox/history.qo-op.json ~/.zen/bunkerbox/history.json && continue
|
||||
# JSON FUSION
|
||||
jq -s '.[0] * .[1]' ~/.zen/bunkerbox/history.json ~/.zen/bunkerbox/history.qo-op.json | jq -M '.Videos |= unique_by(.link)' > ~/.zen/bunkerbox/history.fusion.json
|
||||
jq -s '.[0] * .[1]' ~/.zen/bunkerbox/history.qo-op.json ~/.zen/bunkerbox/history.json | jq -M '.Videos |= unique_by(.link)' > ~/.zen/bunkerbox/history.fusion.json
|
||||
mv ~/.zen/bunkerbox/history.fusion.json ~/.zen/bunkerbox/history.json ## REPLACE LOCAL HISTORY CACHE
|
||||
else
|
||||
IPNSL="./"
|
||||
fi
|
||||
|
||||
# Add current/latest reversed history to media
|
||||
echo '{
|
||||
"Videos":' > ~/.zen/bunkerbox/$VUID/media/history.json
|
||||
echo '{ "Videos":' > ~/.zen/bunkerbox/$VUID/media/history.json
|
||||
cat ~/.zen/bunkerbox/history.json | jq '.[] | reverse' >> ~/.zen/bunkerbox/$VUID/media/history.json
|
||||
echo '}' >> ~/.zen/bunkerbox/$VUID/media/history.json
|
||||
|
||||
# Using relative links
|
||||
# COPY videojs.html TEMPLATE & Updating links
|
||||
sed "s/_IPFSROOT_/./g" ${MY_PATH}/templates/videojs.html > ~/.zen/bunkerbox/$VUID/media/index.html
|
||||
sed -i "s/_VUID_/$VUID/g" ~/.zen/bunkerbox/$VUID/media/index.html
|
||||
# sed -i s/_DATE_/$(date -u "+%Y-%m-%d#%H:%M:%S")/g ~/.zen/bunkerbox/$VUID/media/index.html # Different Copy Makes Different Chains !
|
||||
# sed -i s/_DATE_/$(date -u "+%Y-%m-%d#%H:%M:%S")/g ~/.zen/bunkerbox/$VUID/media/index.html # !! Different Copy Makes Different Chains !
|
||||
sed -i "s~_TITLE_~$TITLE~g" ~/.zen/bunkerbox/$VUID/media/index.html
|
||||
sed -i "s~_CHANNEL_~$CHANNEL~g" ~/.zen/bunkerbox/$VUID/media/index.html
|
||||
sed -i "s~_IPNSL_~$IPNSL~g" ~/.zen/bunkerbox/$VUID/media/index.html #MAJ IPNS link
|
||||
|
@ -155,29 +155,27 @@ echo "##########################################################################
|
|||
|
||||
VMAIN="/ipfs/$IPFSROOT/$VUID.m3u8"
|
||||
# UPDATING original JSON - TODO inform crowdbunker that IPFS copy is available.
|
||||
cat ~/.zen/bunkerbox/$VUID/$VUID.json | jq ".video.hlsManifest.url = \"$VMAIN\"" > ~/.zen/bunkerbox/$VUID/media/$VUID.json
|
||||
echo "M3U8 : $IPFSNGW$VMAIN"
|
||||
cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq ".video.hlsManifest.url = \"$VMAIN\"" > ~/.zen/bunkerbox/$VUID/$VUID.json
|
||||
echo "TODO: CALL BACK SOURCE ... New HLS = $IPFSNGW$VMAIN"
|
||||
|
||||
## UPDATE GLOCAL HISTORY ?
|
||||
IsThere=$(cat ~/.zen/bunkerbox/history.json | jq .Videos[].link | grep $VUID)
|
||||
if [[ ! $IsThere ]]; then
|
||||
echo "Add $INDEX to ~/.zen/bunkerbox/$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 href='"'_INDEX_'"'><img src='"'_INDEX_/_VUID_.jpg'"' height=80 ></a><br>'"'_TITLE_'"'"}]' > ~/.zen/bunkerbox/$VUID/media/history.json
|
||||
echo $INDEX
|
||||
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/$VUID/media/history.json
|
||||
# sed -i "s~_TSVUID_~$TS$VUID~g" ~/.zen/bunkerbox/$VUID/media/history.json # Makes different chain for each creator !!
|
||||
sed -i "s~_INDEX_~$INDEX~g" ~/.zen/bunkerbox/$VUID/media/history.json
|
||||
echo $VUID
|
||||
sed -i "s~_VUID_~$VUID~g" ~/.zen/bunkerbox/$VUID/media/history.json
|
||||
echo $TITLE
|
||||
sed -i "s~_TITLE_~$TITLE~g" ~/.zen/bunkerbox/$VUID/media/history.json
|
||||
|
||||
# COULD BE DONE LIKE THAT
|
||||
# cat ~/.zen/bunkerbox/$VUID/media/history.json | jq --arg INDEX "$INDEX" --arg TITLE "$TITLE" '.Videos += [{"link": "<a href='''$INDEX''' >'''$TITLE'''</a>"}]' > ~/.zen/bunkerbox/history.json
|
||||
echo "MISE A JOUR ~/.zen/bunkerbox/history.json"
|
||||
[[ "$(cat ~/.zen/bunkerbox/$VUID/media/history.json)" == "" ]] && echo "FATAL ERROR" && exit 1
|
||||
# Upgrade local history.json with reverse current one
|
||||
# Upgrade local history.json with reverse new one
|
||||
if [[ -f ~/.zen/bunkerbox/$VUID/media/history.json ]]; then
|
||||
echo '{
|
||||
"Videos":' > ~/.zen/bunkerbox/history.json
|
||||
echo '{ "Videos":' > ~/.zen/bunkerbox/history.json
|
||||
cat ~/.zen/bunkerbox/$VUID/media/history.json | jq '.[] | reverse' >> ~/.zen/bunkerbox/history.json
|
||||
echo '}' >> ~/.zen/bunkerbox/history.json
|
||||
fi
|
||||
|
@ -277,14 +275,10 @@ echo "##########################################################################
|
|||
"debug")
|
||||
echo "debug"
|
||||
> ~/.zen/bunkerbox/choice
|
||||
break
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
##########################################################################
|
||||
# cat ~/.zen/bunkerbox/$VUID/media/$VUID.json | jq -r .video.hlsManifest.url
|
||||
|
||||
end=`date +%s`; echo Duration `expr $end - $start` seconds.
|
||||
end=`date +%s`; echo ___Duration `expr $end - $start` seconds___
|
||||
|
||||
done
|
||||
|
|
|
@ -45,9 +45,11 @@
|
|||
<div id="videosList"><div class="wrapper"></div></div>
|
||||
</center>
|
||||
|
||||
<center>
|
||||
<h6>
|
||||
<a href="_IPNSL_"> _\/_ </a> powered by <a href="https://astroport.com"><span>"</span>Astroport<span>"</span></a>
|
||||
</h6>
|
||||
</center>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
|
@ -64,14 +66,14 @@ var player = videojs('vbunk', {
|
|||
</script>
|
||||
|
||||
<script>
|
||||
$.getJSON('./history.json', function (json) {
|
||||
$.getJSON('_IPNSL_/history.json', function (json) {
|
||||
$('#videosList').pagination({
|
||||
dataSource: json.Videos,
|
||||
pageSize: 1,
|
||||
callback: function(data, pagination) {
|
||||
var wrapper = $('#videosList .wrapper').empty();
|
||||
$.each(data, function (i, f) {
|
||||
$('#videosList .wrapper').append('<ul><li>' + f.link + '</li></ul>');
|
||||
$('#videosList .wrapper').append('<ul><li>div class="snippet-block">' + f.link + '</div></li></ul>');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue