Skip to content

Commit

Permalink
plex_artist_image_downloader: initial
Browse files Browse the repository at this point in the history
  • Loading branch information
trapd00r committed Nov 7, 2023
1 parent 9467072 commit bcf76cd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -166,6 +166,7 @@
* [pimpla](https://github.com/trapd00r/utils/blob/master/pimpla) - perl interface for mplayer using fifos
* [pkgfont](https://github.com/trapd00r/utils/blob/master/pkgfont) - list packages that includes fonts
* [playlists_update](https://github.com/trapd00r/utils/blob/master/playlists_update) - update playlists of loved songs (pimpd2 --love)
* [plex_artist_image_downloader](https://github.com/trapd00r/utils/blob/master/plex_artist_image_downloader) - naively fetches artist images from last.fm for plex
* [poormansls++](https://github.com/trapd00r/utils/blob/master/poormansls++) - poor mans ls++, demonstrate ls_color from File::LsColor
* [post](https://github.com/trapd00r/utils/blob/master/post) - tool to aid me in writing a new blog post using jekyll
* [prename](https://github.com/trapd00r/utils/blob/master/prename) - rename with perl regex
Expand Down Expand Up @@ -196,7 +197,7 @@
* [sdorfehs-undefinekey-tops](https://github.com/trapd00r/utils/blob/master/sdorfehs-undefinekey-tops) - undefine keys for switching workspaces
* [sdorfehsrepl](https://github.com/trapd00r/utils/blob/master/sdorfehsrepl) - sdorfehs repl
* [seen](https://github.com/trapd00r/utils/blob/master/seen) - abuse sticky bits etc to mark a movie or show as seen
* [set_album_title_for_lösa_låtar_to_various](https://github.com/trapd00r/utils/blob/master/set_album_title_for_lösa_låtar_to_various) - set album title to "Various" for everything in */+tracks/ for plex{,amp}
* [set_album_title_for_lösa_låtar_to_various](https://github.com/trapd00r/utils/blob/master/set_album_title_for_lösa_låtar_to_various) - set album title to "Various" for everything in */+tracks/ for plex{,amp}. also set year/date to 1337-01-01
* [setallfonts](https://github.com/trapd00r/utils/blob/master/setallfonts) - set all fonts to ARG
* [setbg](https://github.com/trapd00r/utils/blob/master/setbg) - set terminal background
* [setbg_sshhosts](https://github.com/trapd00r/utils/blob/master/setbg_sshhosts) - set terminal background differently for each ssh host
Expand Down
33 changes: 33 additions & 0 deletions plex_artist_image_downloader
@@ -0,0 +1,33 @@
#!/bin/sh
# abstract: naively fetches artist images from last.fm for plex

ACCUMULATED_ARTIST_IMAGES_DIR=~/artistimages
LOGFILE=~/$0.log

IFS=$'\n'
for dir in $(find ~/mnt/nasse/music -type d -maxdepth 2 -mindepth 1|grep -v '\+'); do
artist=$(echo $dir|sed 's/.*\///')
artist_escaped=$(echo $artist|sed 's/ /+/g')
image=$(curl -s https://www.last.fm/music/${artist_escaped}/+images | url_find | grep freetls|head -1)

cd "$dir" && wget $image -O "artist.jpg" &&
echo "Fetched image for $artist: ${dir}/artist.jpg" | tee -a $LOGFILE

# If the filesize of the image is exactly 3417 bytes, it's a placeholder image
# and we should delete it
if [ $(stat -c %s "artist.jpg") -eq 3417 ]; then
rm -v "artist.jpg"
echo "Deleted placeholder image for $artist" | tee -a $LOGFILE
else
# add a copy to the accumulated artist images dir named after the artist
cp -v "${dir}/artist.jpg" "${ACCUMULATED_ARTIST_IMAGES_DIR}/${artist}.jpg"
fi
done


# Fetched image for Artmind: A/Artmind/artist.jpg
# Fetched image for Artyficial: A/Artyficial/artist.jpg
# Deleted placeholder image for Artyficial
# Fetched image for Ascent: A/Ascent/artist.jpg
# Fetched image for Asia 2001: A/Asia 2001/artist.jpg
# Fetched image for Asimilon: A/Asimilon/artist.jpg

0 comments on commit bcf76cd

Please sign in to comment.