Always assume Icecast-style stream metadata is in the "Artist - Title" format, as this seems more common. Remove the hacks for soma.fm and stations from the icecast list. Fixes issue 1035

This commit is contained in:
David Sansome 2011-07-26 15:56:19 +01:00
parent b628c2a26e
commit ae4cfeff1c
2 changed files with 10 additions and 12 deletions

View File

@ -341,16 +341,17 @@ void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle) {
// Maybe the metadata is from icycast and has "Artist - Title" shoved // Maybe the metadata is from icycast and has "Artist - Title" shoved
// together in the title field. // together in the title field.
int dash_pos = bundle_copy.title.indexOf('-'); const int dash_pos = bundle_copy.title.indexOf('-');
if (dash_pos != -1 && bundle_copy.artist.isEmpty()) { if (dash_pos != -1 && bundle_copy.artist.isEmpty()) {
bundle_copy.artist = bundle_copy.title.mid(dash_pos + 1).trimmed(); // Split on " - " if it exists, otherwise split on "-".
bundle_copy.title = bundle_copy.title.left(dash_pos).trimmed(); const int space_dash_pos = bundle_copy.title.indexOf(" - ");
} if (space_dash_pos != -1) {
bundle_copy.artist = bundle_copy.title.left(space_dash_pos).trimmed();
// Hack as SomaFM's and icecast's artist/title descriptions are backwards. bundle_copy.title = bundle_copy.title.mid(space_dash_pos + 3).trimmed();
if (item->Url().host().contains("somafm.com") || } else {
item->Url().fragment() == "icecast") { bundle_copy.artist = bundle_copy.title.left(dash_pos).trimmed();
qSwap(bundle_copy.artist, bundle_copy.title); bundle_copy.title = bundle_copy.title.mid(dash_pos + 1).trimmed();
}
} }
Song song = item->Metadata(); Song song = item->Metadata();

View File

@ -260,9 +260,6 @@ IcecastBackend::Station IcecastService::ReadStation(QXmlStreamReader* reader) co
station.genre[0] = station.genre[0].toUpper(); station.genre[0] = station.genre[0].toUpper();
} }
// HACK: This hints to the player that the artist and title metadata needs swapping.
station.url.setFragment("icecast");
return station; return station;
} }