Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d36b8a9
Bump debian compat level to 10
carl-di-ortus May 5, 2024
1fb8058
Merge pull request #1 from carl-di-ortus/dh-compat-patch-1
carl-di-ortus May 5, 2024
93f4218
copy-paste from last.fm to listenbrainz
carl-di-ortus May 5, 2024
c04d1ae
rename all instances, restore original querystring
carl-di-ortus May 5, 2024
bb1e8c5
redo listenbrainz plugin with native API
carl-di-ortus Jun 2, 2024
ac5a789
fix duplicate listenbrainz submits
carl-di-ortus Aug 10, 2024
ef7924e
save post body to file, wget use filename
carl-di-ortus Aug 14, 2024
5255ba0
immediately submit on song change
carl-di-ortus Apr 3, 2025
d680722
Merge pull request #8 from carl-di-ortus/2-listenbrainz
carl-di-ortus Apr 3, 2025
79c4961
add .vscode to .gitignore
carl-di-ortus Apr 3, 2025
f3fe966
Merge pull request #9 from carl-di-ortus/4-vscode
carl-di-ortus Apr 3, 2025
4c237c4
Remove obsolete/unmaintained http clients
carl-di-ortus Apr 4, 2025
82543a6
Remove duplicate timer removal, fixes non-critical Glib-critical warning
carl-di-ortus Apr 4, 2025
168b3ed
Merge pull request #15 from carl-di-ortus/2-listenbrainz
carl-di-ortus Apr 4, 2025
f928e52
Merge remote-tracking branch 'origin/master' into 5-http
carl-di-ortus Apr 4, 2025
bc0fa69
Rewrite http post with LWP
carl-di-ortus Apr 4, 2025
e398039
Rewrite http get with LWP, drop wget dependency
carl-di-ortus Apr 4, 2025
49a32e0
rename file
carl-di-ortus Apr 4, 2025
ac108d3
Simplify http logging, (sort of) fix lyrics plugin loading, drop obso…
carl-di-ortus Apr 6, 2025
59bffd3
Remove unused encoding (always asumes UTF-8)
carl-di-ortus Apr 6, 2025
2a16fec
fix musixmatch parser
carl-di-ortus Apr 11, 2025
40b70d8
UTF-8 all output
carl-di-ortus Apr 14, 2025
06ef620
Clean up musicmatch results
carl-di-ortus Apr 25, 2025
7979530
Add line break before h3 verse/chorus
carl-di-ortus Apr 26, 2025
39daa87
Add instrumental handling
carl-di-ortus Apr 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ locale/
po/gmusicbrowser.pot
nytprof*
t/samples/

.vscode/
TODO
2 changes: 1 addition & 1 deletion debian/compat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5
10
5 changes: 3 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ Build-Depends: debhelper (>= 5.0.0), markdown
Standards-Version: 3.7.3

Package: gmusicbrowser
Version: 1.1.99.2
Architecture: all
Depends: perl, libgtk3-perl, libgtk-3-0
Recommends: libintl-perl, libnet-dbus-perl, libglib-object-introspection-perl, gir1.2-gstreamer-1.0, libdigest-crc-perl, libhtml-parser-perl, libio-compress-perl
Depends: perl, libgtk3-perl, libgtk-3-0, libutf8-all-perl
Recommends: libintl-perl, libnet-dbus-perl, libglib-object-introspection-perl, gir1.2-gstreamer-1.0, libdigest-crc-perl, libhtml-parser-perl, libio-compress-perl, libtext-autoformat-perl, libxml-perl
Suggests: mpv, mplayer, mpg123, vorbis-tools, alsa-utils, gir1.2-webkit2, gir1.2-notify, gir1.2-wnck, gir1.2-poppler
Description: very customizable jukebox for large collections of music files
The interface is extremely customizable. It has easy access to related songs
Expand Down
22 changes: 4 additions & 18 deletions gmusicbrowser.pl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

use strict;
use warnings;
use utf8;
binmode STDERR,':utf8';
binmode STDOUT,':utf8';
use utf8::all;


package main;
Expand Down Expand Up @@ -528,18 +526,13 @@ BEGIN
}
# end of command line handling

