Skip to content

Instantly share code, notes, and snippets.

@WaterSibilantFalling
Created September 21, 2017 11:11
Show Gist options
  • Save WaterSibilantFalling/d88be3ff890226bc15fd5cd4e80ba84f to your computer and use it in GitHub Desktop.
Save WaterSibilantFalling/d88be3ff890226bc15fd5cd4e80ba84f to your computer and use it in GitHub Desktop.
a short perl script for logging all the musich I listen to in audiacious
#!/usr/bin/perl
use strict;
use warnings;
use POSIX;
use English qw( -no_match_vars ) ;
my $logFile = "/home/music/logging/musicListenedLog.log";
use IO::All;
#this script :
#
# is run by audacious on song change
# it writes the song info passed by audacious to a log file
# it cleans up the text, and prefixes a timestamp
# Note: this must be run at the START of each song, else audacious looses
# the tag data (album, band....) and retains only the filename
#
#say "In sdmMusicLogger" ;
# --- get the input data
my $infoToLog;
chomp (@ARGV);
foreach (@ARGV) { $infoToLog .= "$_ + ";}
#$infoToLog = $ARGV[0];
#chop $infoToLog;
my $inInfo = $infoToLog;
# --- process the data
$infoToLog =~ s/%20/ /g; # clean filename of webtext
$infoToLog =~ s/%5B/\[/g;
$infoToLog =~ s/%5D/\]/g;
$infoToLog =~ s/%28/\(/g;
$infoToLog =~ s/%29/\)/g;
$infoToLog =~ s/ \+ \+//g; # remove empty categories
$infoToLog =~ s/^\s*\+\s*|\s*\+\s*$//g;
# \s* - zero or more spaces
my $timestamp = `datetime`;
chomp $timestamp;
# --- write it out
$timestamp." :: ".$infoToLog."\n" >> io($logFile);
# `xmessage "IN: \"$inInfo\" OUT: $infoToLog"`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment