Commit d6d91c7c authored by Victor Toso's avatar Victor Toso
Browse files

vimeo: remove due API change v2->v3

This is not working for over a year now.
Related: #67
parent 2ce6c6e9
Pipeline #269860 passed with stage
in 6 minutes and 33 seconds
......@@ -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], []],
]
......
......@@ -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')
<?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>
/*
* 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,