forked from STI/Astroport.ONE
UPGRADE v1.0 : CopierYoutube & MP3 tag detection make video link copied & converted to mp3
This commit is contained in:
parent
70c209682e
commit
6fb0996f89
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
########################################################################
|
||||
# Version: 0.4
|
||||
# Version: 1.0
|
||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||
########################################################################
|
||||
MY_PATH="`dirname \"$0\"`" # relative
|
||||
@ -47,10 +47,17 @@ tiddlywiki --load ${INDEX} \
|
||||
--render '.' 'CopierYoutube.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[CopierYoutube]]'
|
||||
|
||||
echo "DEBUG : cat ~/.zen/game/players/${PLAYER}/G1CopierYoutube/CopierYoutube.json | jq -r"
|
||||
## CHEK FOR MP3 TAG
|
||||
TAGS=()
|
||||
TAGS=($(cat ~/.zen/game/players/${PLAYER}/G1CopierYoutube/CopierYoutube.json | jq -r .[].tags))
|
||||
echo "TAGS :${#TAGS[@]}: ${TAGS[@]}"
|
||||
isMP3=$(echo ${TAGS[@] | grep -w "MP3")
|
||||
|
||||
## GET USER BROWSER for YOUTUBE COOKIES
|
||||
BZER=$(xdg-settings get default-web-browser | cut -d '.' -f 1 | cut -d '-' -f 1) ## GET cookies-from-browser
|
||||
[[ $BZER ]] && BROWSER="--cookies-from-browser $BZER " || BROWSER=""
|
||||
[[ ! $isLAN ]] && BROWSER=""
|
||||
|
||||
BZER=$(xdg-settings get default-web-browser | cut -d '.' -f 1 | cut -d '-' -f 1) ## GET cookies-from-browser
|
||||
[[ $BZER ]] && BROWSER="--cookies-from-browser $BZER " || BROWSER=""
|
||||
[[ ! $isLAN ]] && BROWSER=""
|
||||
###################################################################
|
||||
## URL EXTRACTION & yt-dlp.cache.${PLAYER} upgrade
|
||||
for YURL in $(cat ~/.zen/game/players/${PLAYER}/G1CopierYoutube/CopierYoutube.json | jq -r '.[].text' | grep 'http'); do
|
||||
@ -136,15 +143,13 @@ if [[ ! ${TIDDLER} ]]; then
|
||||
## EXTRA PARAM TO TRY
|
||||
# --write-subs --write-auto-subs --sub-langs "fr, en, en-orig" --embed-subs
|
||||
|
||||
if [[ ${isMP3} == "" ]]; then
|
||||
# copying video
|
||||
/usr/local/bin/yt-dlp -q -f "(bv*[ext=mp4][height<=720]+ba/b[height<=720])" \
|
||||
$BROWSER \
|
||||
--download-archive ${HOME}/.zen/.yt-dlp.list \
|
||||
-S res,ext:mp4:m4a --recode mp4 --no-mtime --embed-thumbnail --add-metadata \
|
||||
-o "${HOME}/.zen/tmp/yt-dlp/$TITLE.%(ext)s" ${ZYURL}
|
||||
|
||||
################################################################################
|
||||
### ADAPT TO TW RYTHM (DELAY COPY?)
|
||||
echo
|
||||
-o "${HOME}/.zen/tmp/yt-dlp/$TITLE.%(ext)s" "${ZYURL}"
|
||||
ZFILE="$TITLE.mp4"
|
||||
|
||||
############################################################################
|
||||
@ -173,6 +178,17 @@ if [[ ! ${TIDDLER} ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
else
|
||||
# copying mp3
|
||||
echo "TODO..."
|
||||
/usr/local/bin/yt-dlp -q -x --no-mtime --audio-format mp3 --embed-thumbnail --add-metadata \
|
||||
$BROWSER \
|
||||
--download-archive ${HOME}/.zen/.yt-dlp.list \
|
||||
-o "$HOME/Astroport/${PLAYER}/mp3/%(autonumber)s_%(title)s.%(ext)s" "${ZYURL}"
|
||||
|
||||
ZFILE="$TITLE.mp3"
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
####################################################
|
||||
@ -181,12 +197,12 @@ if [[ ! ${TIDDLER} ]]; then
|
||||
[[ ! $FILE_BSIZE ]] && echo "SIZE ERROR" && continue
|
||||
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] }')
|
||||
echo "$boucle - ${ZFILE} - FILE SIZE = $FILE_SIZE ($FILE_BSIZE octets)"
|
||||
|
||||
espeak "GOOD! Video Number $boucle = $FILE_SIZE" > /dev/null 2>&1
|
||||
|
||||
echo
|
||||
|
||||
### CREATE GIF ANIM : make_video_gifanim_ipfs.sh
|
||||
$(${MY_PATH}/../tools/make_video_gifanim_ipfs.sh "${HOME}/.zen/tmp/yt-dlp" "${ZFILE}" | tail -n 1) ## export ANIMH
|
||||
[[ ${isMP3} == "" ]] \
|
||||
&& $(${MY_PATH}/../tools/make_video_gifanim_ipfs.sh "${HOME}/.zen/tmp/yt-dlp" "${ZFILE}" | tail -n 1) ## export ANIMH
|
||||
|
||||
echo "HOP=$HOP
|
||||
ANIMH=$ANIMH
|
||||
PROBETIME=$PROBETIME
|
||||
@ -211,6 +227,8 @@ if [[ ! ${TIDDLER} ]]; then
|
||||
CHANNEL=$(/usr/local/bin/yt-dlp $BROWSER --print "%(channel)s" "${ZYURL}" | sed -r 's/\<./\U&/g' | sed 's/ //g') # CapitalGluedWords
|
||||
PLAYLIST=$(/usr/local/bin/yt-dlp $BROWSER --print "%(playlist)s" "${ZYURL}" | sed -r 's/\<./\U&/g' | sed 's/ //g')
|
||||
EXTRATAG="$CHANNEL $PLAYLIST"
|
||||
|
||||
if [[ ${isMP3} == "" ]]; then
|
||||
## PREPARE VIDEO HTML5 CODE
|
||||
TEXT="<video controls width=100% poster='/ipfs/"${ANIMH}"'>
|
||||
<source src='/ipfs/"${ILINK}"' type='"${MIME}"'>
|
||||
@ -219,6 +237,12 @@ if [[ ! ${TIDDLER} ]]; then
|
||||
{{!!filesize}} - {{!!duration}} sec. - vtratio(dur) = {{!!vtratio}} ({{!!dur}})
|
||||
<br>
|
||||
<h1><a href='"${ZYURL}"'>"${TITLE}"</a></h1>"
|
||||
else
|
||||
TEXT="<audio controls>
|
||||
<source src='/ipfs/"${ILINK}"' type='"${MIME}"'>
|
||||
Your browser does not support the audio element.
|
||||
</audio>"
|
||||
fi
|
||||
|
||||
end=`date +%s`
|
||||
dur=`expr $end - $start`
|
||||
|
Loading…
Reference in New Issue
Block a user