Skip to content

Commit 3cfb280

Browse files
committed
Add genre menu to channel list when group by channel is disabled
1 parent 5fb3b96 commit 3cfb280

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

Plugin.pm

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use feature qw(fc);
1414

1515
use JSON::XS::VersionOneAndTwo;
1616

17-
use Slim::Utils::Strings qw(string);
17+
use Slim::Utils::Strings qw(string cstring);
1818
use Slim::Utils::Prefs;
1919
use Slim::Utils::Log;
2020

@@ -91,10 +91,10 @@ sub _feedHandler {
9191
my $json = eval { from_json($http->content) };
9292

9393
if ($prefs->get('groupByGenre')) {
94-
_parseChannelsWithGroupByGenre($json->{'channels'}, $menu);
94+
_parseChannelsWithGroupByGenre($client, $json->{'channels'}, $menu);
9595
}
9696
else {
97-
_parseChannels(_sortChannels($json->{'channels'}), $menu);
97+
_parseChannels($client, _sortChannels($json->{'channels'}), $menu);
9898
}
9999

100100
$callback->({
@@ -119,15 +119,24 @@ sub _feedHandler {
119119
}
120120

121121
sub _parseChannels {
122-
my ($channels, $menu) = @_;
122+
my ($client, $channels, $menu) = @_;
123123

124124
for my $channel (@$channels) {
125125
push @$menu, _parseChannel($channel);
126126
}
127+
128+
if (!$prefs->get('groupByGenre')) {
129+
push @$menu, {
130+
name => cstring($client, 'PLUGIN_SOMAFM_BY_GENRE'),
131+
type => 'menu',
132+
image => 'html/images/genres.png',
133+
items => [_parseChannelsWithGroupByGenre($client, $channels)]
134+
};
135+
}
127136
}
128137

129138
sub _parseChannelsWithGroupByGenre {
130-
my ($channels, $menu) = @_;
139+
my ($client, $channels, $menu) = @_;
131140

132141
my %menu_items;
133142

strings.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ PLUGIN_SOMAFM_ORDER_BY_TITLE
2929
EN Title
3030

3131
PLUGIN_SOMAFM_GROUP_BY_GENRE
32-
EN Group by genre
32+
EN Group by genre first
3333

3434
PLUGIN_SOMAFM_GROUP_BY_GENRE_DESC
35-
EN Group channels by genre. This create submenus for each genre. Channels are sorted within the genre menu
35+
EN Group channels by genre in the first menu. This create submenus for each genre. Channels are sorted within the genre menu. If disabled, the genre menu is shown at the end of all channels.
36+
37+
PLUGIN_SOMAFM_BY_GENRE
38+
EN Genres
3639

3740
PLUGIN_SOMAFM_ORDER_BY_NONE
3841
EN No sorting

0 commit comments

Comments
 (0)