Lancer la copie d'une URL par PLAYER
This commit is contained in:
parent
75cf71307f
commit
6fb049c192
102
API/PLAYER.sh
102
API/PLAYER.sh
|
@ -24,27 +24,27 @@ Server: Astroport.ONE
|
|||
Content-Type: text/html; charset=UTF-8
|
||||
|
||||
"
|
||||
echo "- $PLAYER - $APPNAME : $WHAT $OBJ $VAL"
|
||||
[[ ! $PLAYER ]] && (echo "$HTTPCORS BAD PLAYER - EXIT" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && exit 1
|
||||
ASTRONAUTENS=$(ipfs key list -l | grep -w $PLAYER | cut -d ' ' -f1)
|
||||
[[ ! $ASTRONAUTENS ]] && (echo "$HTTPCORS UNKNOWN PLAYER $PLAYER - EXIT" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && exit 1
|
||||
echo "- ${PLAYER} - ${APPNAME} : ${WHAT} ${OBJ} ${VAL}"
|
||||
[[ ! ${PLAYER} ]] && (echo "${HTTPCORS} BAD PLAYER - EXIT" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && exit 1
|
||||
ASTRONAUTENS=$(ipfs key list -l | grep -w ${PLAYER} | cut -d ' ' -f1)
|
||||
[[ ! ${ASTRONAUTENS} ]] && (echo "${HTTPCORS} UNKNOWN PLAYER ${PLAYER} - EXIT" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && exit 1
|
||||
|
||||
##############################################
|
||||
# MOATUBE : /?player=PLAYER&moa=json&tag=FILTER
|
||||
##############################################
|
||||
if [[ $APPNAME == "moa" ]]; then
|
||||
if [[ ${APPNAME} == "moa" ]]; then
|
||||
|
||||
[[ ! $VAL ]] && VAL="G1CopierYoutube"
|
||||
echo "EXPORT MOATUBE $PLAYER $VAL"
|
||||
[[ ! ${VAL} ]] && VAL="G1CopierYoutube"
|
||||
echo "EXPORT MOATUBE ${PLAYER} ${VAL}"
|
||||
|
||||
tiddlywiki --load ~/.zen/game/players/$PLAYER/ipfs/moa/index.html --output ~/.zen/tmp/ --render '.' "$PLAYER.moatube.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' "[tag[$VAL]]"
|
||||
tiddlywiki --load ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html --output ~/.zen/tmp/ --render '.' "${PLAYER}.moatube.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' "[tag[${VAL}]]"
|
||||
|
||||
if [[ ! $WHAT || $WHAT == "json" ]]; then
|
||||
if [[ ! ${WHAT} || ${WHAT} == "json" ]]; then
|
||||
|
||||
echo "$HTTPCORS" > ~/.zen/tmp/${MOATS}.$PLAYER.http
|
||||
sed -i "s~text/html~application/json~g" ~/.zen/tmp/${MOATS}.$PLAYER.http
|
||||
cat ~/.zen/tmp/$PLAYER.moatube.json >> ~/.zen/tmp/${MOATS}.$PLAYER.http
|
||||
cat ~/.zen/tmp/${MOATS}.$PLAYER.http | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &
|
||||
echo "${HTTPCORS}" > ~/.zen/tmp/${MOATS}.${PLAYER}.http
|
||||
sed -i "s~text/html~application/json~g" ~/.zen/tmp/${MOATS}.${PLAYER}.http
|
||||
cat ~/.zen/tmp/${PLAYER}.moatube.json >> ~/.zen/tmp/${MOATS}.${PLAYER}.http
|
||||
cat ~/.zen/tmp/${MOATS}.${PLAYER}.http | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &
|
||||
|
||||
fi
|
||||
|
||||
|
@ -56,76 +56,24 @@ Content-Type: text/html; charset=UTF-8
|
|||
##############################################
|
||||
# YOUTUBE : /?player=PLAYER&youtube=_URL_
|
||||
##############################################
|
||||
if [[ $APPNAME == "youtube" ]]; then
|
||||
if [[ ${APPNAME} == "youtube" ]]; then
|
||||
|
||||
[[ ! $WHAT ]] && WHAT="https://www.youtube.com/watch?v=BCl2-0HBJ2c"
|
||||
echo "COPY YOUTUBE $PLAYER $WHAT"
|
||||
[[ ! ${WHAT} ]] && WHAT="https://www.youtube.com/watch?v=BCl2-0HBJ2c"
|
||||
echo "COPY YOUTUBE ${PLAYER} ${WHAT}"
|
||||
|
||||
G1PUB=$(cat ~/.zen/game/players/${PLAYER}/.g1pub)
|
||||
[[ ! $G1PUB ]] && espeak "NOT MY PLAYER " && echo "$PLAYER IS NOT MY PLAYER" && exit 1
|
||||
[[ ! ${G1PUB} ]] && espeak "NOT MY PLAYER " && echo "${PLAYER} IS NOT MY PLAYER" && exit 1
|
||||
|
||||
## PREPARE tiddler
|
||||
echo '[
|
||||
{
|
||||
"created": "'${MOATS}'",
|
||||
"modified": "'${MOATS}'",
|
||||
"title": "'♥BOX'",
|
||||
"type": "'text/vnd.tiddlywiki'",
|
||||
"text": "'$WHAT'",
|
||||
"g1pub": "'${G1PUB}'",
|
||||
"tags": "'CopierYoutube ${PLAYER}'"
|
||||
}
|
||||
]
|
||||
' > "$HOME/.zen/tmp/CoeurBOX.json"
|
||||
echo "================================================"
|
||||
echo "${PLAYER} : ${myIPFS}/ipns/${ASTRONAUTENS}"
|
||||
echo " = /ipfs/${TW}"
|
||||
echo "================================================"
|
||||
|
||||
rm -f ~/.zen/tmp/$PLAYER.html
|
||||
${MY_PATH}/../ajouter_media.sh "${WHAT}" "${PLAYER}" "Video" &
|
||||
|
||||
## REMPLACE le Tiddler "CopierYoutube"
|
||||
tiddlywiki --load ~/.zen/game/players/$PLAYER/ipfs/moa/index.html \
|
||||
--deletetiddlers '[tag[CopierYoutube]]' \
|
||||
--output ~/.zen/tmp/ --render "$:/core/save/all" "one.html" "text/plain"
|
||||
|
||||
[[ -s ~/.zen/tmp/one.html ]] && echo "tag[CopierYoutube] removed"
|
||||
|
||||
tiddlywiki --load ~/.zen/tmp/one.html \
|
||||
--import "$HOME/.zen/tmp/CoeurBOX.json" "application/json" \
|
||||
--output ~/.zen/tmp/ --render "$:/core/save/all" "$PLAYER.html" "text/plain"
|
||||
|
||||
[[ ! -s ~/.zen/tmp/$PLAYER.html ]] && echo "ERROR NO TW RESULTING" && exit 0
|
||||
echo "~/.zen/tmp/$PLAYER.html OK"
|
||||
## ANY CHANGES ?
|
||||
##############################################################
|
||||
DIFF=$(diff ~/.zen/tmp/$PLAYER.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html)
|
||||
if [[ $DIFF ]]; then
|
||||
echo "DIFFERENCE DETECTED !! "
|
||||
echo "Backup & Upgrade TW local copy..."
|
||||
cp ~/.zen/tmp/$PLAYER.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
|
||||
else
|
||||
echo "SAME TW"
|
||||
exit 0
|
||||
fi
|
||||
##############################################################
|
||||
|
||||
##################################################
|
||||
##################################################
|
||||
################## UPDATING PLAYER MOA
|
||||
[[ $DIFF ]] && cp ~/.zen/game/players/$PLAYER/ipfs/moa/.chain \
|
||||
~/.zen/game/players/$PLAYER/ipfs/moa/.chain.$(cat ~/.zen/game/players/$PLAYER/ipfs/moa/.moats)
|
||||
|
||||
TW=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ipfs/moa/index.html | tail -n 1)
|
||||
ipfs name publish --allow-offline -t 24h --key=$PLAYER /ipfs/$TW
|
||||
|
||||
[[ $DIFF ]] && echo $TW > ~/.zen/game/players/$PLAYER/ipfs/moa/.chain \
|
||||
&& echo $MOATS > ~/.zen/game/players/$PLAYER/ipfs/moa/.moats
|
||||
|
||||
echo "================================================"
|
||||
echo "$PLAYER : $myIPFS/ipns/$ASTRONAUTENS"
|
||||
echo " = /ipfs/$TW"
|
||||
echo "================================================"
|
||||
|
||||
echo "$HTTPCORS" > ~/.zen/tmp/${MOATS}.$PLAYER.http
|
||||
echo "$myIPFS/ipns/$ASTRONAUTENS" >> ~/.zen/tmp/${MOATS}.$PLAYER.http
|
||||
cat ~/.zen/tmp/${MOATS}.$PLAYER.http | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &
|
||||
echo "${HTTPCORS}" > ~/.zen/tmp/${MOATS}.${PLAYER}.http
|
||||
echo "${myIPFS}/ipns/${ASTRONAUTENS}" >> ~/.zen/tmp/${MOATS}.${PLAYER}.http
|
||||
cat ~/.zen/tmp/${MOATS}.${PLAYER}.http | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &
|
||||
|
||||
# ### REFRESH CHANNEL COPY
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ GET /?player=${PLAYER}&moa=json&tag=G1CopierYoutube
|
|||
| `tag` | `${VAL}` | TW filtering default G1CopierYoutube |
|
||||
|
||||
|
||||
### Modifier URL du G1Voeu "G1CopierYoutube" du PLAYER
|
||||
### Lancer la copie Video d'une URL Youtube par PLAYER
|
||||
```http
|
||||
GET /?player=${PLAYER}&youtube=URLENCODED
|
||||
```
|
||||
|
@ -274,7 +274,7 @@ GET /?player=${PLAYER}&youtube=URLENCODED
|
|||
| `player` | `string` | **Required**. Your EMAIL token |
|
||||
| `youtube` | `string` | **Required** URL = Video URL |
|
||||
|
||||
MORE TEST NEEDED
|
||||
|
||||
|
||||
### QRCODE (API SandBox)
|
||||
```http
|
||||
|
|
Loading…
Reference in New Issue