From 0019dee34bad6760eaa065e1bf10c1a33ace2b80 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 14 Feb 2020 16:21:47 +0100 Subject: Revert "quvi: Rename videosite parser" This reverts commit 4a9a686f9590a44ca8af35b5b5a67c1be7765712. --- plparse/meson.build | 14 ++-- plparse/tests/meson.build | 2 +- plparse/videosite-parser.c | 191 +++++++++++++++++++++++++++++++++++++++++++++ plparse/videosite-quvi.c | 191 --------------------------------------------- 4 files changed, 199 insertions(+), 199 deletions(-) create mode 100644 plparse/videosite-parser.c delete mode 100644 plparse/videosite-quvi.c diff --git a/plparse/meson.build b/plparse/meson.build index fb21ed4..668a072 100644 --- a/plparse/meson.build +++ b/plparse/meson.build @@ -111,13 +111,13 @@ plparser_mini_lib = library('totem-plparser-mini', install: true) if have_quvi - videosite_quvi_exe = executable('99-totem-pl-parser-videosite-quvi', - 'videosite-quvi.c', totem_pl_parser_builtins_h, - c_args: '-DLIBEXECDIR="@0@"'.format(libexecdir), - include_directories: [config_inc, totemlib_inc], - dependencies: [quvi_dep, glib_dep], - install_dir: join_paths(libexecdir, 'totem-pl-parser'), - install: true) + videosite_exe = executable('99-totem-pl-parser-videosite', + 'videosite-parser.c', totem_pl_parser_builtins_h, + c_args: '-DLIBEXECDIR="@0@"'.format(libexecdir), + include_directories: [config_inc, totemlib_inc], + dependencies: [quvi_dep, glib_dep], + install_dir: join_paths(libexecdir, 'totem-pl-parser'), + install: true) endif # Introspection diff --git a/plparse/tests/meson.build b/plparse/tests/meson.build index fc7bf9a..3611613 100644 --- a/plparse/tests/meson.build +++ b/plparse/tests/meson.build @@ -10,7 +10,7 @@ foreach test_name : tests env = environment() if have_quvi - env.set('TOTEM_PL_PARSER_VIDEOSITE_SCRIPT', videosite_quvi_exe.full_path()) + env.set('TOTEM_PL_PARSER_VIDEOSITE_SCRIPT', videosite_exe.full_path()) endif test(test_name, exe, env: env, timeout: 3 * 60) diff --git a/plparse/videosite-parser.c b/plparse/videosite-parser.c new file mode 100644 index 0000000..be374aa --- /dev/null +++ b/plparse/videosite-parser.c @@ -0,0 +1,191 @@ +/* + Copyright (C) 2013 Bastien Nocera + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301 USA. + + Author: Bastien Nocera + */ + +#include "config.h" + +#include + +#include +#include +#include "totem-pl-parser.h" + +#define BASE 20 + +static char *url = NULL; +static gboolean check = FALSE; +static gboolean debug = FALSE; + +const GOptionEntry options[] = { + { "url", 'u', 0, G_OPTION_ARG_FILENAME, &url, "URL of the video site page", NULL }, + { "check", 'c', 0, G_OPTION_ARG_NONE, &check, "Check whether this URL is supported", NULL }, + { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, "Turn on debug mode", NULL }, + { NULL } +}; + +static gboolean +supports_uri (const char *uri) +{ + quvi_t q; + QuviBoolean r; + + q = quvi_new (); + r = quvi_supports (q, uri, QUVI_SUPPORTS_MODE_OFFLINE, QUVI_SUPPORTS_TYPE_ANY); + quvi_free (q); + + return r; +} + +static struct { + const char *container; + const char *content_type; +} containers [] = { + { "webm", "video/webm" }, +}; + +static const char * +container_to_content_type (const char *container) +{ + guint i; + + if (container == NULL) + return NULL; + for (i = 0; i < G_N_ELEMENTS (containers); i++) { + if (g_str_equal (container, containers[i].container)) + return containers[i].content_type; + } + return NULL; +} + +static void +print (const char *name, + const char *value) +{ + g_return_if_fail (name != NULL); + + if (value == NULL) + return; + + g_print ("%s=%s\n", name, value); +} + +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 ("TOTEM_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 ("TOTEM_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 (TOTEM_PL_PARSER_FIELD_TITLE, title); + print (TOTEM_PL_PARSER_FIELD_ID, id); + print (TOTEM_PL_PARSER_FIELD_MOREINFO, uri); + print (TOTEM_PL_PARSER_FIELD_URI, video_uri); + print (TOTEM_PL_PARSER_FIELD_STARTTIME, starttime_str); + print (TOTEM_PL_PARSER_FIELD_CONTENT_TYPE, content_type); + print (TOTEM_PL_PARSER_FIELD_IMAGE_URI, thumb_url); + print (TOTEM_PL_PARSER_FIELD_DURATION, duration_str); + } + + g_free (starttime_str); + g_free (duration_str); + +out: + quvi_media_free (qm); + quvi_free (q); +} + +int main (int argc, char **argv) +{ + GOptionContext *context; + + setlocale (LC_ALL, ""); + + context = g_option_context_new (NULL); + g_option_context_set_summary (context, "totem-pl-parser libquvi Helper"); + g_option_context_add_main_entries (context, options, NULL); + g_option_context_parse (context, &argc, &argv, NULL); + + if (url == NULL) { + char *txt; + + txt = g_option_context_get_help (context, FALSE, NULL); + g_print ("%s", txt); + g_free (txt); + + g_option_context_free (context); + + return 1; + } + g_option_context_free (context); + + if (check) { + g_print ("%s", supports_uri (url) ? "TRUE" : "FALSE"); + return 0; + } + + parse_videosite (url); + + return 0; +} diff --git a/plparse/videosite-quvi.c b/plparse/videosite-quvi.c deleted file mode 100644 index be374aa..0000000 --- a/plparse/videosite-quvi.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - Copyright (C) 2013 Bastien Nocera - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301 USA. - - Author: Bastien Nocera - */ - -#include "config.h" - -#include - -#include -#include -#include "totem-pl-parser.h" - -#define BASE 20 - -static char *url = NULL; -static gboolean check = FALSE; -static gboolean debug = FALSE; - -const GOptionEntry options[] = { - { "url", 'u', 0, G_OPTION_ARG_FILENAME, &url, "URL of the video site page", NULL }, - { "check", 'c', 0, G_OPTION_ARG_NONE, &check, "Check whether this URL is supported", NULL }, - { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, "Turn on debug mode", NULL }, - { NULL } -}; - -static gboolean -supports_uri (const char *uri) -{ - quvi_t q; - QuviBoolean r; - - q = quvi_new (); - r = quvi_supports (q, uri, QUVI_SUPPORTS_MODE_OFFLINE, QUVI_SUPPORTS_TYPE_ANY); - quvi_free (q); - - return r; -} - -static struct { - const char *container; - const char *content_type; -} containers [] = { - { "webm", "video/webm" }, -}; - -static const char * -container_to_content_type (const char *container) -{ - guint i; - - if (container == NULL) - return NULL; - for (i = 0; i < G_N_ELEMENTS (containers); i++) { - if (g_str_equal (container, containers[i].container)) - return containers[i].content_type; - } - return NULL; -} - -static void -print (const char *name, - const char *value) -{ - g_return_if_fail (name != NULL); - - if (value == NULL) - return; - - g_print ("%s=%s\n", name, value); -} - -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 ("TOTEM_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 ("TOTEM_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 (TOTEM_PL_PARSER_FIELD_TITLE, title); - print (TOTEM_PL_PARSER_FIELD_ID, id); - print (TOTEM_PL_PARSER_FIELD_MOREINFO, uri); - print (TOTEM_PL_PARSER_FIELD_URI, video_uri); - print (TOTEM_PL_PARSER_FIELD_STARTTIME, starttime_str); - print (TOTEM_PL_PARSER_FIELD_CONTENT_TYPE, content_type); - print (TOTEM_PL_PARSER_FIELD_IMAGE_URI, thumb_url); - print (TOTEM_PL_PARSER_FIELD_DURATION, duration_str); - } - - g_free (starttime_str); - g_free (duration_str); - -out: - quvi_media_free (qm); - quvi_free (q); -} - -int main (int argc, char **argv) -{ - GOptionContext *context; - - setlocale (LC_ALL, ""); - - context = g_option_context_new (NULL); - g_option_context_set_summary (context, "totem-pl-parser libquvi Helper"); - g_option_context_add_main_entries (context, options, NULL); - g_option_context_parse (context, &argc, &argv, NULL); - - if (url == NULL) { - char *txt; - - txt = g_option_context_get_help (context, FALSE, NULL); - g_print ("%s", txt); - g_free (txt); - - g_option_context_free (context); - - return 1; - } - g_option_context_free (context); - - if (check) { - g_print ("%s", supports_uri (url) ? "TRUE" : "FALSE"); - return 0; - } - - parse_videosite (url); - - return 0; -} -- cgit v1.2.1