-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmpd_get_cover
More file actions
executable file
·78 lines (66 loc) · 2.39 KB
/
mpd_get_cover
File metadata and controls
executable file
·78 lines (66 loc) · 2.39 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: /home/fgm/bin/mpd_get_cover
# Created: Monday, 2013/00/00 - 00:00:00
# Author.: @VyacheslavLevit, (unknown)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Wednesday, 2023/07/05 - 14:05:23
# Modified By..: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 1.0.2.10
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# > Dirty script to download covers for the album of currently playing song by mpd
# ############################################################################
# HISTORY:
MUSIC_DIR="$HOME/music"
TEMPDIR=/var/tmp
MAX_DOWNLOADS=20
VIEWER=(qiv -tBI)
GLYRC_ARGS=(--plugmax 2 --minsize 490)
COVER='cover.$ext' # might be '$artist - $album.$ext'
COVERTXT="/tmp/cover.txt"
if ! type mpc &>/dev/null || ! type glyrc &>/dev/null ; then
echo "mpc and glyrc are required"
exit 1
fi
artist="$(mpc --format %artist% current)"
[[ $? != 0 ]] && { echo "mpd not running?" ; exit 1; }
album="$(mpc --format %album% current)"
file="$MUSIC_DIR/$(mpc --format %file% current)"
echo "artist:$artist"
echo "album:$album"
if [[ -z "$artist" ]] || [[ -z "$album" ]] ; then
echo "artist or/and album field is empty"
exit 1
fi
if [[ ! -e "$file" ]] ; then
echo "File doesn't exist. Wrong MUSIC_DIR?"
exit 1
fi
album_dir="${file%/*}"
glyrcdir="$TEMPDIR/glyrc"
coverdir="$glyrcdir/$artist - $album"
mkdir -p "$coverdir"
# cd "$coverdir"
glyrc cover -n "$MAX_DOWNLOADS" --artist "$artist" --album "$album" "${GLYRC_ARGS[@]}" -w "$coverdir"
# glyrc cover -n "$MAX_DOWNLOADS" --artist "$artist" --album "$album" "${GLYRC_ARGS[@]}" -w /tmp
"${VIEWER[@]}" "$coverdir"
# if [[ ! -e "$COVERTXT" ]] ; then
# echo "No images selected ($COVERTXT does not exist)"
# exit 1
# fi
# coverfile="$(cat "$COVERTXT")"
coverfile=$(ls "$coverdir" | tr -d '\n')
# rm -f "$COVERTXT"
if [[ ! -e "$coverdir/$coverfile" ]] ; then
echo "$coverfile doesn't exist"
exit 1
fi
ext="${coverfile##*.}"
[[ "$ext" == "jpeg" ]] && ext=jpg
eval dest=\"$COVER\"
dest="$album_dir/$dest"
cp "$coverdir/$coverfile" "$dest"