Skip to content

Instantly share code, notes, and snippets.

#returns a function, that function takes a listref of IDs as argument, and returns a hashref of groupid=>score
#returns nothing on error
sub Random::MakeGroupScoreFunction
{ my ($self,$field)=@_;
my ($keycode,$multi)= Songs::LookupCode($field, 'hash','hashm', [ID => '$_']);
unless ($keycode || $multi) { warn "MakeGroupScoreFunction error : can't find code for field $field\n"; return } #return dummy sub ?
($keycode,my $keyafter)= split / +---- +/,$keycode||$multi,2;
if ($keyafter) { warn "MakeGroupScoreFunction with field $field is not supported yet\n"; return } #return dummy sub ?
my ($before,$score)=$self->make;
my $calcIDscore= $multi ? 'my $IDscore='.$score.'; for my $key ('.$keycode.') {$score{$key}+=$IDscore}' : "\$score\{$keycode}+=$score;";
@squentin
squentin / currentsong.pl
Created April 18, 2012 16:28
example for querying current song via DBus
#!/bin/perl
use warnings;
use strict;
use Net::DBus;
my $bus = Net::DBus->session;
my $service = $bus->get_service('org.gmusicbrowser');
my $object = $service->get_object('/org/gmusicbrowser', 'org.gmusicbrowser');
my $info= $object->CurrentSong;
@squentin
squentin / setplaycount.pl
Created April 19, 2012 17:34
small script to set playcount for a song
#!/usr/bin/perl
use warnings;
use strict;
use Net::DBus;
my $bus = Net::DBus->session;
my $service = $bus->get_service('org.gmusicbrowser');
my $object = $service->get_object('/org/gmusicbrowser', 'org.gmusicbrowser');
die "Usage : $0 file(with full path) value\n" unless @ARGV==2;
@squentin
squentin / setfield.pl
Created July 28, 2014 16:36
Small script to set field to a given value for a given file
#!/bin/perl
use warnings;
use strict;
use Net::DBus;
my $bus = Net::DBus->session;
my $service = $bus->get_service('org.gmusicbrowser');
my $object = $service->get_object('/org/gmusicbrowser', 'org.gmusicbrowser');
die "Usage : $0 file(with full path) field value\n" unless @ARGV==3;
@squentin
squentin / gst1-play.pl
Created August 25, 2015 21:24
Sample program to play one or more file with gstreamer-1.x
#!/usr/bin/perl
use warnings;
use strict;
use Glib;
use Glib::Object::Introspection;
Glib::Object::Introspection->setup(basename => 'Gst', version => '1.0', package => 'GStreamer1');
GStreamer1::init_check([ $0, @ARGV ]) or die "Can't initialize gstreamer-1.x\n";
my $reg= GStreamer1::Registry::get();
$reg->lookup_feature('playbin') or die "gstreamer-1.x plugin 'playbin' not found.\n";
@squentin
squentin / 0001-tag-writing-for-DeusIX.patch
Created October 19, 2020 15:55
rating/lastplay/playcount tag writing patch for DeusIX
---
gmusicbrowser_songs.pm | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/gmusicbrowser_songs.pm b/gmusicbrowser_songs.pm
index 67d331b..2d98ba0 100644
--- a/gmusicbrowser_songs.pm
+++ b/gmusicbrowser_songs.pm
@@ -1091,13 +1091,15 @@ our %timespan_menu=