astroport/zen/xbian_vstream.sh

69 lines
2.6 KiB
Bash
Raw Normal View History

2020-12-08 02:22:33 +01:00
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.12.05
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
2020-12-08 21:29:50 +01:00
# Transfert ~/astroport/files to IPFS
# Create Astroport(pastebin) index for Xbian/Vstream
# ipfs publish with xbian key
2020-12-08 02:22:33 +01:00
########################################################################
2020-12-08 02:39:04 +01:00
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid ]] && echo "ERROR no _xbian.zuid" && exit 1
2020-12-08 02:22:33 +01:00
2020-12-08 13:37:59 +01:00
mkdir -p ~/astroport/films
mkdir -p ~/astroport/series
mkdir -p ~/astroport/animes
2020-12-08 21:29:50 +01:00
# GET XZUID
2020-12-08 02:22:33 +01:00
XZUID=$(cat ~/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid)
2020-12-08 21:29:50 +01:00
echo "CREATE ~/.zen/ipfs/xbian/F$XZUID FROM ~/astroport/films"
2020-12-08 13:37:59 +01:00
echo "-----------------------------------------------------------------"
2020-12-08 02:22:33 +01:00
# CREATE Vstream/Pastebin file format
# https://github.com/Kodi-vStream/venom-xbmc-addons/wiki/Voir-et-partager-sa-biblioth%C3%A8que-priv%C3%A9e#d%C3%A9clarer-des-films
2020-12-08 13:37:59 +01:00
echo "ADDING ~/astroport/films/ to IPFS"
echo "-----------------------------------------------------------------"
AFSHARE=$(ipfs add -rq ~/astroport/films/ | tail -n 1)
[[ $AFSHARE == "" ]] && echo "ipfs add ERROR" && exit 1
2020-12-08 02:22:33 +01:00
2020-12-08 13:37:59 +01:00
echo "WRITE ~/.zen/ipfs/xbian/F$XZUID Films index"
echo "-----------------------------------------------------------------"
2020-12-08 03:23:05 +01:00
mkdir -p ~/.zen/ipfs/xbian
2020-12-08 21:29:50 +01:00
echo "TITLE;URLS" > ~/.zen/ipfs/xbian/F${XZUID}
2020-12-08 13:37:59 +01:00
for file in ~/astroport/films/*
2020-12-08 02:22:33 +01:00
do
filename=$(basename -- "$file")
extension="${filename##*.}"
filena="${filename%.*}"
2020-12-08 21:29:50 +01:00
echo "$filena;http://localhost:8080/ipfs/$AFSHARE/$filename" >> ~/.zen/ipfs/xbian/F${XZUID}
2020-12-08 02:22:33 +01:00
done
2020-12-08 03:23:05 +01:00
2020-12-08 13:37:59 +01:00
### TODO
### ADD Animes
### ADD Series
2020-12-08 03:23:05 +01:00
2020-12-08 13:37:59 +01:00
echo "PUBLISH ~/.zen/ipfs to IPNS self"
echo "-----------------------------------------------------------------"
MIPFS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --quieter /ipfs/$MIPFS)
2020-12-08 21:29:50 +01:00
ipfs cat /ipns/$NODEIPNS/xbian/F${XZUID}
2020-12-08 13:37:59 +01:00
echo "SYNCing SWARM..."
echo "-----------------------------------------------------------------"
~/.zen/astroport/zen/ipfs_SWARM_refresh.sh
2020-12-08 13:37:59 +01:00
echo "PREPARE my local FASTRXBIAN (films) list from ipfs_swarm"
echo "-----------------------------------------------------------------"
2020-12-08 13:42:30 +01:00
mkdir -p /tmp/xbian/
echo 'TITLE;URL' > /tmp/xbian/FASTRXBIAN
cat ~/.zen/ipfs_swarm/xbian/F*-* | grep -v -E 'TITLE;URL' >> /tmp/xbian/FASTRXBIAN
2020-12-08 21:29:50 +01:00
cat /tmp/xbian/FASTRXBIAN | uniq > /tmp/xbian/FASTRXBIAN.uniq
mv /tmp/xbian/FASTRXBIAN.uniq /tmp/xbian/FASTRXBIAN
2020-12-08 13:37:59 +01:00
echo "PUBLISH IPNS with 'xbian' key"
echo "-----------------------------------------------------------------"
2020-12-08 13:42:30 +01:00
ISTREAM=$(ipfs add -qrw /tmp/xbian/ | tail -n 1)
ipfs name publish -k xbian $ISTREAM