const char *moose_metadata_query_get_error(MooseMetadataQuery *self) { g_assert(self); MooseMetadataQueryPrivate *priv = moose_metadata_query_get_instance_private(self); if(priv->query.q_errno == GLYRE_UNKNOWN) { return NULL; } else { return glyr_strerror(priv->query.q_errno); } }
END_TEST //-------------------- START_TEST(test_glyr_opt_redirects) { GlyrQuery q; setup(&q, GLYR_GET_COVERART, 1); glyr_opt_from(&q, "amazon"); glyr_opt_redirects(&q, 0); int length = 0; GLYR_ERROR err = GLYRE_OK; GlyrMemCache *list = glyr_get(&q, &err, &length); fail_unless(list == NULL, "should fail due to redirects"); if(err != GLYRE_OK) { puts(glyr_strerror(err)); } unsetup(&q, list); }
int main(int argc, char *argv[]) { /* You need to call this before anything happens */ glyr_init(); atexit(glyr_cleanup); /* Initialize a new query (this may allocate memory) */ GlyrQuery q; glyr_query_init(&q); /* Say we want a Songtext */ GLYR_GET_TYPE type = GLYR_GET_LYRICS; glyr_opt_type(&q, type); /* Set at least the required fields to your needs * * For lyrics those are 'artist' and 'title', ('album') * * is strictly optional and may be used by a few plugins */ glyr_opt_artist(&q, (char *) "Die Apokalyptischen Reiter"); glyr_opt_album(&q, (char *) "Riders on the Storm"); glyr_opt_title(&q, (char *) "Friede sei mit dir"); /* Execute a func when getting one item */ int this_be_my_counter = 0; glyr_opt_dlcallback(&q, funny_callback, &this_be_my_counter); /* For the start: Enable verbosity */ glyr_opt_verbosity(&q, 2); /* Download 5 (or less) items */ glyr_opt_number(&q, 5); /* Just search, without downloading items */ glyr_opt_download(&q, 0); /* Call the most important command: GET! * This returned a list of (GlyrMemCache *)s * Each containing ONE item. (i.e. a songtext) */ GLYR_ERROR err; GlyrMemCache *it = glyr_get(&q, &err, NULL); if(err != GLYRE_OK) { fprintf(stderr, "E:%s\n", glyr_strerror(err)); } /* Now iterate through it... */ if(it != NULL) { GlyrMemCache *start = it; int counter = 0; while(it != NULL) { /* This has the same effect as in the callback, * Just that it's executed just once after all DL is done. * Commented out, as this would print it twice * */ print_item(it, counter); /* Every cache has a link to the next and prev one (or NULL respectively) */ it = it->next; ++counter; } /* The contents of it are dynamically allocated. */ /* So better free them if you're not keen on memoryleaks */ glyr_free_list(start); } /* Destroy query (reset to default values and free dyn memory) */ /* You could start right off to use this query in another glyr_get */ glyr_query_destroy(&q); return EXIT_SUCCESS; }