[grilo-plugins] [shoutcast] Change id encoding in search()
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] [shoutcast] Change id encoding in search()
- Date: Thu, 3 Jun 2010 08:20:15 +0000 (UTC)
commit 3ef4de5f0cb844c3b2eed7684a29772247a55503
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Thu Jun 3 10:14:14 2010 +0200
[shoutcast] Change id encoding in search()
So far, id was formed by concatenating Genre + StationID, except in results
from search, where was encoded as "?" + Search text + StationID.
As it can be seen, two different ways of encoding id.
But 2nd-way encoding has a problem: as SHOUTCast does not provides an API to
query metadata, it is resolved in plugin as repeating the same operation that
led to result, and then getting it from the results. Thus, in first case it
browses the same Genre and then pick the station id, while in the second case
it searches the same string and then pick the result (that is why the "?" is
needed).
The problem is that it is possible than when repeating the searching, the
element is not retrieved. Reason is that could be in the first search a
different limit was applied, so in the second search limit is not the same and
thus different results are retrieved.
To avoid this problem and in order to keep a consistent ID, this patch gets rid
of second approach and always uses the first one: id is encoded as "Genre +
StationID.
src/shoutcast/grl-shoutcast.c | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/src/shoutcast/grl-shoutcast.c b/src/shoutcast/grl-shoutcast.c
index 9522e3a..a373e86 100644
--- a/src/shoutcast/grl-shoutcast.c
+++ b/src/shoutcast/grl-shoutcast.c
@@ -212,10 +212,12 @@ static GrlMedia *
build_media_from_station (OperationData *op_data)
{
GrlMedia *media;
+ gchar **station_genres = NULL;
gchar *media_id;
gchar *media_url;
gchar *station_bitrate;
gchar *station_genre;
+ gchar *station_genre_field;
gchar *station_id;
gchar *station_mime;
gchar *station_name;
@@ -226,19 +228,27 @@ build_media_from_station (OperationData *op_data)
(const xmlChar *) "mt");
station_id = (gchar *) xmlGetProp (op_data->xml_entries,
(const xmlChar *) "id");
- station_genre = (gchar *) xmlGetProp (op_data->xml_entries,
- (const xmlChar *) "genre");
station_bitrate = (gchar *) xmlGetProp (op_data->xml_entries,
(const xmlChar *) "br");
- media_id = g_strconcat (op_data->genre, "/", station_id, NULL);
- media_url = g_strdup_printf (SHOUTCAST_TUNE, station_id);
-
if (op_data->media) {
media = op_data->media;
} else {
media = grl_media_audio_new ();
}
+ if (op_data->genre) {
+ station_genre = op_data->genre;
+ } else {
+ station_genre_field = (gchar *) xmlGetProp (op_data->xml_entries,
+ (const xmlChar *) "genre");
+ station_genres = g_strsplit (station_genre_field, " ", -1);
+ g_free (station_genre_field);
+ station_genre = station_genres[0];
+ }
+
+ media_id = g_strconcat (station_genre, "/", station_id, NULL);
+ media_url = g_strdup_printf (SHOUTCAST_TUNE, station_id);
+
grl_media_set_id (media, media_id);
grl_media_set_title (media, station_name);
grl_media_set_mime (media, station_mime);
@@ -250,10 +260,12 @@ build_media_from_station (OperationData *op_data)
g_free (station_name);
g_free (station_mime);
g_free (station_id);
- g_free (station_genre);
g_free (station_bitrate);
g_free (media_id);
g_free (media_url);
+ if (station_genres) {
+ g_strfreev (station_genres);
+ }
return media;
}
@@ -677,7 +689,6 @@ grl_shoutcast_source_search (GrlMediaSource *source,
data->count = ss->count;
data->user_data = ss->user_data;
data->error_code = GRL_ERROR_SEARCH_FAILED;
- data->genre = g_strconcat ("?", ss->text, NULL);
grl_media_source_set_operation_data (source, ss->search_id, data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]