diff options
author | Victor Toso <victortoso@gnome.org> | 2021-03-20 21:55:56 +0100 |
---|---|---|
committer | Victor Toso <victortoso@gnome.org> | 2021-03-27 19:18:43 +0000 |
commit | d6d91c7cf27de78b0b0575daeeddb1ae7f69cc94 (patch) | |
tree | c36724205eab5b8ba4df1707b60f7a38c99713ce | |
parent | 2ce6c6e90f631357b6204bd10803f8641cb25db4 (diff) | |
download | grilo-plugins-d6d91c7cf27de78b0b0575daeeddb1ae7f69cc94.tar.gz |
vimeo: remove due API change v2->v3
This is not working for over a year now.
Related: https://gitlab.gnome.org/GNOME/grilo-plugins/-/issues/67
-rw-r--r-- | meson.build | 1 | ||||
-rw-r--r-- | meson_options.txt | 1 | ||||
-rw-r--r-- | src/vimeo/channel-vimeo.svg | 108 | ||||
-rw-r--r-- | src/vimeo/grl-vimeo.c | 564 | ||||
-rw-r--r-- | src/vimeo/grl-vimeo.h | 77 | ||||
-rw-r--r-- | src/vimeo/gvimeo.c | 500 | ||||
-rw-r--r-- | src/vimeo/gvimeo.h | 112 | ||||
-rw-r--r-- | src/vimeo/meson.build | 30 | ||||
-rw-r--r-- | src/vimeo/vimeo.gresource.xml | 6 | ||||
-rw-r--r-- | tests/meson.build | 1 | ||||
-rw-r--r-- | tests/vimeo/data/empty.data | 4 | ||||
-rw-r--r-- | tests/vimeo/data/network-data.ini | 9 | ||||
-rw-r--r-- | tests/vimeo/data/results.data | 87 | ||||
-rw-r--r-- | tests/vimeo/meson.build | 21 | ||||
-rw-r--r-- | tests/vimeo/test_vimeo.c | 258 |
15 files changed, 0 insertions, 1779 deletions
diff --git a/meson.build b/meson.build index c8c7e53..30d38d6 100644 --- a/meson.build +++ b/meson.build @@ -130,7 +130,6 @@ plugins = [ # NAME, REQ_DEPS, OPT_DEPS ['tmdb', [json_glib_dep, libsoup_dep, grilo_net_dep], []], ['tracker', [tracker_sparql_dep], []], ['tracker3', [tracker3_dep], []], - ['vimeo', [grilo_net_dep, libxml_dep, totem_plparser_dep], []], ['youtube', [grilo_net_dep, libxml_dep, libgdata_dep, totem_plparser_dep], []], ] diff --git a/meson_options.txt b/meson_options.txt index 1040067..71f80b8 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -20,5 +20,4 @@ option('enable-thetvdb', type: 'combo', choices: [ 'auto', 'yes', 'no' ], value: option('enable-tmdb', type: 'combo', choices: [ 'auto', 'yes', 'no' ], value: 'auto', description: 'Enable TMDb plugin') option('enable-tracker', type: 'combo', choices: [ 'auto', 'yes', 'no' ], value: 'auto', description: 'Enable Tracker plugin (DEPRECATED)') option('enable-tracker3', type: 'combo', choices: [ 'auto', 'yes', 'no' ], value: 'auto', description: 'Enable Tracker3 plugin') -option('enable-vimeo', type: 'combo', choices: [ 'auto', 'yes', 'no' ], value: 'auto', description: 'Enable Vimeo plugin') option('enable-youtube', type: 'combo', choices: [ 'auto', 'yes', 'no' ], value: 'auto', description: 'Enable YouTube plugin') diff --git a/src/vimeo/channel-vimeo.svg b/src/vimeo/channel-vimeo.svg deleted file mode 100644 index 61d4ed3..0000000 --- a/src/vimeo/channel-vimeo.svg +++ /dev/null @@ -1,108 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="256" - height="256" - id="svg2" - version="1.1" - inkscape:version="0.48.4 r9939" - sodipodi:docname="channel-youtube.svg"> - <defs - id="defs4"> - <clipPath - id="clipPath6193" - clipPathUnits="userSpaceOnUse"> - <path - id="path6195" - d="m 1600,2252.8 5020,0 0,3650 -5020,0 0,-3650 z" /> - </clipPath> - <linearGradient - id="linearGradient6181" - spreadMethod="pad" - gradientTransform="matrix(-3.593e-5,822,822,3.593e-5,411,0)" - gradientUnits="userSpaceOnUse" - y2="0" - x2="1" - y1="0" - x1="0"> - <stop - id="stop6183" - offset="0" - style="stop-opacity:1;stop-color:#c01e25" /> - <stop - id="stop6185" - offset="1" - style="stop-opacity:1;stop-color:#e62426" /> - </linearGradient> - <clipPath - id="clipPath6177" - clipPathUnits="userSpaceOnUse"> - <path - id="path6179" - d="M 8220,0 0,0 l 0,8220 8220,0 0,-8220 m -6620,5902.8 0,-3650 5020,0 0,3650 -5020,0" /> - </clipPath> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#505050" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="1" - inkscape:pageshadow="2" - inkscape:zoom="1" - inkscape:cx="222.0001" - inkscape:cy="70.020428" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="false" - borderlayer="true" - inkscape:showpageshadow="false" - inkscape:window-width="2560" - inkscape:window-height="1374" - inkscape:window-x="0" - inkscape:window-y="27" - inkscape:window-maximized="1" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1" - transform="translate(0,-796.36218)"> - <g - transform="matrix(630.025,0,0,-458.9,-77.5125,1218.8747)" - id="g6197" /> - <g - transform="matrix(1.6065952,0,0,-1.6065952,-27.843516,1073.2062)" - inkscape:label="ink_ext_XXXXXX" - id="g7156"> - <g - transform="scale(0.1,0.1)" - id="g7158"> - <path - id="path7162" - style="fill:#00adef;fill-opacity:1;fill-rule:evenodd;stroke:none" - d="m 694.148,1088.41 c 19.196,15.29 25.106,39.79 13.2,54.76 -11.91,14.95 -37.121,14.69 -56.317,-0.59 -19.195,-15.28 -25.101,-39.79 -13.199,-54.74 11.91,-14.97 37.117,-14.7 56.316,0.57 z M 1544.92,870.051 c -10.19,-18.301 -27.85,-36.461 -48.98,-41.09 -41.3,-9.051 -38.18,51.07 -31.25,76.09 2.98,10.801 7.37,19.769 11.96,27.929 9.19,16.329 22.06,34.258 40.53,40.618 1.25,0.429 2.53,0.808 3.84,1.132 18.81,4.618 32.24,-8.671 38.2,-25.558 9.58,-27.07 -1.04,-55.293 -14.3,-79.121 z m -279.57,97.48 c 11.7,6.016 31.15,8.547 35.04,-11.308 4.4,-22.539 -32.37,-66.274 -83.74,-86.813 -19.59,35.801 16.98,81.207 48.7,98.121 z m 371.13,-26.64 c -2.3,33.468 -16.11,66.109 -46.94,81.039 -28.33,13.71 -82.02,10.09 -110.6,-2.29 -103.09,-48.417 -97.07,-136.249 -100.92,-156.781 -18.33,-12.257 -49.41,-21.3 -77.54,-25.089 -24.74,-3.301 -51.56,-2.04 -66.7,9.699 51.36,20.41 178.4,83.578 136.83,157.351 -40.83,75.24 -271.82,0.85 -234.9,-163.25 -21.17,-13.218 -29.61,-9.41 -34.77,11.02 -0.92,36.351 8.43,64.301 13.68,96.367 1.75,10.703 3.95,22.227 2.85,33.621 -1.9,19.642 -15.98,39.152 -37.64,41.062 -61.69,0 -94.549,-44.984 -110.025,-55.308 -6.16,14.836 15.363,54.728 -47.325,54.728 -47.8,2.97 -79.582,-29.064 -102.621,-49.025 -3.179,11.668 -4.257,25.125 -9.129,35.915 -4.066,9.03 -12.062,18.97 -22.234,20.53 -10.273,1.57 -21.699,-5.48 -29.078,-10.84 -22.656,-16.48 -45.68,-38.202 -61,-58.71 8.32,-15.45 32.086,-4.785 47.32,-2.852 -0.656,-15.156 -1.855,-31 -3.992,-46.187 -3.351,-23.852 -4.008,-44.461 -25.086,-59.301 -12.676,-8.91 -30.437,-16.559 -37.055,2.851 -6.402,18.809 -0.921,40.918 2.739,59.75 4.566,23.454 7.008,47.164 10.371,70.817 1.805,12.668 4.047,22.572 -5.098,33.312 -7.058,8.28 -18.16,13.34 -29.109,12.29 -29.11,-2.77 -42.824,-29.29 -63.281,-42.184 10.378,41.244 -22.629,52.964 -55.684,47.924 -13.125,-2.01 -57.496,-21.58 -72.602,-68.452 26.754,2.051 40.77,-1.914 38.2,-31.347 -1.078,-12.34 -7.297,-25.821 -14.25,-38.77 -8.032,-14.922 -23.086,-44.203 -42.817,-23.101 -17.769,19 -16.41,55.347 -20.472,79.547 -2.282,13.586 -4.672,30.488 -9.125,44.464 -3.829,12.029 -12.61,26.489 -23.375,29.649 -11.555,3.39 -25.825,-1.91 -34.207,-6.85 -26.696,-15.69 -47.032,-38.037 -70.129,-56.443 l 0,-1.707 c 4.566,-4.367 5.797,-11.555 12.547,-12.531 15.898,-2.325 31.039,14.824 41.597,-3.047 6.442,-10.899 8.449,-22.852 12.567,-34.59 5.503,-15.684 9.753,-32.731 14.253,-50.742 7.618,-30.489 16.961,-76.051 43.329,-87.231 13.461,-5.699 33.664,1.922 43.902,7.992 27.742,16.43 49.34,40.2 67.848,64.418 18.347,24.02 36.82,52.121 51.304,80.954 8.883,17.675 14.813,32.617 39.914,29.082 -1.656,-36.774 -13.125,-67.965 -19.957,-99.766 -2.406,-11.207 -5.527,-23.418 -5.699,-34.789 -0.308,-20.328 8.188,-40.25 23.375,-44.469 11.242,-3.101 26.891,-1.93 37.633,-1.133 36.367,2.641 68.277,26.641 88.031,46.403 10.934,-13.2 24.758,-46.993 76.332,-46.993 -23.672,51.84 -8.449,176.137 55.133,170.473 18.625,-7.168 10.246,-38.359 6.273,-55.859 -2.742,-12.114 -27.578,-123.653 68.989,-115.172 0,21.172 -8.403,138.609 54.893,169.762 5.68,2.949 25.54,3.086 26.64,-6.7 4.93,-44.312 -15.51,-84.023 -14.83,-128.843 0.52,-70.707 109.93,-11.329 133.99,2.261 13.81,-10.16 54.6,-50.308 148.23,-29.058 17.6,4.429 33.11,9.097 47.32,15.957 14.93,7.203 28.75,15.109 43.9,19.961 -2.07,-0.668 17.87,-24.551 20.07,-26.231 9.57,-7.371 21.16,-12.187 32.58,-15.859 26.57,-8.5 54.79,-5.391 81.58,0.949 54.05,12.82 90.62,53.563 107.35,105.391 5.39,16.699 7.96,36.468 6.62,55.961" - inkscape:connector-curvature="0" /> - </g> - </g> - </g> -</svg> diff --git a/src/vimeo/grl-vimeo.c b/src/vimeo/grl-vimeo.c deleted file mode 100644 index 12572dc..0000000 --- a/src/vimeo/grl-vimeo.c +++ /dev/null @@ -1,564 +0,0 @@ -/* - * Copyright (C) 2010, 2011 Igalia S.L. - * Copyright (C) 2011 Intel Corporation. - * - * Contact: Iago Toral Quiroga <itoral@igalia.com> - * - * Authors: Joaquim Rocha <jrocha@igalia.com> - Juan A. Suarez Romero <jasuarez@igalia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <grilo.h> -#include <string.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <gio/gio.h> -#include <glib/gi18n-lib.h> - -#include "grl-vimeo.h" -#include "gvimeo.h" - -/* --------- Logging -------- */ - -#define GRL_LOG_DOMAIN_DEFAULT vimeo_log_domain -GRL_LOG_DOMAIN_STATIC(vimeo_log_domain); - -/* --- Plugin information --- */ - -#define SOURCE_ID "grl-vimeo" -#define SOURCE_NAME "Vimeo" -#define SOURCE_DESC _("A source for browsing and searching Vimeo videos") - -#define MAX_ELEMENTS 50 - -typedef struct { - GrlSourceSearchSpec *ss; - GVimeo *vimeo; - GQueue *queue; - gint offset; - gint page; - gboolean get_url; -} SearchData; - -typedef struct { - GrlMedia *media; - SearchData *sd; - gint index; - gboolean computed; -} AddMediaUrlData; - -struct _GrlVimeoSourcePrivate { - GVimeo *vimeo; -}; - -static GrlVimeoSource *grl_vimeo_source_new (void); -static void grl_vimeo_source_finalize (GObject *object); - -gboolean grl_vimeo_plugin_init (GrlRegistry *registry, - GrlPlugin *plugin, - GList *configs); - -static const GList *grl_vimeo_source_supported_keys (GrlSource *source); - -static const GList *grl_vimeo_source_slow_keys (GrlSource *source); - -static void grl_vimeo_source_resolve (GrlSource *source, - GrlSourceResolveSpec *rs); - -static void grl_vimeo_source_search (GrlSource *source, - GrlSourceSearchSpec *ss); - -/* =================== Vimeo Plugin =============== */ - -gboolean -grl_vimeo_plugin_init (GrlRegistry *registry, - GrlPlugin *plugin, - GList *configs) -{ - gchar *vimeo_key; - gchar *vimeo_secret; - gchar *format; - GrlConfig *config; - gint config_count; - gboolean init_result = FALSE; - GrlVimeoSource *source; - - GRL_LOG_DOMAIN_INIT (vimeo_log_domain, "vimeo"); - - GRL_DEBUG ("vimeo_plugin_init"); - - /* Initialize i18n */ - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - - if (!configs) { - GRL_INFO ("Configuration not provided! Plugin not loaded"); - return FALSE; - } - - config_count = g_list_length (configs); - if (config_count > 1) { - GRL_INFO ("Provided %d configs, but will only use one", config_count); - } - - config = GRL_CONFIG (configs->data); - - vimeo_key = grl_config_get_api_key (config); - vimeo_secret = grl_config_get_api_secret (config); - - if (!vimeo_key || !vimeo_secret) { - GRL_INFO ("Required API key or secret configuration not provided." - " Plugin not loaded"); - goto go_out; - } - - source = grl_vimeo_source_new (); - source->priv->vimeo = g_vimeo_new (vimeo_key, vimeo_secret); - - format = grl_config_get_string (config, "format"); - if (format) { - g_object_set (source->priv->vimeo, "quvi-format", format, NULL); - g_free (format); - } - - grl_registry_register_source (registry, - plugin, - GRL_SOURCE (source), - NULL); - init_result = TRUE; - - go_out: - g_clear_pointer (&vimeo_key, g_free); - g_clear_pointer (&vimeo_secret, g_free); - - return init_result; -} - -GRL_PLUGIN_DEFINE (GRL_MAJOR, - GRL_MINOR, - VIMEO_PLUGIN_ID, - "Vimeo", - "A plugin for searching Vimeo videos", - "Igalia S.L.", - VERSION, - "LGPL", - "http://www.igalia.com", - grl_vimeo_plugin_init, - NULL, - NULL); - -/* ================== Vimeo GObject ================ */ - -G_DEFINE_TYPE_WITH_PRIVATE (GrlVimeoSource, grl_vimeo_source, GRL_TYPE_SOURCE) - -static GrlVimeoSource * -grl_vimeo_source_new (void) -{ - GIcon *icon; - GFile *file; - GrlVimeoSource *source; - const char *tags[] = { - "net:internet", - NULL - }; - - GRL_DEBUG ("grl_vimeo_source_new"); - - file = g_file_new_for_uri ("resource:///org/gnome/grilo/plugins/vimeo/channel-vimeo.svg"); - icon = g_file_icon_new (file); - g_object_unref (file); - - source = g_object_new (GRL_VIMEO_SOURCE_TYPE, - "source-id", SOURCE_ID, - "source-name", SOURCE_NAME, - "source-desc", SOURCE_DESC, - "supported-media", GRL_SUPPORTED_MEDIA_VIDEO, - "source-icon", icon, - "source-tags", tags, - NULL); - g_object_unref (icon); - - return source; -} - -static void -grl_vimeo_source_class_init (GrlVimeoSourceClass * klass) -{ - GrlSourceClass *source_class = GRL_SOURCE_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - source_class->supported_keys = grl_vimeo_source_supported_keys; - source_class->slow_keys = grl_vimeo_source_slow_keys; - source_class->resolve = grl_vimeo_source_resolve; - source_class->search = grl_vimeo_source_search; - - object_class->finalize = grl_vimeo_source_finalize; -} - -static void -grl_vimeo_source_init (GrlVimeoSource *source) -{ - source->priv = grl_vimeo_source_get_instance_private (source); - - grl_source_set_auto_split_threshold (GRL_SOURCE (source), MAX_ELEMENTS); -} - -static void -grl_vimeo_source_finalize (GObject *object) -{ - GrlVimeoSource *source = GRL_VIMEO_SOURCE (object); - - g_clear_object (&source->priv->vimeo); - - G_OBJECT_CLASS (grl_vimeo_source_parent_class)->finalize (object); -} - -/* ======================= Utilities ==================== */ - -static gint -str_to_gint (gchar *str) -{ - gint number; - - errno = 0; - number = (gint) g_ascii_strtod (str, NULL); - if (errno == 0) - { - return number; - } - return 0; -} - -static GDateTime * -parse_date (const gchar *date) -{ - /* code duplicated from the flickr plugin until we find a better place for - * it.*/ - guint year, month, day, hours, minutes; - gdouble seconds; - - sscanf (date, "%u-%u-%u %u:%u:%lf", - &year, &month, &day, &hours, &minutes, &seconds); - - return g_date_time_new_utc (year, month, day, hours, minutes, seconds); -} - -static void -update_media (GrlMedia *media, GHashTable *video) -{ - gchar *str; - - str = g_hash_table_lookup (video, VIMEO_VIDEO_ID); - if (str) - { - char *external_url; - - grl_media_set_id (media, str); - external_url = g_strdup_printf ("https://vimeo.com/%s", str); - grl_media_set_external_url (media, external_url); - g_free (external_url); - } - - str = g_hash_table_lookup (video, VIMEO_VIDEO_TITLE); - if (str) - { - grl_media_set_title (media, str); - } - - str = g_hash_table_lookup (video, VIMEO_VIDEO_DESCRIPTION); - if (str) - { - grl_media_set_description (media, str); - } - - str = g_hash_table_lookup (video, VIMEO_VIDEO_DURATION); - if (str) - { - grl_media_set_duration (media, str_to_gint (str)); - } - - str = g_hash_table_lookup (video, VIMEO_VIDEO_OWNER_NAME); - if (str) - { - grl_media_set_author (media, str); - } - - str = g_hash_table_lookup (video, VIMEO_VIDEO_UPLOAD_DATE); - if (str) - { - GDateTime *date = parse_date (str); - if (date) { - grl_media_set_publication_date (media, date); - g_date_time_unref (date); - } - } - - str = g_hash_table_lookup (video, VIMEO_VIDEO_THUMBNAIL); - if (str) - { - grl_media_set_thumbnail (media, str); - } - - str = g_hash_table_lookup (video, VIMEO_VIDEO_WIDTH); - if (str) - { - grl_media_set_width (media, str_to_gint (str)); - } - - str = g_hash_table_lookup (video, VIMEO_VIDEO_HEIGHT); - if (str) - { - grl_media_set_height (media, str_to_gint (str)); - } -} - -static void -add_url_media_cb (const gchar *url, gpointer user_data) -{ - AddMediaUrlData *amud = (AddMediaUrlData *) user_data; - SearchData *sd = amud->sd; - - if (url) { - grl_media_set_url (amud->media, url); - } - - amud->computed = TRUE; - - /* Try to send in order all the processed elements */ - while ((amud = g_queue_peek_tail (sd->queue)) && - amud != NULL && - amud->computed) { - sd->ss->callback (sd->ss->source, - sd->ss->operation_id, - amud->media, - amud->index, - sd->ss->user_data, - NULL); - g_queue_pop_tail (sd->queue); - g_slice_free (AddMediaUrlData, amud); - } - - /* If there are still elements not processed let's wait for them */ - if (amud == NULL) { - g_queue_free (sd->queue); - g_slice_free (SearchData, sd); - } -} - -static void -search_cb (GVimeo *vimeo, GList *video_list, gpointer user_data) -{ - GrlMedia *media = NULL; - AddMediaUrlData *amud; - SearchData *sd = (SearchData *) user_data; - gint count = grl_operation_options_get_count (sd->ss->options); - gint id; - gchar *media_type; - gint video_list_size; - - /* Go to offset element */ - video_list = g_list_nth (video_list, sd->offset); - - /* No more elements can be sent */ - if (!video_list) { - sd->ss->callback (sd->ss->source, - sd->ss->operation_id, - NULL, - 0, - sd->ss->user_data, - NULL); - g_slice_free (SearchData, sd); - return; - } - - video_list_size = g_list_length (video_list); - if (count > video_list_size) { - count = video_list_size; - } - - if (sd->get_url) { - sd->queue = g_queue_new (); - } - - while (video_list && count) - { - media_type = g_hash_table_lookup (video_list->data, "title"); - if (media_type) { - media = grl_media_video_new (); - } else { - media = NULL; - } - - if (media) - { - update_media (media, video_list->data); - if (sd->get_url) { - amud = g_slice_new (AddMediaUrlData); - amud->computed = FALSE; - amud->media = media; - amud->index = --count; - amud->sd = sd; - g_queue_push_head (sd->queue, amud); - id = (gint) g_ascii_strtod (grl_media_get_id (media), NULL); - g_vimeo_video_get_play_url (sd->vimeo, - id, - add_url_media_cb, - amud); - } else { - sd->ss->callback (sd->ss->source, - sd->ss->operation_id, - media, - --count, - sd->ss->user_data, - NULL); - } - } - video_list = g_list_next (video_list); - } - - if (!sd->get_url) { - g_slice_free (SearchData, sd); - } -} - -static void -video_get_play_url_cb (const gchar *url, gpointer user_data) -{ - GrlSourceResolveSpec *rs = (GrlSourceResolveSpec *) user_data; - - if (url) { - grl_media_set_url (rs->media, url); - } - - rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL); -} - -/* ================== API Implementation ================ */ - -static const GList * -grl_vimeo_source_supported_keys (GrlSource *source) -{ - static GList *keys = NULL; - if (!keys) { - keys = grl_metadata_key_list_new (GRL_METADATA_KEY_ID, - GRL_METADATA_KEY_TITLE, - GRL_METADATA_KEY_DESCRIPTION, - GRL_METADATA_KEY_URL, - GRL_METADATA_KEY_AUTHOR, - GRL_METADATA_KEY_PUBLICATION_DATE, - GRL_METADATA_KEY_THUMBNAIL, - GRL_METADATA_KEY_DURATION, - GRL_METADATA_KEY_WIDTH, - GRL_METADATA_KEY_HEIGHT, - GRL_METADATA_KEY_EXTERNAL_URL, - GRL_METADATA_KEY_INVALID); - } - return keys; -} - -static const GList * -grl_vimeo_source_slow_keys (GrlSource *source) -{ - static GList *keys = NULL; - if (!keys) { - keys = grl_metadata_key_list_new (GRL_METADATA_KEY_URL, - GRL_METADATA_KEY_INVALID); - } - return keys; -} - -static void -grl_vimeo_source_resolve (GrlSource *source, - GrlSourceResolveSpec *rs) -{ - gint id; - const gchar *id_str; - - if (!rs->media || (id_str = grl_media_get_id (rs->media)) == NULL) { - goto send_unchanged; - } - - /* As all the keys are added always, except URL, the only case is missing URL */ - if (g_list_find (rs->keys, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_URL)) != NULL && - grl_media_get_url (rs->media) == NULL) { - errno = 0; - id = (gint) g_ascii_strtod (id_str, NULL); - if (errno != 0) { - goto send_unchanged; - } - - g_vimeo_video_get_play_url (GRL_VIMEO_SOURCE (source)->priv->vimeo, - id, - video_get_play_url_cb, - rs); - } else { - goto send_unchanged; - } - - return; - - send_unchanged: - rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL); -} - -static void -grl_vimeo_source_search (GrlSource *source, - GrlSourceSearchSpec *ss) -{ - SearchData *sd; - GError *error; - gint per_page; - GVimeo *vimeo = GRL_VIMEO_SOURCE (source)->priv->vimeo; - guint skip = grl_operation_options_get_skip (ss->options); - gint count = grl_operation_options_get_count (ss->options); - - if (!ss->text) { - /* Vimeo does not support searching all */ - error = g_error_new (GRL_CORE_ERROR, - GRL_CORE_ERROR_SEARCH_NULL_UNSUPPORTED, - _("Failed to search: %s"), - _("non-NULL search text is required")); - ss->callback (ss->source, ss->operation_id, NULL, 0, ss->user_data, error); - g_error_free (error); - return; - } - - sd = g_slice_new0 (SearchData); - sd->vimeo = vimeo; - sd->get_url = (g_list_find (ss->keys, - GRLKEYID_TO_POINTER (GRL_METADATA_KEY_URL)) != NULL); - - /* Compute items per page and page offset */ - grl_paging_translate (skip, - count, - MAX_ELEMENTS, - (guint *) &per_page, - (guint *) &(sd->page), - (guint *) &(sd->offset)); - - g_vimeo_set_per_page (vimeo, per_page); - sd->ss = ss; - - g_vimeo_videos_search (vimeo, ss->text, sd->page, search_cb, sd); -} diff --git a/src/vimeo/grl-vimeo.h b/src/vimeo/grl-vimeo.h deleted file mode 100644 index b0c49bb..0000000 --- a/src/vimeo/grl-vimeo.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2010 Igalia S.L. - * - * Contact: Iago Toral Quiroga <itoral@igalia.com> - * - * Authors: Joaquim Rocha <jrocha@igalia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#ifndef _GRL_VIMEO_SOURCE_H_ -#define _GRL_VIMEO_SOURCE_H_ - -#include <grilo.h> - -#define GRL_VIMEO_SOURCE_TYPE \ - (grl_vimeo_source_get_type ()) - -#define GRL_VIMEO_SOURCE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - GRL_VIMEO_SOURCE_TYPE, \ - GrlVimeoSource)) - -#define GRL_IS_VIMEO_SOURCE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - GRL_VIMEO_SOURCE_TYPE)) - -#define GRL_VIMEO_SOURCE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), \ - GRL_VIMEO_SOURCE_TYPE, \ - GrlVimeoSourceClass)) - -#define GRL_IS_VIMEO_SOURCE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), \ - GRL_VIMEO_SOURCE_TYPE)) - -#define GRL_VIMEO_SOURCE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - GRL_VIMEO_SOURCE_TYPE, \ - GrlVimeoSourceClass)) - -typedef struct _GrlVimeoSource GrlVimeoSource; -typedef struct _GrlVimeoSourcePrivate GrlVimeoSourcePrivate; - -struct _GrlVimeoSource { - - GrlSource parent; - - /*< private >*/ - GrlVimeoSourcePrivate *priv; -}; - -typedef struct _GrlVimeoSourceClass GrlVimeoSourceClass; - -struct _GrlVimeoSourceClass { - - GrlSourceClass parent_class; - -}; - -GType grl_vimeo_source_get_type (void); - -#endif /* _GRL_VIMEO_SOURCE_H_ */ diff --git a/src/vimeo/gvimeo.c b/src/vimeo/gvimeo.c deleted file mode 100644 index 04e974f..0000000 --- a/src/vimeo/gvimeo.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright (C) 2010, 2011 Igalia S.L. - * - * Contact: Iago Toral Quiroga <itoral@igalia.com> - * - * Authors: Joaquim Rocha <jrocha@igalia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include "gvimeo.h" - -#include <glib.h> -#include <string.h> -#include <net/grl-net.h> -#include <libxml/parser.h> -#include <libxml/xpath.h> -#include <totem-pl-parser.h> - -#define G_VIMEO_GET_PRIVATE(object) \ - (G_TYPE_INSTANCE_GET_PRIVATE((object), \ - G_VIMEO_TYPE, \ - GVimeoPrivate)) - -#define PLUGIN_USER_AGENT "Grilo Vimeo Plugin" - -#define VIMEO_HOST "https://vimeo.com" -#define VIMEO_ENDPOINT VIMEO_HOST "/api/rest/v2" -#define VIMEO_VIDEO_LOAD_URL VIMEO_HOST "/moogaloop/load/clip:" -#define VIMEO_VIDEO_PLAY_URL VIMEO_HOST "/moogaloop/play/clip:" - -#define VIMEO_VIDEO_SEARCH_METHOD "vimeo.videos.search" -#define VIMEO_API_OAUTH_SIGN_METHOD "HMAC-SHA1" -#define VIMEO_API_OAUTH_SIGNATURE_PARAM "&oauth_signature=%s" - -#define VIMEO_VIDEO_SEARCH \ - "full_response=yes" \ - "&method=%s" \ - "&oauth_consumer_key=%s" \ - "&oauth_nonce=%s" \ - "&oauth_signature_method=" VIMEO_API_OAUTH_SIGN_METHOD \ - "&oauth_timestamp=%s" \ - "&oauth_token=" \ - "&page=%d" \ - "&per_page=%d" \ - "&query=%s" - -typedef struct { - GVimeo *vimeo; - GVimeoVideoSearchCb search_cb; - gpointer user_data; -} GVimeoVideoSearchData; - -typedef struct { - GVimeo *vimeo; - gchar *vimeo_url; - GVimeoURLCb callback; - gpointer user_data; -} GVimeoVideoURLData; - -struct _GVimeoPrivate { - gchar *api_key; - gchar *auth_token; - gchar *auth_secret; - gint per_page; - GrlNetWc *wc; -}; - -enum InfoType {SIMPLE, EXTENDED}; - -typedef struct { - enum InfoType type; - gchar *name; -} VideoInfo; - -static VideoInfo video_info[] = {{SIMPLE, VIMEO_VIDEO_TITLE}, - {SIMPLE, VIMEO_VIDEO_DESCRIPTION}, - {SIMPLE, VIMEO_VIDEO_UPLOAD_DATE}, - {SIMPLE, VIMEO_VIDEO_WIDTH}, - {SIMPLE, VIMEO_VIDEO_HEIGHT}, - {SIMPLE, VIMEO_VIDEO_OWNER}, - {SIMPLE, VIMEO_VIDEO_URL}, - {SIMPLE, VIMEO_VIDEO_THUMBNAIL}, - {SIMPLE, VIMEO_VIDEO_DURATION}, - {EXTENDED, VIMEO_VIDEO_OWNER}}; - -static void g_vimeo_finalize (GObject *object); -static void g_vimeo_dispose (GObject *object); -static gchar * encode_uri (const gchar *uri); - -/* -------------------- GOBJECT -------------------- */ - -G_DEFINE_TYPE_WITH_PRIVATE (GVimeo, g_vimeo, G_TYPE_OBJECT); - -static void -g_vimeo_class_init (GVimeoClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - gobject_class->finalize = g_vimeo_finalize; - gobject_class->dispose = g_vimeo_dispose; -} - -static void -entry_parsed_cb (TotemPlParser *parser, - const char *uri, - GHashTable *metadata, - char **new_url) -{ - *new_url = g_strdup (uri); -} - -static void -g_vimeo_init (GVimeo *vimeo) -{ - vimeo->priv = g_vimeo_get_instance_private (vimeo); - vimeo->priv->per_page = 50; - vimeo->priv->wc = grl_net_wc_new (); - g_object_set (vimeo->priv->wc, "user-agent", PLUGIN_USER_AGENT, NULL); -} - -static void -g_vimeo_dispose (GObject *object) -{ - GVimeo *vimeo = G_VIMEO (object); - - g_clear_object (&vimeo->priv->wc); - - G_OBJECT_CLASS (g_vimeo_parent_class)->dispose (object); -} - -static void -g_vimeo_finalize (GObject *object) -{ - GVimeo *vimeo = G_VIMEO (object); - g_free (vimeo->priv->api_key); - g_free (vimeo->priv->auth_secret); - - G_OBJECT_CLASS (g_vimeo_parent_class)->finalize (object); -} - -GVimeo * -g_vimeo_new (const gchar *api_key, const gchar *auth_secret) -{ - GVimeo *vimeo = g_object_new (G_VIMEO_TYPE, NULL); - vimeo->priv->api_key = g_strdup (api_key); - vimeo->priv->auth_secret = g_strdup (auth_secret); - - return vimeo; -} - -/* -------------------- PRIVATE API -------------------- */ - -static gchar * -get_timestamp (void) -{ - time_t t = time (NULL); - return g_strdup_printf ("%d", (gint) t); -} - -static gchar * -get_nonce (void) -{ - gchar *timestamp = get_timestamp(); - guint rnd_number = g_random_int (); - gchar *rnd_str = g_strdup_printf ("%d_%s", rnd_number, timestamp); - gchar *nonce = g_compute_checksum_for_string (G_CHECKSUM_MD5, rnd_str, -1); - g_free (timestamp); - g_free (rnd_str); - - return nonce; -} - -static gchar * -get_videos_search_params (GVimeo *vimeo, const gchar *text, gint page) { - gchar *encoded_text = encode_uri (text); - gchar *timestamp = get_timestamp (); - gchar *nonce = get_nonce (); - gchar *params = g_strdup_printf (VIMEO_VIDEO_SEARCH, - VIMEO_VIDEO_SEARCH_METHOD, - vimeo->priv->api_key, - nonce, - timestamp, - page, - vimeo->priv->per_page, - encoded_text); - g_free (timestamp); - g_free (nonce); - g_free (encoded_text); - - return params; -} - -/* From gchecksum.c in glib */ -#define SHA1_DIGEST_LEN 20 - -static gchar * -sign_string (gchar *message, gchar *key) -{ - GHmac *hmac; - guint8 buffer[SHA1_DIGEST_LEN]; - gsize buffer_len = SHA1_DIGEST_LEN; - - hmac = g_hmac_new (G_CHECKSUM_SHA1, (guchar *) key, strlen (key)); - g_hmac_update (hmac, (guchar *) message, strlen (message)); - g_hmac_get_digest (hmac, buffer, &buffer_len); - g_hmac_unref (hmac); - - return g_base64_encode (buffer, buffer_len); -} - -static gboolean -result_is_correct (xmlNodePtr node) -{ - gboolean correct = FALSE; - xmlChar *stat; - - if (xmlStrcmp (node->name, (const xmlChar *) "rsp") == 0) - { - stat = xmlGetProp (node, (const xmlChar *) "stat"); - if (stat && xmlStrcmp (stat, (const xmlChar *) "ok") == 0) - { - correct = TRUE; - xmlFree (stat); - } - } - - return correct; -} - -static void -add_node (xmlNodePtr node, GHashTable *video) -{ - xmlAttrPtr attr; - - for (attr = node->properties; attr != NULL; attr = attr->next) - { - g_hash_table_insert (video, - g_strconcat ((const gchar *) node->name, - "_", - (const gchar *) attr->name, - NULL), - (gchar *) xmlGetProp (node, attr->name)); - } -} - -static xmlNodePtr -xpath_get_node (xmlXPathContextPtr context, gchar *xpath_expr) -{ - xmlNodePtr node = NULL; - xmlXPathObjectPtr xpath_obj; - xpath_obj = xmlXPathEvalExpression ((xmlChar *) xpath_expr, context); - - if (xpath_obj && xpath_obj->nodesetval->nodeTab) - { - node = xpath_obj->nodesetval->nodeTab[0]; - } - xmlXPathFreeObject (xpath_obj); - - return node; -} - -static GHashTable * -get_video (xmlNodePtr node) -{ - gint i; - gint array_length; - xmlXPathContextPtr context; - gchar *video_id; - GHashTable *video = g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - g_free); - - /* Adds the video node's properties */ - add_node (node, video); - - context = xmlXPathNewContext (node->doc); - video_id = (gchar *) xmlGetProp (node, (xmlChar *) "id"); - - array_length = G_N_ELEMENTS (video_info); - for (i = 0; i < array_length; i++) - { - /* Look for the wanted information only under the current video */ - gchar *xpath_name = g_strdup_printf ("//video[@id=%s]//%s", - video_id, - video_info[i].name); - xmlNodePtr info_node = xpath_get_node (context, xpath_name); - if (info_node) - { - if (video_info[i].type == EXTENDED) { - add_node (info_node, video); - } - else - { - g_hash_table_insert (video, - g_strdup ((const gchar *) info_node->name), - (gchar *) xmlNodeGetContent (info_node)); - } - } - g_free (xpath_name); - } - g_free (video_id); - - xmlXPathFreeContext (context); - - return video; -} - - -static void -process_video_search_result (const gchar *xml_result, gpointer user_data) -{ - xmlDocPtr doc; - xmlNodePtr node; - GList *video_list = NULL; - GVimeoVideoSearchData *data = (GVimeoVideoSearchData *) user_data; - - doc = xmlReadMemory (xml_result, - xmlStrlen ((xmlChar *) xml_result), - NULL, - NULL, - XML_PARSE_RECOVER | XML_PARSE_NOBLANKS); - node = xmlDocGetRootElement (doc); - - /* Check result is ok */ - if (!node || !result_is_correct (node)) - { - data->search_cb (data->vimeo, NULL, data->user_data); - } - else - { - node = node->xmlChildrenNode; - - /* Now we're at "video pages" node */ - node = node->xmlChildrenNode; - while (node) - { - video_list = g_list_prepend (video_list, get_video (node)); - node = node->next; - } - - video_list = g_list_reverse (video_list); - data->search_cb (data->vimeo, video_list, data->user_data); - g_list_free_full (video_list, (GDestroyNotify) g_hash_table_unref); - } - g_slice_free (GVimeoVideoSearchData, data); - xmlFreeDoc (doc); -} - -static void -search_videos_complete_cb (GObject *source_object, - GAsyncResult *res, - gpointer data) -{ - gchar *content = NULL; - - GVimeoVideoSearchCb *search_data = (GVimeoVideoSearchCb *) data; - grl_net_wc_request_finish (GRL_NET_WC (source_object), - res, - &content, - NULL, - NULL); - - process_video_search_result (content, search_data); -} - -static gboolean -get_video_play_url_cb (GVimeoVideoURLData *url_data) -{ - gchar *url = NULL; - TotemPlParser *parser; - TotemPlParserResult res; - - parser = totem_pl_parser_new (); - g_signal_connect (parser, "entry-parsed", - G_CALLBACK (entry_parsed_cb), &url); - res = totem_pl_parser_parse (parser, - url_data->vimeo_url, - FALSE); - if (res != TOTEM_PL_PARSER_RESULT_SUCCESS) - url_data->callback (NULL, url_data->user_data); - else - url_data->callback (url, url_data->user_data); - g_clear_object (&parser); - - g_object_unref (url_data->vimeo); - g_free (url_data->vimeo_url); - g_slice_free (GVimeoVideoURLData, url_data); - - return FALSE; -} - -static gchar * -encode_uri (const gchar *uri) -{ - return g_uri_escape_string (uri, NULL, TRUE); -} - -static gchar * -build_request (GVimeo *vimeo, const gchar *query, gint page) -{ - gchar *params; - gchar *endpoint_encoded; - gchar *key; - gchar *escaped_str; - gchar *tmp_str; - gchar *signature; - - g_return_val_if_fail (G_IS_VIMEO (vimeo), NULL); - - params = get_videos_search_params (vimeo, query, page); - endpoint_encoded = encode_uri (VIMEO_ENDPOINT); - key = g_strdup_printf ("%s&", vimeo->priv->auth_secret); - escaped_str = encode_uri (params); - tmp_str = g_strdup_printf ("GET&%s&%s", endpoint_encoded, escaped_str); - signature = sign_string (tmp_str, key); - g_free (escaped_str); - g_free (tmp_str); - escaped_str = encode_uri (signature); - tmp_str = g_strdup_printf ("%s?%s" VIMEO_API_OAUTH_SIGNATURE_PARAM, - VIMEO_ENDPOINT, - params, - escaped_str); - - g_free (endpoint_encoded); - g_free (params); - g_free (key); - g_free (escaped_str); - g_free (signature); - - return tmp_str; -} - -/* -------------------- PUBLIC API -------------------- */ - -void -g_vimeo_set_per_page (GVimeo *vimeo, gint per_page) -{ - g_return_if_fail (G_IS_VIMEO (vimeo)); - vimeo->priv->per_page = per_page; -} - -void -g_vimeo_videos_search (GVimeo *vimeo, - const gchar *text, - gint page, - GVimeoVideoSearchCb callback, - gpointer user_data) -{ - GVimeoVideoSearchData *search_data; - gchar *request; - - g_return_if_fail (G_IS_VIMEO (vimeo)); - - request = build_request (vimeo, text, page); - search_data = g_slice_new (GVimeoVideoSearchData); - search_data->vimeo = vimeo; - search_data->search_cb = callback; - search_data->user_data = user_data; - - grl_net_wc_request_async (vimeo->priv->wc, - request, - NULL, - search_videos_complete_cb, - search_data); - g_free (request); -} - -void -g_vimeo_video_get_play_url (GVimeo *vimeo, - gint id, - GVimeoURLCb callback, - gpointer user_data) -{ - GVimeoVideoURLData *data; - guint tag_id; - - data = g_slice_new (GVimeoVideoURLData); - data->vimeo = g_object_ref (vimeo); - data->vimeo_url = g_strdup_printf (VIMEO_HOST "/%d", id); - data->callback = callback; - data->user_data = user_data; - - tag_id = g_idle_add ((GSourceFunc) get_video_play_url_cb, data); - g_source_set_name_by_id (tag_id, "[vimeo] get_video_play_url_cb"); -} diff --git a/src/vimeo/gvimeo.h b/src/vimeo/gvimeo.h deleted file mode 100644 index 3fd7ad2..0000000 --- a/src/vimeo/gvimeo.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2010 Igalia S.L. - * - * Contact: Iago Toral Quiroga <itoral@igalia.com> - * - * Authors: Joaquim Rocha <jrocha@igalia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#ifndef _G_VIMEO_H_ -#define _G_VIMEO_H_ - -#include <glib-object.h> - -#define G_VIMEO_TYPE \ - (g_vimeo_get_type ()) - -#define G_VIMEO(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - G_VIMEO_TYPE, \ - GVimeo)) - -#define G_IS_VIMEO(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - G_VIMEO_TYPE)) - -#define G_VIMEO_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), \ - G_VIMEO_TYPE, \ - GVimeoClass)) - -#define G_IS_VIMEO_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), \ - G_VIMEO_TYPE)) - -#define G_VIMEO_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - G_VIMEO_TYPE, \ - GVimeoClass)) - -#define VIMEO_VIDEO "video" -#define VIMEO_VIDEO_ID VIMEO_VIDEO "_id" -#define VIMEO_VIDEO_TITLE "title" -#define VIMEO_VIDEO_DESCRIPTION "description" -#define VIMEO_VIDEO_URL "url" -#define VIMEO_VIDEO_UPLOAD_DATE "upload_date" -#define VIMEO_VIDEO_WIDTH "width" -#define VIMEO_VIDEO_HEIGHT "height" -#define VIMEO_VIDEO_DURATION "duration" -#define VIMEO_VIDEO_OWNER "owner" -#define VIMEO_VIDEO_THUMBNAIL "thumbnail" - -#define VIMEO_VIDEO_OWNER_NAME VIMEO_VIDEO_OWNER "_realname" - -typedef struct _GVimeo GVimeo; -typedef struct _GVimeoPrivate GVimeoPrivate; - -struct _GVimeo { - - GObject parent; - - /*< private >*/ - GVimeoPrivate *priv; -}; - -typedef struct _GVimeoClass GVimeoClass; - -struct _GVimeoClass { - - GObjectClass parent_class; - -}; - -typedef void (*GVimeoVideoSearchCb) (GVimeo *vimeo, - GList *videolist, - gpointer user_data); - -typedef void (*GVimeoURLCb) (const gchar *url, gpointer user_data); - -GType g_vimeo_get_type (void); - -GVimeo *g_vimeo_new (const gchar *api_key, const gchar *auth_secret); - -void g_vimeo_video_get_play_url (GVimeo *vimeo, - gint id, - GVimeoURLCb callback, - gpointer user_data); - -void g_vimeo_set_per_page (GVimeo *vimeo, gint per_page); - -void g_vimeo_videos_search (GVimeo *vimeo, - const gchar *text, - gint page, - GVimeoVideoSearchCb callback, - gpointer user_data); - -#endif /* _G_VIMEO_H_ */ diff --git a/src/vimeo/meson.build b/src/vimeo/meson.build deleted file mode 100644 index 70a849b..0000000 --- a/src/vimeo/meson.build +++ /dev/null @@ -1,30 +0,0 @@ -# -# meson.build -# -# Author: Juan A. Suarez Romero <jasuarez@igalia.com> -# -# Copyright (C) 2016 Igalia S.L. All rights reserved. - -vimeo_resources = gnome.compile_resources('vimeoresources', - 'vimeo.gresource.xml', - c_name: '_grl_vimeo') - -vimeo_sources = [ - 'grl-vimeo.c', - 'grl-vimeo.h', - 'gvimeo.c', - 'gvimeo.h', -] - -configure_file(output: 'config.h', - configuration: cdata) - -shared_library('grlvimeo', - sources: vimeo_sources + vimeo_resources, - install: true, - install_dir: pluginsdir, - dependencies: must_deps + plugins[vimeo_idx][REQ_DEPS] + plugins[vimeo_idx][OPT_DEPS], - c_args: [ - '-DG_LOG_DOMAIN="GrlVimeo"', - '-DHAVE_CONFIG_H', - ]) diff --git a/src/vimeo/vimeo.gresource.xml b/src/vimeo/vimeo.gresource.xml deleted file mode 100644 index aab7791..0000000 --- a/src/vimeo/vimeo.gresource.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<gresources> - <gresource prefix="/org/gnome/grilo/plugins/vimeo"> - <file compressed="false">channel-vimeo.svg</file> - </gresource> -</gresources> diff --git a/tests/meson.build b/tests/meson.build index 434d951..97e196d 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -11,7 +11,6 @@ test_plugins = [ 'lua-factory', 'thetvdb', 'tmdb', - 'vimeo', ] test_lua_sources = [ diff --git a/tests/vimeo/data/empty.data b/tests/vimeo/data/empty.data deleted file mode 100644 index 75bc8d2..0000000 --- a/tests/vimeo/data/empty.data +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<rsp generated_in="0.0117" stat="ok"> - <videos on_this_page="0" page="1" perpage="50" total="0"></videos> -</rsp> diff --git a/tests/vimeo/data/network-data.ini b/tests/vimeo/data/network-data.ini deleted file mode 100644 index 0fffc9b..0000000 --- a/tests/vimeo/data/network-data.ini +++ /dev/null @@ -1,9 +0,0 @@ -[default] -version=1 -ignored-parameters=oauth_nonce;oauth_timestamp;oauth_signature_method;oauth_signature - -[https://vimeo.com/api/rest/v2?full_response=yes&method=vimeo.videos.search&oauth_consumer_key=TEST_VIMEO_KEY&oauth_token=&page=1&per_page=2&query=gnome] -data=results.data - -[https://vimeo.com/api/rest/v2?full_response=yes&method=vimeo.videos.search&oauth_consumer_key=TEST_VIMEO_KEY&oauth_token=&page=1&per_page=2&query=invalidfoo] -data=empty.data diff --git a/tests/vimeo/data/results.data b/tests/vimeo/data/results.data deleted file mode 100644 index dee3bd4..0000000 --- a/tests/vimeo/data/results.data +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<rsp generated_in="0.0573" stat="ok"> - <videos on_this_page="2" page="1" perpage="2" total="605"> - <video allow_adds="1" embed_privacy="anywhere" id="31110838" is_hd="1" is_transcoding="0" license="0" privacy="anybody"> - <title>Mound by Allison Schulnik</title> - <description>Please allow 1 minute to load before viewing. Credits: Film by Allison Schulnik Cinematography by Helder K. Sun. "It's Raining Today" written by Noel Scott Engel 4:23 min Copyright Allison Schulnik 2011 allisonschulnik.com</description> - <upload_date>2011-10-25 17:28:37</upload_date> - <modified_date>2013-08-23 06:17:32</modified_date> - <number_of_likes>3566</number_of_likes> - <number_of_plays>217134</number_of_plays> - <number_of_comments>139</number_of_comments> - <width>1280</width> - <height>720</height> - <duration>263</duration> - <owner display_name="garaco taco" id="9030794" is_plus="0" is_pro="0" is_staff="0" profileurl="http://vimeo.com/user9030794" realname="garaco taco" username="user9030794" videosurl="http://vimeo.com/user9030794/videos"> - <portraits> - <portrait height="30" width="30">http://b.vimeocdn.com/ps/270/881/2708811_30.jpg</portrait> - <portrait height="75" width="75">http://b.vimeocdn.com/ps/270/881/2708811_75.jpg</portrait> - <portrait height="100" width="100">http://b.vimeocdn.com/ps/270/881/2708811_100.jpg</portrait> - <portrait height="300" width="300">http://b.vimeocdn.com/ps/270/881/2708811_300.jpg</portrait> - </portraits> - </owner> - <tags> - <tag author="9030794" id="68583916" normalized="allison" url="http://vimeo.com/tag:allison">allison</tag> - <tag author="9030794" id="68583917" normalized="schulnik" url="http://vimeo.com/tag:schulnik">schulnik</tag> - <tag author="9030794" id="68583918" normalized="scott" url="http://vimeo.com/tag:scott">scott</tag> - <tag author="9030794" id="68583919" normalized="walker" url="http://vimeo.com/tag:walker">walker</tag> - <tag author="9030794" id="68583920" normalized="claymation" url="http://vimeo.com/tag:claymation">claymation</tag> - <tag author="9030794" id="68583921" normalized="video" url="http://vimeo.com/tag:video">video</tag> - <tag author="9030794" id="68583922" normalized="stop-motion" url="http://vimeo.com/tag:stop-motion">stop-motion</tag> - <tag author="9030794" id="68583923" normalized="experimental" url="http://vimeo.com/tag:experimental">experimental</tag> - <tag author="9030794" id="68583924" normalized="animation" url="http://vimeo.com/tag:animation">animation</tag> - <tag author="9030794" id="68583925" normalized="itapostrophesrainingtoday" url="http://vimeo.com/tag:It%26%23039%3Bs+Raining+Today">It's Raining Today</tag> - <tag author="9030794" id="68583926" normalized="calarts" url="http://vimeo.com/tag:CalArts">CalArts</tag> - <tag author="9030794" id="68583927" normalized="art" url="http://vimeo.com/tag:art">art</tag> - <tag author="9030794" id="68583928" normalized="artist" url="http://vimeo.com/tag:artist">artist</tag> - <tag author="9030794" id="68583929" normalized="clown" url="http://vimeo.com/tag:clown">clown</tag> - <tag author="9030794" id="68583930" normalized="hobo" url="http://vimeo.com/tag:hobo">hobo</tag> - <tag author="9030794" id="68583931" normalized="gnome" url="http://vimeo.com/tag:gnome">gnome</tag> - </tags> - <cast> - <member display_name="garaco taco" id="9030794" role="" username="user9030794"/> - </cast> - <urls> - <url type="video">http://vimeo.com/31110838</url> - <url type="mobile">http://vimeo.com/m/31110838</url> - </urls> - <thumbnails> - <thumbnail height="75" width="100">http://b.vimeocdn.com/ts/209/404/209404005_100.jpg</thumbnail> - <thumbnail height="150" width="200">http://b.vimeocdn.com/ts/209/404/209404005_200.jpg</thumbnail> - <thumbnail height="360" width="640">http://b.vimeocdn.com/ts/209/404/209404005_640.jpg</thumbnail> - </thumbnails> - </video> - <video allow_adds="1" embed_privacy="anywhere" id="13797705" is_hd="0" is_transcoding="0" license="by-sa" privacy="anybody"> - <title>Shell Yes! motion design mockup</title> - <description></description> - <upload_date>2010-08-01 05:41:20</upload_date> - <modified_date>2013-08-20 03:33:11</modified_date> - <number_of_likes>37</number_of_likes> - <number_of_plays>38941</number_of_plays> - <number_of_comments>9</number_of_comments> - <width>640</width> - <height>480</height> - <duration>13</duration> - <owner display_name="GNOME Shell" id="2664247" is_plus="0" is_pro="0" is_staff="0" profileurl="http://vimeo.com/user2664247" realname="GNOME Shell" username="user2664247" videosurl="http://vimeo.com/user2664247/videos"> - <portraits> - <portrait height="30" width="30">http://b.vimeocdn.com/ps/159/159264_30.jpg</portrait> - <portrait height="75" width="75">http://b.vimeocdn.com/ps/159/159264_75.jpg</portrait> - <portrait height="100" width="100">http://b.vimeocdn.com/ps/159/159264_100.jpg</portrait> - <portrait height="300" width="300">http://b.vimeocdn.com/ps/159/159264_300.jpg</portrait> - </portraits> - </owner> - <cast> - <member display_name="GNOME Shell" id="2664247" role="" username="user2664247"/> - </cast> - <urls> - <url type="video">http://vimeo.com/13797705</url> - <url type="mobile">http://vimeo.com/m/13797705</url> - </urls> - <thumbnails> - <thumbnail height="75" width="100">http://b.vimeocdn.com/ts/798/198/79819832_100.jpg</thumbnail> - <thumbnail height="150" width="200">http://b.vimeocdn.com/ts/798/198/79819832_200.jpg</thumbnail> - <thumbnail height="480" width="640">http://b.vimeocdn.com/ts/798/198/79819832_640.jpg</thumbnail> - </thumbnails> - </video> - </videos> -</rsp> diff --git a/tests/vimeo/meson.build b/tests/vimeo/meson.build deleted file mode 100644 index 55f8e4d..0000000 --- a/tests/vimeo/meson.build +++ /dev/null @@ -1,21 +0,0 @@ -# -# meson.build -# -# Author: Juan A. Suarez Romero <jasuarez@igalia.com> -# -# Copyright (C) 2016 Igalia S.L. All rights reserved. - -source_tests = [ - 'test_vimeo', -] - -foreach t: source_tests - exe = executable(t, t + '.c', - install: false, - dependencies: must_deps, - c_args: [ - '-DVIMEO_DATA_PATH="@0@/data/"'.format(meson.current_source_dir()), - '-DVIMEO_PLUGIN_PATH="@0@/src/vimeo/"'.format(meson.build_root()), - ]) - test(t, exe) -endforeach diff --git a/tests/vimeo/test_vimeo.c b/tests/vimeo/test_vimeo.c deleted file mode 100644 index 0749338..0000000 --- a/tests/vimeo/test_vimeo.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (C) 2013 Igalia S.L. - * - * Author: Juan A. Suarez Romero <jasuarez@igalia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include <locale.h> -#include <grilo.h> - -#define VIMEO_ID "grl-vimeo" - -#define VIMEO_KEY "TEST_VIMEO_KEY" -#define VIMEO_SECRET "TEST_VIMEO_SECRET" - -static GMainLoop *main_loop = NULL; - -static void -test_setup (void) -{ - GError *error = NULL; - GrlConfig *config; - GrlRegistry *registry; - - registry = grl_registry_get_default (); - - config = grl_config_new (VIMEO_ID, NULL); - grl_config_set_api_key (config, VIMEO_KEY); - grl_config_set_api_secret (config, VIMEO_SECRET); - grl_registry_add_config (registry, config, NULL); - - grl_registry_load_all_plugins (registry, TRUE, &error); - g_assert_no_error (error); -} - -static void -test_search_normal (void) -{ - GError *error = NULL; - GList *medias; - GrlMedia *media; - GrlOperationOptions *options; - GrlRegistry *registry; - GrlSource *source; - - registry = grl_registry_get_default (); - source = grl_registry_lookup_source (registry, VIMEO_ID); - g_assert (source); - options = grl_operation_options_new (NULL); - grl_operation_options_set_count (options, 2); - grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FAST_ONLY); - g_assert (options); - - medias = grl_source_search_sync (source, - "gnome", - grl_source_supported_keys (source), - options, - &error); - - g_assert_cmpint (g_list_length(medias), ==, 2); - g_assert_no_error (error); - - media = g_list_nth_data (medias, 0); - - g_assert (grl_media_is_video (media)); - g_assert_cmpstr (grl_media_get_id (media), - ==, - "31110838"); - g_assert_cmpstr (grl_media_get_title (media), - ==, - "Mound by Allison Schulnik"); - g_assert_cmpstr (grl_media_get_author (media), - ==, - "garaco taco"); - g_assert_cmpstr (grl_media_get_thumbnail (media), - ==, - "http://b.vimeocdn.com/ts/209/404/209404005_100.jpg"); - - media = g_list_nth_data (medias, 1); - - g_assert (grl_media_is_video (media)); - g_assert_cmpstr (grl_media_get_id (media), - ==, - "13797705"); - g_assert_cmpstr (grl_media_get_title (media), - ==, - "Shell Yes! motion design mockup"); - g_assert_cmpstr (grl_media_get_author (media), - ==, - "GNOME Shell"); - g_assert_cmpstr (grl_media_get_thumbnail (media), - ==, - "http://b.vimeocdn.com/ts/798/198/79819832_100.jpg"); - - g_list_free_full (medias, g_object_unref); - g_object_unref (options); -} - -static void -test_search_null (void) -{ - GError *error = NULL; - GList *medias; - GrlOperationOptions *options; - GrlRegistry *registry; - GrlSource *source; - - registry = grl_registry_get_default (); - source = grl_registry_lookup_source (registry, VIMEO_ID); - g_assert (source); - options = grl_operation_options_new (NULL); - grl_operation_options_set_count (options, 2); - grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FAST_ONLY); - g_assert (options); - - medias = grl_source_search_sync (source, - NULL, - grl_source_supported_keys (source), - options, - &error); - - g_assert_cmpint (g_list_length(medias), ==, 0); - g_assert_error (error, - GRL_CORE_ERROR, - GRL_CORE_ERROR_SEARCH_NULL_UNSUPPORTED); - - g_object_unref (options); - g_error_free (error); -} - -static void -test_search_empty (void) -{ - GError *error = NULL; - GList *medias; - GrlOperationOptions *options; - GrlRegistry *registry; - GrlSource *source; - - registry = grl_registry_get_default (); - source = grl_registry_lookup_source (registry, VIMEO_ID); - g_assert (source); - options = grl_operation_options_new (NULL); - grl_operation_options_set_count (options, 2); - grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FAST_ONLY); - g_assert (options); - - medias = grl_source_search_sync (source, - "invalidfoo", - grl_source_supported_keys (source), - options, - &error); - - g_assert_cmpint (g_list_length(medias), ==, 0); - g_assert_no_error (error); - - g_object_unref (options); -} - -static void -search_cb (GrlSource *source, - guint operation_id, - GrlMedia *media, - guint remaining, - gpointer user_data, - const GError *error) -{ - static gboolean is_cancelled = FALSE; - - if (!is_cancelled) { - g_assert (media); - g_object_unref (media); - g_assert_cmpint (remaining, >, 0); - g_assert_no_error (error); - grl_operation_cancel (operation_id); - is_cancelled = TRUE; - } else { - g_assert (!media); - g_assert_cmpint (remaining, ==, 0); - g_assert_error (error, - GRL_CORE_ERROR, - GRL_CORE_ERROR_OPERATION_CANCELLED); - g_main_loop_quit (main_loop); - } -} - -static void -test_cancel (void) -{ - GrlOperationOptions *options; - GrlRegistry *registry; - GrlSource *source; - - registry = grl_registry_get_default (); - source = grl_registry_lookup_source (registry, VIMEO_ID); - g_assert (source); - options = grl_operation_options_new (NULL); - grl_operation_options_set_count (options, 2); - grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FAST_ONLY); - g_assert (options); - - grl_source_search (source, - "gnome", - grl_source_supported_keys (source), - options, - search_cb, - NULL); - - if (!main_loop) { - main_loop = g_main_loop_new (NULL, FALSE); - } - - g_main_loop_run (main_loop); - g_object_unref (options); -} - -int -main (int argc, char **argv) -{ - gint result; - - setlocale (LC_ALL, ""); - - g_setenv ("GRL_PLUGIN_PATH", VIMEO_PLUGIN_PATH, TRUE); - g_setenv ("GRL_PLUGIN_LIST", VIMEO_ID, TRUE); - g_setenv ("GRL_NET_MOCKED", VIMEO_DATA_PATH "network-data.ini", TRUE); - - grl_init (&argc, &argv); - g_test_init (&argc, &argv, NULL); - - test_setup (); - - g_test_add_func ("/vimeo/search/normal", test_search_normal); - g_test_add_func ("/vimeo/search/null", test_search_null); - g_test_add_func ("/vimeo/search/empty", test_search_empty); - g_test_add_func ("/vimeo/cancel", test_cancel); - - result = g_test_run (); - - grl_deinit (); - - return result; -} |