gint main(gint argc, gchar **argv) { gint i,r; gchar *s; g_assert(qm == NULL); g_assert(q == NULL); memset(&opts, 0, sizeof(struct _opts_s)); setlocale(LC_ALL, ""); r = opts_new(argc, argv); if (r != EXIT_SUCCESS) return (r); q = quvi_new(); examples_exit_if_error(); if (opts.autoproxy == TRUE) examples_enable_autoproxy(); if (opts.verbose == TRUE) examples_enable_verbose(); quvi_set(q, QUVI_OPTION_CALLBACK_STATUS, (qcs) examples_status); for (i=0; opts.url[i] != NULL; ++i) { qm = quvi_media_new(q, opts.url[i]); examples_exit_if_error(); quvi_media_get(qm, QUVI_MEDIA_PROPERTY_TITLE, &s); g_print("[%s]\n title='%s'\n", __func__, s); if (opts.best == TRUE) { quvi_media_stream_choose_best(qm); dump_stream(); } else if (opts.stream != NULL) { quvi_media_stream_select(qm, opts.stream); examples_exit_if_error(); dump_stream(); } else dump_streams(); quvi_media_free(qm); qm = NULL; } opts_free(); examples_cleanup(); g_assert(qm == NULL); g_assert(q == NULL); return (r); }
static QuviError _select(_quvi_media_t qm, const gchar *id) { _quvi_media_stream_t qms; gboolean found_flag; QuviError rc; gchar **r; gint i; quvi_media_stream_reset(qm); r = g_strsplit(id, ",", 0); found_flag = FALSE; rc = QUVI_OK; for (i=0; (r[i] != NULL && found_flag == FALSE); ++i) { if (g_strcmp0(r[i], "croak") ==0) { rc = QUVI_ERROR_KEYWORD_CROAK; break; } else if (g_strcmp0(r[i], "best") == 0) { quvi_media_stream_choose_best(qm); break; } else { while (quvi_media_stream_next(qm) == QUVI_TRUE) { /* TODO: Use quvi_media_get? */ qms = (_quvi_media_stream_t) qm->curr.stream->data; found_flag = m_match(qms->id->str, r[i]); if (found_flag == TRUE) break; } if (found_flag == FALSE) /* Use the first stream as a fallback. */ quvi_media_stream_reset(qm); } } g_strfreev(r); return (rc); }
static void parse_videosite (const char *uri) { quvi_t q; quvi_media_t qm; /* properties */ const char *video_uri; const char *title; const char *id; const char *content_type; const char *thumb_url; const char *container; double duration; double starttime; char *duration_str = NULL; char *starttime_str = NULL; if (!supports_uri (uri)) { g_print ("XPLAYER_PL_PARSER_RESULT_UNHANDLED"); return; } q = quvi_new (); qm = quvi_media_new (q, uri); /* Empty results list? */ if (quvi_media_stream_next(qm) != QUVI_TRUE) { if (debug) g_print ("Parsing '%s' failed with error: %s\n", uri, quvi_errmsg (q)); g_print ("XPLAYER_PL_PARSER_RESULT_ERROR"); goto out; } /* Choose the best stream */ quvi_media_stream_choose_best (qm); quvi_media_get (qm, QUVI_MEDIA_PROPERTY_TITLE, &title); quvi_media_get (qm, QUVI_MEDIA_PROPERTY_ID, &id); quvi_media_get (qm, QUVI_MEDIA_PROPERTY_THUMBNAIL_URL, &thumb_url); quvi_media_get (qm, QUVI_MEDIA_PROPERTY_DURATION_MS, &duration); if (duration) duration_str = g_strdup_printf ("%f", duration); quvi_media_get (qm, QUVI_MEDIA_STREAM_PROPERTY_URL, &video_uri); quvi_media_get (qm, QUVI_MEDIA_PROPERTY_START_TIME_MS, &starttime); if (starttime) starttime_str = g_strdup_printf ("%f", starttime); quvi_media_get (qm, QUVI_MEDIA_STREAM_PROPERTY_CONTAINER, &container); content_type = container_to_content_type (container); if (video_uri != NULL) { print (XPLAYER_PL_PARSER_FIELD_TITLE, title); print (XPLAYER_PL_PARSER_FIELD_ID, id); print (XPLAYER_PL_PARSER_FIELD_MOREINFO, uri); print (XPLAYER_PL_PARSER_FIELD_URI, video_uri); print (XPLAYER_PL_PARSER_FIELD_STARTTIME, starttime_str); print (XPLAYER_PL_PARSER_FIELD_CONTENT_TYPE, content_type); print (XPLAYER_PL_PARSER_FIELD_IMAGE_URI, thumb_url); print (XPLAYER_PL_PARSER_FIELD_DURATION, duration_str); } g_free (starttime_str); g_free (duration_str); out: quvi_media_free (qm); quvi_free (q); }