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