From e98d0d1ebc76e98d03580c25449bb4ba86f222be Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 7 Mar 2023 14:58:12 +0100 Subject: [PATCH] fixing --- 12345.sh | 2 +- ajouter_media.sh | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/12345.sh b/12345.sh index 268b6de5..1d24a45c 100755 --- a/12345.sh +++ b/12345.sh @@ -73,7 +73,7 @@ while true; do ## CHECK PORT IS FREE & KILL OLD ONE pidportinuse=$(ps axf --sort=+utime | grep -w "nc -l -p ${PORT}" | grep -v -E 'color=auto|grep' | awk '{gsub(/^ +| +$/,"")} {print $0}' | tail -n 1 | cut -d " " -f 1) - [[ $pidportinuse ]] && kill -9 $pidportinuse && echo "KILLING LOST $pidportinuse" && continue + [[ $pidportinuse ]] && kill -9 $pidportinuse && echo "KILLING LOST $pidportinuse" ## CHECK 12345 PORT RUNNING (STATION FoF MAP) maprunning=$(ps auxf --sort=+utime | grep -w '_12345.sh' | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) diff --git a/ajouter_media.sh b/ajouter_media.sh index e3d4249a..af4c749a 100755 --- a/ajouter_media.sh +++ b/ajouter_media.sh @@ -73,7 +73,9 @@ PLAYERNS=$(myPlayerNs) || ( echo "noplayerns" && exit 1 ) ASTRONAUTENS=$(myAstroKey) [[ $ASTRONAUTENS == "" ]] && echo "ASTRONAUTE manquant" && espeak "Astronaut Key Missing" && exit 1 -BROWSER=$(xdg-settings get default-web-browser | cut -d '.' -f 1 | cut -d '-' -f 1) ## GET cookies-from-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="" ### if [ $URL ]; then @@ -250,17 +252,23 @@ mkdir -p ${YTEMP} # youtube-dl $YTURL echo "VIDEO $YTURL" -LINE="$(yt-dlp --cookies-from-browser $BROWSER --print "%(id)s&%(title)s" "${YTURL}")" +LINE="$(yt-dlp $BROWSER --print "%(id)s&%(title)s" "${YTURL}")" YID=$(echo "$LINE" | cut -d '&' -f 1) TITLE=$(echo "$LINE" | cut -d '&' -f 2- | detox --inline) /usr/local/bin/youtube-dl -f "(bv*[ext=mp4][height<=720]+ba/b[height<=720])" \ --no-playlist \ - --cookies-from-browser $BROWSER --verbose --audio-format mp3\ + $BROWSER --verbose --audio-format mp3\ --download-archive $HOME/.zen/.yt-dlp.list \ -S res,ext:mp4:m4a --recode mp4 --no-mtime --embed-thumbnail --add-metadata \ -o "${YTEMP}/$TITLE.%(ext)s" "$YTURL" + if [[ ! $(ls "${YTEMP}/*.mp4") ]]; then + ## SECOND TRY + /usr/local/bin/youtube-dl --no-playlist $BROWSER --download-archive $HOME/.zen/.yt-dlp.list -S res,ext:mp4:m4a --no-mtime --embed-thumbnail --add-metadata -o "${YTEMP}/$TITLE.%(ext)s" "$YTURL" + fi + [[ ! $(ls "${YTEMP}/*.mp4") ]] && espeak "cannot download file" && exit 1 + ZFILE="$TITLE.mp4" echo "$ZFILE" @@ -511,7 +519,7 @@ then espeak "Searching $artist $song" # Download mp3 from 1st youtube search video result (--write-info-json) /usr/local/bin/youtube-dl --default-search ytsearch1: \ - --cookies-from-browser $BROWSER \ + $BROWSER \ --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" @@ -522,7 +530,7 @@ else espeak "Copying Link" /usr/local/bin/youtube-dl \ --no-playlist \ ---cookies-from-browser $BROWSER \ +$BROWSER \ --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" "$YTURL"