summaryrefslogtreecommitdiff
path: root/.config/ncmpcpp/cover_obs.sh
blob: e6d80e075198fcb88a86fb687ab6dec9799170d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env sh

######################################################################
# @author      : pico (pico@$HOSTNAME)
# @file        : cover_obs
# @created     : Sunday Sep 08, 2024 00:52:58 CST
#
# @description : 
######################################################################

COVER="/tmp/album_cover.png"
COVER_SIZE="400"

#path to current song
file="$MUSIC_DIR/$(mpc --format %file% current)"
album="${file%/*}"
#search for cover image
#use embedded image if present, otherwise take it from current folder
err=$(ffmpeg -loglevel 16 -y -i "$file" -an -vcodec copy $EMB_COVER 2>&1)
if [ "$err" != "" ] ; then
    art=$(find $album" -maxdepth 1 | grep -m 1 ".*\.\(jpg\|png\|gif\|bmp\)")
else
    art=$EMB_COVER
fi

if [ "$art" = "" ]; then
    art="$HOME/.config/ncmpcpp/default_cover.png"
fi

#copy and resize image to destination
ffmpeg -loglevel 0 -y -i "$art" -vf "scale=$COVER_SIZE:-1" "$COVER"