Пример #1
0
/* Wrap around the (a bit more) generic versions */
static GList * tags_musicbrainz_parse (cb_object * capo)
{
    GList * results = NULL;
    gint mbid_marker = 0;
    while (continue_search (g_list_length (results), capo->s) )
    {
        GlyrMemCache  * info = generic_musicbrainz_parse (capo,&mbid_marker,"tags");
        if (info == NULL)
        {
            break;
        }

        gint type_num = please_what_type (capo->s);
        gchar * tag_node = info->data;
        while ( (tag_node = strstr (tag_node + 1,"<tag") ) )
        {
            gchar * tag_begin = strchr (tag_node+1,'>');
            if (!tag_begin)
                continue;

            tag_begin++;
            gchar * tag_endin = strchr (tag_begin,'<');
            if (!tag_endin)
                continue;

            gchar * value = copy_value (tag_begin,tag_endin);
            if (value != NULL)
            {
                if (strlen (value) > 0)
                {
                    GlyrMemCache * tmp = DL_init();
                    tmp->data = value;
                    tmp->size = tag_endin - tag_begin;
                    tmp->type = type_num;
                    tmp->dsrc = g_strdup (info->dsrc);

                    results = g_list_prepend (results,tmp);
                }
            }
        }
        DL_free (info);
    }
    return results;
}
Пример #2
0
/* Wrap around the (a bit more) generic versions */
static GList * relations_musicbrainz_parse (cb_object * capo)
{
    GList * results = NULL;
    gint mbid_marker = 0;
    while (continue_search (g_list_length (results), capo->s) )
    {
        GlyrMemCache  * infobuf = generic_musicbrainz_parse (capo,&mbid_marker,"url-rels");
        if (infobuf == NULL)
        {
            break;
        }
        gsize nlen = (sizeof RELATION_BEGIN_TYPE) - 1;
        gchar * node = strstr (infobuf->data,RELATION_TARGLYR_GET_TYPE);
        if (node != NULL)
        {
            gint ctr = 0;
            while (continue_search (ctr,capo->s) && (node = strstr (node+nlen,RELATION_BEGIN_TYPE) ) )
            {
                node += nlen;
                gchar * target = get_search_value (node,"target=\"","\"");
                gchar * type   = get_search_value (node,"type=\"","\"");

                if (type != NULL && target != NULL)
                {
                    GlyrMemCache * tmp = DL_init();
                    tmp->data = g_strdup_printf ("%s:%s",type,target);
                    tmp->size = strlen (tmp->data);
                    tmp->dsrc = g_strdup (infobuf->dsrc);
                    results = g_list_prepend (results,tmp);
                    ctr++;

                    g_free (type);
                    g_free (target);
                }
            }
        }
        DL_free (infobuf);
    }
    return results;
}