always truncate output filenames

This commit is contained in:
Dym Sohin 2024-04-24 17:58:40 +02:00
parent d6f91887cd
commit e06429769f
1 changed files with 12 additions and 8 deletions

20
y.sh
View File

@ -95,10 +95,10 @@ get_bandcamp_track()
{ {
echo "> > track: '$1'" echo "> > track: '$1'"
YDL "$1" -f mp3-320 \ YDL "$1" -f mp3-320 \
-o "$MUSIC_PATH/$ARTIST/%(album)s/%(track_number)02d %(title).100B [%(id)s].%(ext)s" -o "$MUSIC_PATH/$ARTIST/%(album)s/%(track_number)02d %(title).50B [%(id)s].%(ext)s"
[ $? -eq 1 ] \ [ $? -eq 1 ] \
&& YDL "$1" -f mp3 \ && YDL "$1" -f mp3 \
-o "$MUSIC_PATH/$ARTIST/%(album)s/%(track_number)02d %(title).100B [%(id)s].%(ext)s" -o "$MUSIC_PATH/$ARTIST/%(album)s/%(track_number)02d %(title).50B [%(id)s].%(ext)s"
} }
get_bandcamp_album() get_bandcamp_album()
@ -121,7 +121,7 @@ case "$SITE" in
'music.youtube.com') 'music.youtube.com')
echo '> youtube-music' echo '> youtube-music'
YDL "$URL" -f 251 \ YDL "$URL" -f 251 \
-o "$MUSIC_PATH/%(artist)s - %(title).100B [%(id)s].%(ext)s" -o "$MUSIC_PATH/%(artist)s - %(title).50B [%(id)s].%(ext)s"
;; ;;
'youtube.com'| \ 'youtube.com'| \
@ -131,28 +131,28 @@ case "$SITE" in
if [[ "$URL" = *youtube\.com\/@* ]]; then if [[ "$URL" = *youtube\.com\/@* ]]; then
echo '> > store archive' echo '> > store archive'
YDL "$URL" \ YDL "$URL" \
-o "$YT_PATH/%(uploader_id)s/%(title).100B [%(id)s].%(ext)s" -o "$YT_PATH/%(uploader_id)s/%(title).50B [%(id)s].%(ext)s"
else else
case "$OPT" in case "$OPT" in
'm') 'm')
echo '> > music' echo '> > music'
YDL "$URL" -f 251 \ YDL "$URL" -f 251 \
-o "$MUSIC_PATH/%(title).100B [%(id)s].%(ext)s" -o "$MUSIC_PATH/%(title).50B [%(id)s].%(ext)s"
;; ;;
'a') 'a')
echo '> > audio' echo '> > audio'
YDL "$URL" -f 251 \ YDL "$URL" -f 251 \
-o "$AUDIO_PATH/%(title).100B [%(id)s].%(ext)s" -o "$AUDIO_PATH/%(title).50B [%(id)s].%(ext)s"
;; ;;
's') 's')
echo '> > store archive' echo '> > store archive'
YDL "$URL" \ YDL "$URL" \
-o "$YT_PATH/%(uploader_id)s/%(title).100B [%(id)s].%(ext)s" -o "$YT_PATH/%(uploader_id)s/%(title).50B [%(id)s].%(ext)s"
;; ;;
*) *)
echo '> > _video_' echo '> > _video_'
YDL "$URL" \ YDL "$URL" \
-o "$DEFAULT_PATH/yt-%(title).100B [%(id)s].%(ext)s" -o "$DEFAULT_PATH/yt-%(title).50B [%(id)s].%(ext)s"
;; ;;
esac esac
fi fi
@ -251,6 +251,7 @@ case "$SITE" in
| sd -- '/status/' '--' \ | sd -- '/status/' '--' \
| sd '/' '-' \ | sd '/' '-' \
` `
CLEAN_URL=${CLEAN_URL:0:50}
echo "CLEAN_URL : '$CLEAN_URL'" echo "CLEAN_URL : '$CLEAN_URL'"
YDL "$URL" -o "$DEFAULT_PATH/tw--$CLEAN_URL.%(ext)s" YDL "$URL" -o "$DEFAULT_PATH/tw--$CLEAN_URL.%(ext)s"
;; ;;
@ -265,6 +266,7 @@ case "$SITE" in
| sd -- '/?comments/' '--' \ | sd -- '/?comments/' '--' \
| sd '/' '-' \ | sd '/' '-' \
` `
CLEAN_URL=${CLEAN_URL:0:50}
echo "CLEAN_URL : '$CLEAN_URL'" echo "CLEAN_URL : '$CLEAN_URL'"
YDL "$URL" -o "$DEFAULT_PATH/r-$CLEAN_URL.%(ext)s" YDL "$URL" -o "$DEFAULT_PATH/r-$CLEAN_URL.%(ext)s"
;; ;;
@ -279,6 +281,7 @@ case "$SITE" in
| sd '/+$' '' \ | sd '/+$' '' \
| sd '/' '-' \ | sd '/' '-' \
` `
CLEAN_URL=${CLEAN_URL:0:50}
echo "CLEAN_URL : '$CLEAN_URL'" echo "CLEAN_URL : '$CLEAN_URL'"
DATE=` date -u "+%Y%m%d%H%M%S" ` DATE=` date -u "+%Y%m%d%H%M%S" `
YDL "$URL" -o "$DEFAULT_PATH/ig-%(uploader_id).50B-$CLEAN_URL-(%(title).50B)_$DATE.%(ext)s" YDL "$URL" -o "$DEFAULT_PATH/ig-%(uploader_id).50B-$CLEAN_URL-(%(title).50B)_$DATE.%(ext)s"
@ -293,6 +296,7 @@ case "$SITE" in
| sd '[\\\/\s\?\^\*\|:><]+' '-' \ | sd '[\\\/\s\?\^\*\|:><]+' '-' \
` `
CLEAN_URL=${CLEAN_URL%%/*} CLEAN_URL=${CLEAN_URL%%/*}
CLEAN_URL=${CLEAN_URL:0:50}
echo "CLEAN_URL : '$CLEAN_URL'" echo "CLEAN_URL : '$CLEAN_URL'"
DATE=` date -u "+%Y%m%d%H%M%S" ` DATE=` date -u "+%Y%m%d%H%M%S" `
YDL "$URL" -o "$DEFAULT_PATH/$CLEAN_URL-[%(id)s]_$DATE.%(ext)s" YDL "$URL" -o "$DEFAULT_PATH/$CLEAN_URL-[%(id)s]_$DATE.%(ext)s"