Beispiel #1
0
static GList * factory (GlyrQuery * s, GList * list, gboolean * stop_me, GList ** result_list)
{
    /* Fix up tabs, escape chars etc.  */
    for (GList * elem = list; elem; elem = elem->next)
    {
        GlyrMemCache * item = elem->data;
        if (item != NULL)
        {
            gchar * temp = beautify_string (item->data);
            g_free (item->data);
            item->data = temp;
            item->size = (item->data) ? strlen (item->data) : 0;
        }
    }

    /* Let the rest do by the norma generic finalizer */
    return generic_txt_finalizer (s,list,stop_me,GLYR_TYPE_GUITARTABS,result_list);
}
Beispiel #2
0
static GList * factory (GlyrQuery * s, GList * list, gboolean * stop_me, GList ** result_list)
{
    return generic_txt_finalizer (s,list,stop_me,GLYR_TYPE_TRACK,result_list);
}
Beispiel #3
0
GList * generic_img_finalizer(GlyrQuery * s, GList * list, gboolean * stop_me, GLYR_DATA_TYPE type, GList ** result_list)
{
	/* Just return URLs */
	if(s->download == false)
	{
		for(GList * elem = list; elem; elem = elem->next)
		{
			GlyrMemCache * img = elem->data;
			img->is_image = false;
		}
		return generic_txt_finalizer(s,list,stop_me,GLYR_TYPE_IMG_URL,result_list);
	}
	else
	{
		/* Convert to a list of URLs first */
		GList * url_list  = NULL;

		/* Hashtable to associate the provider name with the corresponding URL */
		GHashTable * cache_url_table = g_hash_table_new_full(g_str_hash,g_str_equal,
				NULL,
				(GDestroyNotify)DL_free
				);

		/* Iterate over all caches and turn them to GList */
		for(GList * item = list; item; item = item->next)
		{
			GlyrMemCache * cache = item->data;

			/* Make a copy, since we free the cache */
			gchar * url_double = g_strdup(cache->data);
			url_list  = g_list_prepend(url_list,url_double);

			/* Fill in the URL */
			g_hash_table_insert(cache_url_table,(gpointer)url_double,(gpointer)cache);
		}

		/* We need to pass this to the callback */
		struct callback_save_struct userptr =
		{
			.table = cache_url_table,
			.type  = type,
			.results = result_list ? result_list[0] : NULL
		};

		/* Download images in parallel */
		GList * dl_raw_images = async_download(url_list,NULL,s,1,(g_list_length(url_list)/2),async_dl_callback,&userptr,FALSE);

		/* Default to the given type */
		for(GList * elem = dl_raw_images; elem; elem = elem->next)
		{
			GlyrMemCache * item = elem->data;
			if(item && item->type == GLYR_TYPE_NOIDEA)
			{
				item->type = type;
			}
		}

		/* Freeing Party */
		g_hash_table_destroy(cache_url_table);
		glist_free_full(url_list,g_free);

		/* Ready to save images */
		return dl_raw_images;
	}
	return NULL;
}