our $HTTP_module;
our ($Play_package,%PlayPacks); my ($PlayNext_package,$Vol_package);
BEGIN{
require 'gmusicbrowser_songs.pm';
require 'gmusicbrowser_tags.pm';
require 'gmusicbrowser_layout.pm';
require 'gmusicbrowser_list.pm';
$HTTP_module= -e $DATADIR.SLASH.'simple_http_wget.pm' && (grep -x $_.SLASH.'wget', split /:/, $ENV{PATH}) ? 'simple_http_wget.pm' :
-e $DATADIR.SLASH.'simple_http_AE.pm' && (grep -f $_.SLASH.'AnyEvent'.SLASH.'HTTP.pm', @INC) ? 'simple_http_AE.pm' :
'simple_http.pm';
#warn "using $HTTP_module for http requests\n";
#require $HTTP_module;
require 'simple_http.pm';

# load gstreamer backend module
if (!$CmdLine{nogst})
Expand Down Expand Up @@ -10306,22 +10299,16 @@ sub Start
$self->Done;
}
else
{ unless (eval {require $::HTTP_module}) {warn "Loading $::HTTP_module failed, can't download $display_uri\n"; $self->Done; return}
{
warn "Downloading '$display_uri' to '$destpath'\n" if $::debug;
::Progress( $progressid, bartext_append=>$display_uri, title=>_"Downloading");
$self->{waiting}= Simple_http::get_with_cb(url => $uri, cache=>1, progress=>1, cb => sub { $self->Downloaded(@_); });
$self->{track_progress} ||= Glib::Timeout->add(200,
sub { if (my $w= $self->{waiting}) { my ($p,$s)=$w->progress; ::Progress( $progressid, partial=>$p ) if defined $p; }
else { $self->{track_progress}=0 }
return $self->{track_progress};
});
Simple_http::get_with_cb(url => $uri, cb => sub { $self->Downloaded(@_); });
return
}
}

sub Downloaded
{ my ($self,$content,%content_prop)=@_;
delete $self->{waiting};
my $type=$content_prop{type};
my $params= $self->{current};
my $uri= $params->{uri};
Expand Down Expand Up @@ -10409,7 +10396,6 @@ sub Done # file done, if no $self->{newfile} it means the file has been skipped
}
sub Abort # GMB::DropURI object must not be used after that
{ my $self=shift;
$self->{waiting}->abort if $self->{waiting};
Glib::Source->remove( $self->{track_progress} ) if $self->{track_progress};
::Progress( 'DropURI_'.$self, abort=>1 );
$self->{cb_end}() if $self->{cb_end};
Expand Down
20 changes: 19 additions & 1 deletion gmusicbrowser_songs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use strict;
use warnings;
use utf8;
use utf8::all;

package Songs;

Expand Down Expand Up @@ -1151,6 +1151,24 @@ our %timespan_menu=
editsubmenu=>0,
category=>'extra',
},
# https://github.com/carl-di-ortus/gmusicbrowser/issues/3
# https://picard-docs.musicbrainz.org/downloads/MusicBrainz_Picard_Tag_Map.html
# musicbrainz_trackid =>
# { name => _"MBID",
# id3v2 => 'TXXX;MusicBrainz Release Track Id;%v', vorbis => 'musicbrainz_releasetrackid', ape => 'MUSICBRAINZ_RELEASETRACKID', ilst => "----:com.apple.iTunes:MusicBrainz Release Track Id", 'id3v2.3' => 'TXXX;MusicBrainz Release Track Id;%v',
# flags => 'fgaescpi',
# type => 'string',
# category=>'extra',
# postread=> sub { my $v=shift; warn "V $v"; },
# },
# acoustid =>
# { name => _"AcoustID",
# id3v2 => 'TXXX;Acoustid Id;%v', vorbis => 'ACOUSTID_ID', ape => 'ACOUSTID_ID', ilst => "----:com.apple.iTunes:Acoustid Id",
# flags => 'fgaescpi',
# type => 'string',
# category=>'extra',
# postread=> sub { my $v=shift },
# },
style =>
{ name => _"Styles", width => 180, flags => 'fgaescpil',
type => 'flags',
Expand Down
2 changes: 1 addition & 1 deletion gmusicbrowser_tags.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BEGIN
}
use strict;
use warnings;
use utf8;
use utf8::all;

