summaryrefslogtreecommitdiff
path: root/rmpc/inspect_log.sh
diff options
context:
space:
mode:
authoranand <anand.panchdhari@gmail.com>2025-12-17 15:57:55 +0530
committeranand <anand.panchdhari@gmail.com>2025-12-17 15:57:55 +0530
commitb7ef29a8886a57aadb787807a7c6cf74c1f0ed3a (patch)
tree366a68240fbc9da6b1d567bd6c46d1350ad814de /rmpc/inspect_log.sh
Nixos
Diffstat (limited to 'rmpc/inspect_log.sh')
-rwxr-xr-xrmpc/inspect_log.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/rmpc/inspect_log.sh b/rmpc/inspect_log.sh
new file mode 100755
index 0000000..660eae6
--- /dev/null
+++ b/rmpc/inspect_log.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env sh
+
+LOGFILE="$HOME/.mpd/log"
+OUTFILE="$HOME/.config/rmpc/genre_counts.txt"
+TMPFILE="$(mktemp)"
+
+# Extract and accumulate genres to tmpfile
+grep "player: played" "$LOGFILE" | while read -r line; do
+ filepath=$(echo "$line" | sed -n 's/.*player: played "\(.*\)"/\1/p')
+ fullpath="$HOME/Music/mpd/$filepath"
+
+ if [ -f "$fullpath" ]; then
+ genre=$(eyeD3 --no-color "$fullpath" | grep "genre:" | sed -E 's/.*genre: (.*) \(id.*/\1/')
+ IFS=';'
+ for g in $genre; do
+ clean_genre=$(echo "$g" | xargs)
+ [ -n "$clean_genre" ] && echo "$clean_genre" >> "$TMPFILE"
+ done
+ fi
+done
+
+# Count and sort genres
+sort "$TMPFILE" | uniq -c | sort -k1 -nr | awk '{ $1=$1; print substr($0, index($0,$2)) " " $1 }' > "$OUTFILE"
+
+rm "$TMPFILE"
+echo "✅ Genre frequency list saved to $OUTFILE"