forked from axiom-team/astrXbian
71 lines
2.8 KiB
Bash
Executable File
71 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
########################################################################
|
|
# Author: Fred (support@qo-op.com)
|
|
# Version: 2020.12.05
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
########################################################################
|
|
# Transfert ~/astroport/films to IPFS
|
|
# Create Astroport(pastebin) index for Xbian/Vstream
|
|
# ipfs publish ~/.zen/xbian/INDEXes with xbian key
|
|
########################################################################
|
|
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid ]] && echo "ERROR no _xbian.zuid" && exit 1
|
|
|
|
mkdir -p ~/astroport/films
|
|
|
|
# GET XZUID
|
|
XZUID=$(cat ~/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid)
|
|
|
|
# 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
|
|
|
|
### Films
|
|
echo "ADDING ~/astroport/films/ to IPFS. should be only one file"
|
|
echo "-----------------------------------------------------------------"
|
|
|
|
AFSHARE=$(ipfs add -rq ~/astroport/films | tail -n 1)
|
|
[[ $AFSHARE == "" ]] && echo "ipfs add ERROR" && exit 1
|
|
|
|
echo "WRITE own ~/.zen/ipfs/xbian/F$XZUID Films index"
|
|
echo "-----------------------------------------------------------------"
|
|
mkdir -p ~/.zen/ipfs/xbian
|
|
[[ ! -f ~/.zen/ipfs/xbian/F${XZUID} ]] && echo "CAT;TITLE;URLS" > ~/.zen/ipfs/xbian/F${XZUID}
|
|
|
|
file="$1"
|
|
filename=$(basename -- "$file")
|
|
extension="${filename##*.}"
|
|
filena="${filename%.*}"
|
|
echo "films;$filena;http://127.0.0.1:8181/ipfs/$AFSHARE/$filename" >> ~/.zen/ipfs/xbian/F${XZUID}
|
|
|
|
rm -f "/home/$YOU/astroport/films/$file"
|
|
cat ~/.zen/ipfs/xbian/F${XZUID} | uniq > /tmp/F${XZUID}
|
|
mv /tmp/F${XZUID} ~/.zen/ipfs/xbian/F${XZUID}
|
|
|
|
########################################################################
|
|
echo "PUBLISH ~/.zen/ipfs to IPNS self"
|
|
echo "-----------------------------------------------------------------"
|
|
MIPFS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
|
|
NODEIPNS=$(ipfs name publish --quieter /ipfs/$MIPFS)
|
|
|
|
ipfs cat /ipns/$IPFSNODEID/xbian/F${XZUID}
|
|
|
|
echo "SYNCing SWARM..."
|
|
echo "-----------------------------------------------------------------"
|
|
~/.zen/astrXbian/zen/ipfs_SWARM_refresh.sh
|
|
|
|
echo "PREPARE GLOBAL FASTRXBIAN (animes) global swarm list from ipfs_swarm"
|
|
echo "-----------------------------------------------------------------"
|
|
mkdir -p /tmp/xbian/
|
|
mkdir -p ~/.zen/xbian/
|
|
|
|
echo 'CAT;TITLE;URL' > /tmp/xbian/FASTRXBIAN
|
|
# Get all animes published in swarm
|
|
cat ~/.zen/ipfs_swarm/xbian/F* | grep -v -E 'CAT;TITLE;URL' >> /tmp/xbian/FASTRXBIAN
|
|
# Create global swarm animes index
|
|
cat /tmp/xbian/FASTRXBIAN | uniq > ~/.zen/xbian/FASTRXBIAN
|
|
|
|
echo "PUBLISH ~/.zen/xbian/ IPNS with 'xbian' key"
|
|
echo "-----------------------------------------------------------------"
|
|
ISTREAM=$(ipfs add -qrw ~/.zen/xbian/ | tail -n 1)
|
|
ipfs name publish -k xbian $ISTREAM
|
|
|