package FileTag;

Expand Down
20 changes: 8 additions & 12 deletions plugins/albuminfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ desc Retrieves album-relevant information (review etc.) from allmusic.com.
package GMB::Plugin::ALBUMINFO;
use strict;
use warnings;
use utf8;
require $::HTTP_module;
use utf8::all;
require 'simple_http.pm';
use base 'Gtk3::Box';
use constant
{ OPT => 'PLUGIN_ALBUMINFO_',
Expand Down Expand Up @@ -153,7 +153,7 @@ sub download_one {
} else {
my $url = AMG_SEARCH_URL.::url_escapeall($album);
warn "Albuminfo: fetching search results from $url\n" if $::debug;
$self->{waiting} = Simple_http::get_with_cb(url=>$url, cache=>1, cb=>sub {$self->load_search_results($ID,1,\&download_one,@_)});
Simple_http::get_with_cb(url=>$url, cb=>sub {$self->load_search_results($ID,1,\&download_one,@_)});
}
}

Expand Down Expand Up @@ -512,12 +512,11 @@ sub new_search {
$self->cancel();
$self->{treeview}->get_model->clear;
warn "Albuminfo: fetching search results from $url.\n" if $::debug;
$self->{waiting} = Simple_http::get_with_cb(cb=>sub {$self->print_results(@_)},url=>$url, cache=>1);
Simple_http::get_with_cb(cb=>sub {$self->print_results(@_)},url=>$url);
}

sub print_results {
my ($self,$html,%prop) = @_;
delete $self->{waiting};
my $result = parse_amg_search_results($html, $prop{type}); # result is a ref to an array of hash refs
my $store= $self->{treeview}->get_model;
$store->set_sort_column_id(5, 'ascending');
Expand All @@ -534,8 +533,8 @@ sub entry_selected_cb {
my $url = $store->get($store->get_iter($path),4);
warn "Albuminfo: fetching review from $url\n" if $::debug;
$self->cancel();
$self->{waiting} = Simple_http::get_with_cb(cb=>sub {$self->{searchview}->hide(); $self->{infoview}->show();
$self->load_review(::GetSelID($self),0,undef,$url,@_)}, url=>$url, cache=>1);
Simple_http::get_with_cb(cb=>sub {$self->{searchview}->hide(); $self->{infoview}->show();
$self->load_review(::GetSelID($self),0,undef,$url,@_)}, url=>$url);
}


Expand Down Expand Up @@ -580,7 +579,7 @@ sub album_changed {
}
}
warn "Albuminfo: fetching search results from $url\n" if $::debug;
$self->{waiting} = Simple_http::get_with_cb(cb=>sub {$self->load_search_results($ID,0,undef,@_)}, url=>$url, cache=>1);
Simple_http::get_with_cb(cb=>sub {$self->load_search_results($ID,0,undef,@_)}, url=>$url);
}

