Author Topic: Artists sorting  (Read 2891 times)

pyropingvin

  • Newbie
  • *
  • Posts: 15
    • View Profile
Artists sorting
« on: November 28, 2009, 23:14:43 »
It would be much more convenient if artists' names starting with "The" are sorted by their name not by the article "the" (e.g. finding The Who under the letter "w" instead of "t")...

Quentin Sculo

  • Administrator
  • Hero Member
  • *****
  • Posts: 1082
    • View Profile
Re: Artists sorting
« Reply #1 on: December 05, 2009, 20:02:05 »
It's planned (can't say when) as an option, at least by using the "Artist Sort Order" tag, and maybe also by using a user defined expression.

bamberg

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Artists sorting
« Reply #2 on: November 15, 2010, 16:17:09 »
I want to second this request.
You can achieve it partially (for the popup you get when clicking on artist) with this patch


diff --git a/gmusicbrowser.pl b/gmusicbrowser.pl
index 6b0f7fb..0384b74 100755
--- a/gmusicbrowser.pl
+++ b/gmusicbrowser.pl
@@ -5548,7 +5548,8 @@ sub PrefMisc
        my $shutentry=NewPrefEntry(Shutdown_cmd => _"Shutdown command :", tip => _"Command used when\n'turn off computer when queue empty'\nis selected");
        #artist splitting
        my %split=
-       (       ' & |, |;'      => _"' & ' and ', ' and ';'",
+       (       ' the |The | & |, and |and |, |;|\(|\)' => _"' & ' and ', [and]' and ';' and brackets (Also remove The from Names)",
+                ' & |, |;'     => _"' & ' and ', ' and ';'",
                ' & '           => "' & '",
                ' \\+ '         => "' + '",
                '; *'           => "';'",

This also extends the splitting to handle cases like: BBM (Jack Bruce, Ginger Baker, and Gary Moore) ->
- BBM
- Jack Bruce
- Ginger Baker
- Gary Moore

The downside is that it adds everything starting with "The " to the group <Unknown> too. So for example "The Animals" is split into
- <Unkown>
- Animals
It would be much nicer if there were a function handle which could be applied to all the entries in the splitted list which would transform "The Animals" to "Animals, The" and "The Animals", generating two entries from a single entry. But I did not find out how to do this by looking at the code for 10 minutes :)

Brian

Quentin Sculo

  • Administrator
  • Hero Member
  • *****
  • Posts: 1082
    • View Profile
Re: Artists sorting
« Reply #3 on: November 23, 2010, 00:31:12 »
As long as you're willing to change the source, you can use this small patch :

Code: [Select]
diff --git a/gmusicbrowser_songs.pm b/gmusicbrowser_songs.pm
index 845a4d3..9a7eabb 100644
--- a/gmusicbrowser_songs.pm
+++ b/gmusicbrowser_songs.pm
@@ -163,6 +163,7 @@ our %timespan_menu=
                load_extra      => '__#mainfield#_gid{#SGID#} || return;',
                save_extra      => 'my %h; while ( my ($sgid,$gid)=each %__#mainfield#_gid ) { $h{$sgid}= [#SUBFIELDS#] } delete $h{""}; return \%h;',
                #plugin         => 'picture',
+               newval          => 'push @#_iname#, do { my $artist=::superlc( #_name#[-1] ); $artist=~s/^the\s+//; $artist; };',
        },
        album   =>
        {       parent          => 'fewstring',

It will remove the "the" from the string that is used to sort artists case-insensitively and for case insensitive matches.
There are other possible ways to do this kind of things, let me know how you would prefer.

explanation of the patch : this line override the default value of "newval" found in the "fewstring" definition :
Code: [Select]
newval => 'push @#_iname#, ::superlc( #_name#[-1] );',the "newval" code is used for every new artist name
superlc is a function that lowercase and remove accents. (I'm not sure removing the accents is such a good idea btw, it's a very complicated question, I will probably make it optional).


Part of the reason I haven't implemented it yet, is that I'm not sure what is the preferred way for this to work :
- ignoring the "the" when sorting, or putting the "the" at the end
- if the displayed artist string is modified, should the modified version be used everywhere or just in some places


Also there is some tags that can be used to specify how an artist name/ album name/... should be sorted, but I'm not sure what to do if the same artist/album has not always the same "sort string".