[tracker/ovi-entityid: 1/2] Add a property for OVI/EntityId and extract it from mp3 files.
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/ovi-entityid: 1/2] Add a property for OVI/EntityId and extract it from mp3 files.
- Date: Wed, 21 Sep 2011 15:14:30 +0000 (UTC)
commit 2f77aec2b5c3ac3a755e4baf89d8e4c5cba18f1e
Author: Mikael Ottela <mikael ottela ixonos com>
Date: Thu Sep 15 15:20:35 2011 +0300
Add a property for OVI/EntityId and extract it from mp3 files.
Fixes NB#280284, Ovi/EntityId needs to be extracted from mp3 song metadata
data/ontologies/38-nmm.ontology | 11 ++++-
src/tracker-extract/tracker-extract-mp3.c | 83 +++++++++++++++++++++++++++++
2 files changed, 93 insertions(+), 1 deletions(-)
---
diff --git a/data/ontologies/38-nmm.ontology b/data/ontologies/38-nmm.ontology
index ea3e6be..5a84313 100644
--- a/data/ontologies/38-nmm.ontology
+++ b/data/ontologies/38-nmm.ontology
@@ -13,7 +13,7 @@
nmm: a tracker:Namespace, tracker:Ontology ;
tracker:prefix "nmm" ;
- nao:lastModified "2011-08-19T13:05:00Z" .
+ nao:lastModified "2011-09-21T16:57:00Z" .
nmm:MusicPiece a rdfs:Class ;
rdfs:label "Music" ;
@@ -543,3 +543,12 @@ nmm:uPnPShared a rdf:Property ;
nrl:maxCardinality 1 ;
rdfs:domain nfo:Media ;
rdfs:range xsd:boolean .
+
+# Resources related to online services (recognition)
+
+nmm:OVIEntityId a rdf:Property ;
+ rdfs:label "OVI Entity ID" ;
+ rdfs:comment "Nokia OVI service entity ID for identification" ;
+ nrl:maxCardinality 1 ;
+ rdfs:domain nfo:Media ;
+ rdfs:range xsd:string .
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 2c944f8..2369e53 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -101,6 +101,7 @@ typedef struct {
gint track_count;
gint set_number;
gint set_count;
+ gchar *ovi_entityid;
} id3v2tag;
typedef enum {
@@ -145,6 +146,7 @@ typedef enum {
ID3V24_TPUB,
ID3V24_TRCK,
ID3V24_TPOS,
+ ID3V24_TXXX,
ID3V24_TYER,
} id3v24frame;
@@ -172,6 +174,7 @@ typedef struct {
gint track_count;
gint set_number;
gint set_count;
+ const gchar *ovi_entityid;
unsigned char *albumart_data;
size_t albumart_size;
@@ -222,6 +225,7 @@ static const struct {
{ "TPOS", ID3V24_TPOS },
{ "TPUB", ID3V24_TPUB },
{ "TRCK", ID3V24_TRCK },
+ { "TXXX", ID3V24_TXXX },
{ "TYER", ID3V24_TYER },
};
@@ -1283,6 +1287,41 @@ get_id3v24_tags (id3v24frame frame,
break;
}
+ case ID3V24_TXXX: {
+ gchar *word;
+ gchar *prop;
+ gchar text_encode;
+ const gchar *text_desc;
+ const gchar *text;
+ guint offset;
+ gint text_desc_len;
+
+ text_encode = data[pos + 0]; /* $xx */
+ text_desc = &data[pos + 1]; /* <text string according to encoding> $00 (00) */
+ text_desc_len = id3v2_strlen (text_encode, text_desc, csize - 1);
+
+ offset = 1 + text_desc_len + id3v2_nul_size (text_encode);
+ text = &data[pos + offset]; /* <full text string according to encoding> */
+
+ prop = id3v24_text_to_utf8 (text_encode, text_desc, text_desc_len, info);
+ word = id3v24_text_to_utf8 (text_encode, text, csize - offset, info);
+
+ if (!tracker_is_empty_string (word) &&
+ !tracker_is_empty_string (prop)) {
+ g_strstrip (word);
+
+ if (strcmp (prop, "OVI/EntityId") == 0) {
+ tag->ovi_entityid = word;
+ }
+
+ g_free (prop);
+ } else {
+ g_free (word);
+ g_free (prop);
+ }
+ break;
+ }
+
default: {
gchar *word;
@@ -1470,6 +1509,41 @@ get_id3v23_tags (id3v24frame frame,
break;
}
+ case ID3V24_TXXX: {
+ gchar *word;
+ gchar *prop;
+ gchar text_encode;
+ const gchar *text_desc;
+ const gchar *text;
+ guint offset;
+ gint text_desc_len;
+
+ text_encode = data[pos + 0]; /* $xx */
+ text_desc = &data[pos + 1]; /* <text string according to encoding> $00 (00) */
+ text_desc_len = id3v2_strlen (text_encode, text_desc, csize - 1);
+
+ offset = 1 + text_desc_len + id3v2_nul_size (text_encode);
+ text = &data[pos + offset]; /* <full text string according to encoding> */
+
+ prop = id3v24_text_to_utf8 (text_encode, text_desc, text_desc_len, info);
+ word = id3v24_text_to_utf8 (text_encode, text, csize - offset, info);
+
+ if (!tracker_is_empty_string (word) &&
+ !tracker_is_empty_string (prop)) {
+ g_strstrip (word);
+
+ if (strcmp (prop, "OVI/EntityId") == 0) {
+ tag->ovi_entityid = word;
+ }
+
+ g_free (prop);
+ } else {
+ g_free (word);
+ g_free (prop);
+ }
+ break;
+ }
+
default: {
gchar *word;
@@ -2222,6 +2296,10 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
md.id3v23.encoded_by,
md.id3v22.encoded_by);
+ md.ovi_entityid = tracker_coalesce_strip (3, md.id3v24.ovi_entityid,
+ md.id3v23.ovi_entityid,
+ md.id3v22.ovi_entityid);
+
if (md.id3v24.track_number != 0) {
md.track_number = md.id3v24.track_number;
} else if (md.id3v23.track_number != 0) {
@@ -2438,6 +2516,11 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
tracker_sparql_builder_object_unvalidated (metadata, md.encoded_by);
}
+ if (md.ovi_entityid) {
+ tracker_sparql_builder_predicate (metadata, "nmm:OVIEntityId");
+ tracker_sparql_builder_object_unvalidated (metadata, md.ovi_entityid);
+ }
+
if (md.track_number > 0) {
tracker_sparql_builder_predicate (metadata, "nmm:trackNumber");
tracker_sparql_builder_object_int64 (metadata, md.track_number);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]