💾 Archived View for oppen.digital › memex › 20210706 captured on 2022-01-08 at 14:04:12. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

Old RaspberryPi Media Player

RaspberryPi with InkyPHAT eInk display

I found an old RaspberryPi B today that I used to use as a media player, it'd play random tracks all day long while I worked, and had an eInk display that'd show the track details. For posterity here's the bash files:

player.sh

#!/bin/bash

echo "Oppen MP3 Player"

while :
do
	rfile="$(find ./ -iname '*.mp3' -print0 | shuf -z -n1)"
	rname=${rfile##*/}
	echo $rname

	artist="$(ffprobe -loglevel error -show_entries format_tags=artist -of default=noprint_wrappers=1:nokey=1 $rname)"
	track="$(ffprobe -loglevel error -show_entries format_tags=title -of default=noprint_wrappers=1:nokey=1 $rname)"
	album="$(ffprobe -loglevel error -show_entries format_tags=album -of default=noprint_wrappers=1:nokey=1 $rname)"
	figlet "$track - $artist"
	python phat.py -a "$artist" -t "$track" -al "$album" -s 22
	cvlc --play-and-exit "$rname"
done

phat.sh

This updates an InkyPHAT eInk display:

#!/usr/bin/env python

import os
import argparse
from PIL import Image, ImageDraw, ImageFont
from inky import InkyPHAT

PATH = os.path.dirname(__file__)


parser = argparse.ArgumentParser()
parser.add_argument('--artist', '-a', type=str, required=True, help="artist name")
parser.add_argument('--track', '-t', type=str, required=True, help="track name")
parser.add_argument('--album', '-al', type=str, required=True, help="album name")
parser.add_argument('--fontsize', '-s', type=int, required=True, help="enter font size")
args = parser.parse_args()

inky_display = InkyPHAT('black')

#inky_display.set_border(inky_display.BLACK)


img = Image.new('1', (212, 104))

fontsize = args.fontsize
font = ImageFont.truetype("intermedium.ttf", fontsize) 
d = ImageDraw.Draw(img)
d.text((10,10), args.track, (255), font=font)
d.text((10,10 + fontsize + 5), args.artist, (255), font=font)
d.text((10,10 + fontsize + fontsize + 10), args.album, (255), font=font)

img.save('oppen_phat.png')

 inky_display.set_image(img)
 inky_display.show()