sub update_titlebox {
Expand All @@ -600,7 +599,6 @@ sub update_titlebox {

sub load_search_results {
my ($self,$ID,$md,$cb,$html,%prop) = @_; # $md = 1 if mass_download, 0 otherwise. $cb = callback function if mass_download, undef otherwise.
delete $self->{waiting};
my $result = parse_amg_search_results($html, $prop{type}); # $result[$i] = {url, album, artist, genres, year}
my ($artist,$year) = ::Songs::Get($ID, qw/artist year/);
my $url;
Expand All @@ -616,7 +614,7 @@ sub load_search_results {
}
if ($url) {
warn "Albuminfo: fetching review from $url\n" if $::debug;
$self->{waiting} = Simple_http::get_with_cb(cb=>sub {$self->load_review($ID,$md,$cb,$url,@_)}, url=>$url, cache=>1);
Simple_http::get_with_cb(cb=>sub {$self->load_review($ID,$md,$cb,$url,@_)}, url=>$url);
} else {
$self->{fields} = {};
warn "Albuminfo: album not found in search results\n" if $::debug;
Expand All @@ -627,7 +625,6 @@ sub load_search_results {

sub load_review {
my ($self,$ID,$md,$cb,$url,$html,%prop) = @_;
delete $self->{waiting};
$self->{fields} = parse_amg_album_page($url,$html,$prop{type});
$self->print_review() unless $md;
save_review($ID, $self->{fields}) if $::Options{OPT.'AutoSave'} || $md;
Expand Down Expand Up @@ -804,7 +801,6 @@ sub cancel {
my $self = shift;
delete $::ToDo{'9_load_albuminfo'.$self};
delete $::ToDo{'9_refresh_albuminfo'.$self};
$self->{waiting}->abort() if $self->{waiting};
::Progress('albuminfo', abort=>1);
$self->{abort}=1;
}
Expand Down
28 changes: 9 additions & 19 deletions plugins/artistinfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ url http://gmusicbrowser.org/dokuwiki/doku.php?id=plugins:artistinfo
package GMB::Plugin::ARTISTINFO;
use strict;
use warnings;
use utf8;
require $::HTTP_module;
use utf8::all;
require 'simple_http.pm';
use base 'Gtk3::Box';
use constant
{ OPT => 'PLUGIN_ARTISTINFO_', # MUST begin by PLUGIN_ followed by the plugin ID / package name
Expand All @@ -29,7 +29,7 @@ use constant
my %sites =
(
biography => ['http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=%a&api_key=7aa688c2466dc17263847da16f297835&autocorrect=1',_"Biography",_"Show artist's biography"],
events => ['http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist=%a&api_key=7aa688c2466dc17263847da16f297835&autocorrect=1',_"Events",_"Show artist's upcoming events"],
#events => ['http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist=%a&api_key=7aa688c2466dc17263847da16f297835&autocorrect=1',_"Events",_"Show artist's upcoming events"],
similar => ['http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist=%a&api_key=7aa688c2466dc17263847da16f297835&autocorrect=1&limit=%l',_"Similar",_"Show similar artists"]);

my @External=
Expand All @@ -49,7 +49,6 @@ my %menuitem=
test => sub {$_[0]{mainfield} eq 'artist'}, #the menu item is displayed if returns true
);
my $nowplayingaID;
my $queuewaiting;
my %queuemode=
( order=>10, icon=>'gtk-refresh', short=> _"similar-artists", long=> _"Auto-fill queue with similar artists (from last.fm)", changed=>\&QAutofillSimilarArtists, keep=>1,save=>1,autofill=>1,
);
Expand Down Expand Up @@ -97,7 +96,6 @@ sub Stop {
Layout::RegisterWidget(PluginArtistinfo => undef);
@::cMenuAA= grep $_!=\%menuitem, @::SongCMenu;
delete $::QActions{'autofill-similar-artists'}; ::Update_QueueActionList();
$queuewaiting->abort if $queuewaiting; $queuewaiting=undef;
}

sub new
Expand Down Expand Up @@ -271,7 +269,6 @@ sub destroy_event_cb
sub cancel
{ my $self=shift;
delete $::ToDo{'8_artistinfo'.$self};
$self->{waiting}->abort if $self->{waiting};
}

sub prefbox
Expand Down Expand Up @@ -506,25 +503,18 @@ sub load_url
warn "info : loading $url\n" if $::debug;
$self->{url}=$url;
$self->{sw2}->hide; $self->{sw1}->show;
$self->{waiting}=Simple_http::get_with_cb(cb => sub {$self->loaded(@_)},url => $url, cache => 1);
Simple_http::get_with_cb(cb => sub {$self->loaded(@_)},url => $url);
}

sub loaded
{ my ($self,$data,%prop)=@_;
delete $self->{waiting};
my $buffer=$self->{buffer};
my $type=$prop{type};
unless ($data) { $data=_("Loading failed.").qq( <a href="$self->{url}">)._("retry").'</a>'; $type="text/html"; }
$self->{url}=$prop{url} if $prop{url}; #for redirections
$buffer->delete($buffer->get_bounds);
my $encoding;
if ($type && $type=~m#^text/.*; ?charset=([\w-]+)#) {$encoding=$1}
if ($data=~m/xml version/) { $encoding='utf-8'; }
$encoding=$1 if $data=~m#<meta *http-equiv="Content-Type" *content="text/html; charset=([\w-]+)"#;
$encoding='cp1252' if $encoding && $encoding eq 'iso-8859-1'; #microsoft use the superset cp1252 of iso-8859-1 but says it's iso-8859-1
$encoding||='cp1252'; #default encoding
$data=Encode::decode($encoding,$data) if $encoding;
if ($encoding eq 'utf-8') { $data = ::decode_html($data); }

$data = ::decode_html($data);
my $iter=$buffer->get_start_iter;

my $fontsize = $self->{fontsize};
Expand Down Expand Up @@ -669,7 +659,7 @@ sub Save_text
}

sub QAutofillSimilarArtists
{ $queuewaiting->abort if $queuewaiting; $queuewaiting=undef;
{
return unless $::QueueAction eq 'autofill-similar-artists';
return if $::Options{MaxAutoFill}<=@$::Queue;
return unless $::SongID;
Expand All @@ -679,11 +669,11 @@ sub QAutofillSimilarArtists

my $url = GetUrl($sites{similar}[0],$nowplayingaID);
return unless $url;
$queuewaiting=Simple_http::get_with_cb(url => $url, cb => \&PopulateQueue );
Simple_http::get_with_cb(url => $url, cb => \&PopulateQueue );
}

sub PopulateQueue
{ $queuewaiting=undef;
{
if ( $nowplayingaID != Songs::Get_gid($::SongID,'artist')) { QAutofillSimilarArtists; return; }
my $data = $_[0];

Expand Down
19 changes: 9 additions & 10 deletions plugins/audioscrobbler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ use constant
SAVEFILE => 'audioscrobbler.queue', #file used to save unsent data
};
use Digest::MD5 'md5_hex';
require $::HTTP_module;
require 'simple_http.pm';

our $ignore_current_song;

my $self=bless {},__PACKAGE__;
my @ToSubmit; my $NowPlaying; my $NowPlayingID; my $unsent_saved=0;
my $interval=5; my ($timeout,$waiting);
my $interval=5; my $timeout;
my ($HandshakeOK,$submiturl,$nowplayingurl,$sessionid);
my ($Serrors,$Stop);
my $Log= Gtk3::ListStore->new('Glib::String');
Expand All @@ -43,9 +43,9 @@ sub Start
$Serrors=$Stop=undef;
}
sub Stop
{ $waiting->abort if $waiting;
{
Glib::Source->remove($timeout) if $timeout;
$timeout=$waiting=undef;
$timeout=undef;
::UnWatch($self,$_) for qw/PlayingSong Played Save/;
$self->{on}=undef;
$interval=5;
Expand Down Expand Up @@ -86,10 +86,10 @@ sub prefbox
sub update_queue_label
{ my $qbox=shift;
my $label= $qbox->{label};
if (@ToSubmit && (@ToSubmit>1 || (!$waiting && (!$timeout || $interval>10))))
if (@ToSubmit && (@ToSubmit>1 || (!$timeout || $interval>10)))
{ $label->set_text(::__n("%d song waiting to be sent","%d songs waiting to be sent", scalar @ToSubmit ));
$label->get_parent->show;
$qbox->{button}->set_sensitive(!$waiting);
$qbox->{button}->set_sensitive();
}
else { $label->get_parent->hide }
}
Expand Down Expand Up @@ -236,14 +236,14 @@ sub Sleep
{ #warn "Sleep\n";
return unless $self->{on};
::QHasChanged('Lastfm_state_change');
return if $Stop || $waiting || $timeout;
return if $Stop || $timeout;
$timeout=Glib::Timeout->add(1000*$interval,\&Awake) if @ToSubmit || $NowPlaying;
#warn "Sleeping $interval seconds\n" if $timeout;
}
sub Awake
{ #warn "Awoke\n";
$timeout=undef;
return 0 if !$self->{on} || $waiting;
return 0 if !$self->{on};
if ($HandshakeOK) { Submit(); }
else { Handshake(); }
Sleep();
Expand All @@ -253,11 +253,10 @@ sub Send
{ my ($response_cb,$url,$post)=@_;
my $cb=sub
{ my @response=(defined $_[0])? split "\012",$_[0] : ();
$waiting=undef;
&$response_cb(@response);
Sleep();
};
$waiting=Simple_http::get_with_cb(cb => $cb,url => $url,post => $post);
Simple_http::post_with_cb(cb => $cb,url => $url,post => $post);
::QHasChanged('Lastfm_state_change');
}

Expand Down
Loading