1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-17 20:09:50 +01:00

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
// 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()) {
bundle_copy.artist = bundle_copy.title.mid(dash_pos + 1).trimmed();
bundle_copy.title = bundle_copy.title.left(dash_pos).trimmed();
}
// Hack as SomaFM's and icecast's artist/title descriptions are backwards.
if (item->Url().host().contains("somafm.com") ||
item->Url().fragment() == "icecast") {
qSwap(bundle_copy.artist, bundle_copy.title);
// Split on " - " if it exists, otherwise split on "-".
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();
bundle_copy.title = bundle_copy.title.mid(space_dash_pos + 3).trimmed();
} else {
bundle_copy.artist = bundle_copy.title.left(dash_pos).trimmed();
bundle_copy.title = bundle_copy.title.mid(dash_pos + 1).trimmed();
}
}
Song song = item->Metadata();

View File

@ -260,9 +260,6 @@ IcecastBackend::Station IcecastService::ReadStation(QXmlStreamReader* reader) co
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;
}