forked from axiom-team/astrXbian
add youtube copy... mp3 coming soon
This commit is contained in:
parent
dbfa87b922
commit
1dd5f5acfe
|
@ -88,22 +88,13 @@ YTURL=$(zenity --entry --width 300 --title "Lien ou identifiant à copier" --tex
|
|||
# Create TEMP directory
|
||||
YTEMP="/tmp/$(date -u +%s%N | cut -b1-13)"
|
||||
mkdir -p ${YTEMP}
|
||||
CONVERT=$(zenity --question --width 300 --title "Convertir en MP3 ?" --text "Voulez-vous convertir la vidéo en mp3?" )
|
||||
|
||||
# youtube-dl $YTURL
|
||||
if [ $? == 1 ]; then
|
||||
echo "VIDEO"
|
||||
echo "VIDEO $YTURL"
|
||||
/usr/local/bin/youtube-dl -f '[height=720]/best' \
|
||||
--write-info-json --write-annotations \
|
||||
--no-mtime -o "${YTEMP}/%(id)s_%(title)s.%(ext)s" $YTURL
|
||||
CAT="youtube"
|
||||
else
|
||||
echo "MP3"
|
||||
/usr/local/bin/youtube-dl -x --audio-format mp3 \
|
||||
--write-info-json --add-metadata --embed-thumbnail \
|
||||
--no-mtime -o "${YTEMP}/%(id)s_%(title)s.%(ext)s" $YTURL
|
||||
CAT="mp3"
|
||||
fi
|
||||
|
||||
# Get filename, extract ID, make destination dir and move copy.
|
||||
YFILE=$(ls -t ${YTEMP} | head -n 1)
|
||||
|
@ -124,7 +115,58 @@ GROUPES="${XZUID}"
|
|||
|
||||
rm -Rf ${YTEMP}
|
||||
;;
|
||||
|
||||
|
||||
########################################################################
|
||||
# CASE ## MP3
|
||||
########################################################################
|
||||
M)
|
||||
|
||||
# Create TEMP directory
|
||||
YTEMP="/tmp/$(date -u +%s%N | cut -b1-13)"
|
||||
mkdir -p ${YTEMP}
|
||||
|
||||
artist=$(zenity --entry --width 300 --title "Extraction MP3 depuis Youtube" --text "Artiste recherché ou Lien Youtube" --entry-text="")
|
||||
[[ $artist == "" ]] && exit 1
|
||||
|
||||
## CHECK if artist is LINK or ID
|
||||
length=${#artist}
|
||||
islink=$(echo "$artist" | grep "http")
|
||||
if [[ ! $islink || $length != 11 ]]
|
||||
then
|
||||
# Ask for song name
|
||||
song=$(zenity --entry --width 300 --title "Titre à chercher sur Youtube" --text "Titre recherché" --entry-text="")
|
||||
[[ $song == "" ]] && exit 1
|
||||
fi
|
||||
|
||||
# Download mp3 from 1st youtube search video result
|
||||
/usr/local/bin/youtube-dl --default-search ytsearch1: --download-archive /home/$USER/.ytdl.list \
|
||||
--continue --no-overwrites --ignore-errors --no-mtime \
|
||||
--embed-thumbnail --metadata-from-title "%(artist)s - %(title)s" --add-metadata \
|
||||
--extract-audio --audio-format mp3 -o "${YTEMP}/%(id)s_%(title)s.%(ext)s" "$artist $song"
|
||||
|
||||
# Get filename, extract ID, make destination dir and move copy.
|
||||
YFILE=$(ls -t ${YTEMP} | head -n 1)
|
||||
FILE_NAME="$(basename "${YFILE}")"
|
||||
FILE_EXT="${FILE_NAME##*.}"
|
||||
|
||||
YID=$(echo "${FILE_NAME}" | cut -d "_" -f 1)
|
||||
YNAME=$(echo "${FILE_NAME}" | cut -d "_" -f 2)
|
||||
|
||||
FILE_PATH="$HOME/astroport/$CAT/$artist/"
|
||||
mkdir -p ${FILE_PATH} && mv ${YTEMP}/* ${FILE_PATH}/
|
||||
|
||||
TMDB=$YID
|
||||
|
||||
TITLE="${YNAME%.*}"
|
||||
GENRES="[MP3]"
|
||||
GROUPES="${XZUID}"
|
||||
|
||||
## TODO call mazash to get audiofingerprint
|
||||
# curl -X POST "http://localhost:8600/api/v1/mazash/recognize" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"cid\":\"QmU3XRYZiebdDMcUwKrvecxyDgtgVY6zaNYrzQBeCkFb2r\",\"extension\":\".mp3\",\"song\":\"${TITLE}\"}"
|
||||
|
||||
rm -Rf ${YTEMP}
|
||||
|
||||
;;
|
||||
########################################################################
|
||||
# CASE ## DEFAULT
|
||||
########################################################################
|
||||
|
|
|
@ -40,7 +40,8 @@ echo '
|
|||
( I | P | N | S )
|
||||
\_/ \_/ \_/ \_/
|
||||
|
||||
ZENTAG KEY REFRESH $MyCODE
|
||||
ZENTAG KEY REFRESH
|
||||
MyCODE = $MyCODE
|
||||
'
|
||||
echo "I am /ipns/$IPFSNODEID controling and refreshing my KEY ZenTag"
|
||||
|
||||
|
@ -52,6 +53,8 @@ do
|
|||
count=$((count+1))
|
||||
IPNSLINK=$(ipfs key list -l | grep ${id} | cut -d ' ' -f 1)
|
||||
FILE_NAME=$(cat ~/.zen/KEY/${id}/${G1PUB}/.ipfs.filename)
|
||||
TITLE=$(cat ~/.zen/KEY/${id}/${G1PUB}/.title)
|
||||
|
||||
### IPNS LINK CAN EVOLVE (REFRESH EVERY 12 H TO MAINTAIN ALIVE IN THE SWARM)
|
||||
echo "<meta http-equiv=\"Refresh\" content=\"10;URL=https://aries.copylaradio.com/ipns/$IPNSLINK/${G1PUB}/\">
|
||||
<h1><a href='https://astroport.com'>ASTROPORT</a>/KODI</h1>
|
||||
|
|
|
@ -61,9 +61,11 @@ case ${PREFIX} in
|
|||
Y)
|
||||
INDEXPREFIX="YOUTUBE_"
|
||||
REFERENCE=$(echo "$file" | cut -d "_" -f 1) # Youtube filename starts with ID_
|
||||
TITLE=$(echo "$TITLE" | cut -d "_" -f 2)
|
||||
;;
|
||||
M)
|
||||
INDEXPREFIX="MP3TUBE_"
|
||||
## DIFFERENT TREATMENT
|
||||
INDEXPREFIX="MP3_"
|
||||
REFERENCE=$(echo "$file" | cut -d "_" -f 1) # Youtube filename starts with ID_
|
||||
;;
|
||||
F | S | A)
|
||||
|
@ -147,6 +149,7 @@ $MY_PATH/tools/natools.py encrypt -p $G1PUB -i ~/.zen/KEY/${INDEXPREFIX}${REFERE
|
|||
rm ~/.zen/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/.ipfs.filelink
|
||||
|
||||
echo "${file}" > ~/.zen/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/.ipfs.filename
|
||||
echo "${TITLE}" > ~/.zen/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/.title
|
||||
|
||||
# TRANSFERT "ajouter_video.txt" later used
|
||||
[[ -f ~/astroport/${TYPE}/${REFERENCE}/ajouter_video.txt ]] && mv ~/astroport/${TYPE}/${REFERENCE}/ajouter_video.txt ~/.zen/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/
|
||||
|
|
Loading…
Reference in New Issue