Add file test for m3u8 files to correct them in case youtube-dl was wrong. - annna - Annna the nice friendly bot.
HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
---
DIR commit ef2a8267309f40a3a475dd332006ce1987bf9077
DIR parent fc2e372e7b1c8849f9daa63c7ec6b4d36378932c
HTML Author: Annna Robert-Houdin <annna@bitreich.org>
Date: Sat, 23 Oct 2021 21:17:14 +0200
Add file test for m3u8 files to correct them in case youtube-dl was wrong.
Diffstat:
M annna-add-hashtag | 18 ++++++++++++++++++
M modules/hashtags/hashtags.txt | 1 -
2 files changed, 18 insertions(+), 1 deletion(-)
---
DIR diff --git a/annna-add-hashtag b/annna-add-hashtag
@@ -62,6 +62,24 @@ processtag() {
cd "${memecachedir}"
tagfile="$(basename "$(find . -name "${stag}.*" | grep -v .orig)")"
+
+ # In case youtube-dl mangled with the extension, rename to what file
+ # suggests us as ending.
+ case "${tagfile}" in
+ *.m3u8|*.M3U8)
+ realext="$(file --mime-type -b "${tagfile}" | cut -d'/' -f 2)"
+ if [ "${realext}" != "m3u8" ];
+ then
+ newtagfile="$(printf "%s\n" "${tagfile}" \
+ | tr '[:upper:]' '[:lower:]' \
+ | sed "s,m3u8,${realext},")"
+ printf "Renaming %s to %s.\n" "${tagfile}" "${newtagfile}"
+ mv "${tagfile}" "${newtagfile}"
+ tagfile="${newtagfile}"
+ fi
+ ;;
+ esac
+
case "${tagfile}" in
*.MP4|*.mp4|*.MKV|*.mkv|*.webm|*.WEBM|*.mov|*.MOV)
printf "Making %s streamable by adding faststart.\n" "${tagfile}"
DIR diff --git a/modules/hashtags/hashtags.txt b/modules/hashtags/hashtags.txt
@@ -3052,7 +3052,6 @@
#covid gopher://bitreich.org/I/memecache/covid.png
#cow gopher://bitreich.org/9/memecache/cow.mkv
#cow-drive-in gopher://bitreich.org/I/memecache/cow-drive-in.jpg
-#cow-job gopher://bitreich.org/9/memecache/cow-job.m3u8
#cow-lick gopher://bitreich.org/I/memecache/cow-lick.jpg
#cow-tipping gopher://bitreich.org/I/memecache/cow-tipping.png
#cowabunga gopher://bitreich.org/I/memecache/cowabunga.png