示例#1
0
文件: check_opt.c 项目: lejenome/glyr
END_TEST

//--------------------

START_TEST(test_glyr_opt_proxy)
{
    GlyrQuery q;
    setup(&q, GLYR_GET_COVERART, 1);
    glyr_opt_verbosity(&q, 0);
    glyr_opt_proxy(&q, "I can haz Existence?");

    GlyrMemCache *list = glyr_get(&q, NULL, NULL);
    fail_unless(list == NULL, NULL);

    glyr_cache_free(list);
    glyr_query_destroy(&q);
}
示例#2
0
文件: check_opt.c 项目: lejenome/glyr
END_TEST

//--------------------
// from
// plugmax

START_TEST(test_glyr_opt_allowed_formats)
{
    GlyrQuery q;
    setup(&q, GLYR_GET_COVERART, 1);
    glyr_opt_verbosity(&q, 0);
    glyr_opt_allowed_formats(&q, "png");

    int length = 0;
    GlyrMemCache *list = glyr_get(&q, NULL, &length);

    fail_if(strcmp(list->img_format, "png") != 0, NULL);

    unsetup(&q, list);
}
void moose_metadata_query_enable_debug(MooseMetadataQuery *self) {
    g_assert(self);

    MooseMetadataQueryPrivate *priv = moose_metadata_query_get_instance_private(self);
    glyr_opt_verbosity(&priv->query, 4);
}
示例#4
0
文件: example.c 项目: lejenome/glyr
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;
}