2 MP3 Get Tags
tengel edited this page 2024-09-05 08:27:27 -05:00

Pull out mp3 tags to create a libre.fm import file

#!/usr/bin/env bash

DTB=1251499494   # epoch start time
DTS=$(date +%s)  # epoch current time
DAT="${HOME}/Music"
while IFS="" read -r -d $'\000' mp3 <&3; do
  DTN=$(shuf -i $DTB-$DTS -n 1)  # random epoch between
  ART=$(mid3v2 -l "$mp3" | grep "^TPE1" | cut -d'=' -f2)
  SNG=$(mid3v2 -l "$mp3" | grep "^TIT2" | cut -d'=' -f2)
  ALB=$(mid3v2 -l "$mp3" | grep "^TALB" | cut -d'=' -f2)
  echo -e "$DTN\t$SNG\t$ART\t$ALB\t\t\t"
done 3< <(find "$DAT" -mindepth 1 -name \*.mp3 -print0)

# Use libreimport.py / scrobble.py from here:
#  http://bugs.foocorp.net/projects/librefm/wiki/LastToLibre
#
# Connect libre.fm to your last.fm account first, then the scrobbles
# import to both services at once for your entire local music library.