[grilo-plugins] guardian-videos: Add a source for Guardian Videos
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] guardian-videos: Add a source for Guardian Videos
- Date: Sun, 9 Feb 2014 22:44:51 +0000 (UTC)
commit fa49c5a92f7ba00d3b74f148e401fc7ee81d852d
Author: Bastien Nocera <hadess hadess net>
Date: Mon Jan 27 16:47:54 2014 +0100
guardian-videos: Add a source for Guardian Videos
Not that great because the RSS feed only seems to list the
10 newest videos, but pretty neat nonetheless.
https://bugzilla.gnome.org/show_bug.cgi?id=680678
configure.ac | 41 ++++
src/Makefile.am | 6 +-
src/guardian-videos/Makefile.am | 50 +++++
src/guardian-videos/grl-guardianvideos.c | 227 ++++++++++++++++++++++
src/guardian-videos/grl-guardianvideos.h | 76 +++++++
src/guardian-videos/grl-guardianvideos.xml | 10 +
src/guardian-videos/guardian.png | Bin 0 -> 2193 bytes
src/guardian-videos/guardianvideos.gresource.xml | 6 +
8 files changed, 415 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 512808a..d3dae9f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1175,6 +1175,46 @@ DEPS_FREEBOX_LIBS="$DEPS_LIBS $GRLPLS_LIBS $AVAHI_LIBS"
AC_SUBST(DEPS_FREEBOX_LIBS)
# ----------------------------------------------------------
+# BUILD GUARDIANVIDEOS PLUGIN
+# ----------------------------------------------------------
+
+AC_ARG_ENABLE(guardianvideos,
+ AC_HELP_STRING([--enable-guardianvideos],
+ [enable Guardian Videos plugin (default: auto)]),
+ [
+ case "$enableval" in
+ yes)
+ if test "x$HAVE_GRLPLS" = "xno"; then
+ AC_MSG_ERROR([grilo-pls-0.2 >= 0.2.0 not found, install it or use
--disable-guardianvideos])
+ fi
+ ;;
+ esac
+ ],
+ [
+ if test "x$HAVE_GRLPLS" = "xyes"; then
+ enable_guardianvideos=yes
+ else
+ enable_guardianvideos=no
+ fi
+ ])
+
+AM_CONDITIONAL([GUARDIANVIDEOS_PLUGIN], [test "x$enable_guardianvideos" = "xyes"])
+GRL_PLUGINS_ALL="$GRL_PLUGINS_ALL guardianvideos"
+if test "x$enable_guardianvideos" = "xyes"
+then
+ GRL_PLUGINS_ENABLED="$GRL_PLUGINS_ENABLED guardianvideos"
+fi
+
+GUARDIANVIDEOS_PLUGIN_ID="grl-guardianvideos"
+AC_SUBST(GUARDIANVIDEOS_PLUGIN_ID)
+AC_DEFINE_UNQUOTED([GUARDIANVIDEOS_PLUGIN_ID], ["$GUARDIANVIDEOS_PLUGIN_ID"], [Guardian Videos plugin ID])
+
+DEPS_GUARDIANVIDEOS_CFLAGS="$DEPS_CFLAGS $GRLPLS_CFLAGS"
+AC_SUBST(DEPS_GUARDIANVIDEOS_CFLAGS)
+DEPS_GUARDIANVIDEOS_LIBS="$DEPS_LIBS $GRLPLS_LIBS"
+AC_SUBST(DEPS_GUARDIANVIDEOS_LIBS)
+
+# ----------------------------------------------------------
# GETTEXT/INTLTOOL
# ----------------------------------------------------------
@@ -1217,6 +1257,7 @@ AC_CONFIG_FILES([
src/flickr/Makefile
src/freebox/Makefile
src/gravatar/Makefile
+ src/guardian-videos/Makefile
src/jamendo/Makefile
src/lastfm-albumart/Makefile
src/local-metadata/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index d4d763a..4fc5a9d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -98,8 +98,12 @@ if FREEBOX_PLUGIN
SUBDIRS += freebox
endif
+if GUARDIANVIDEOS_PLUGIN
+SUBDIRS += guardian-videos
+endif
+
DIST_SUBDIRS = \
- apple-trailers bliptv bookmarks dmap filesystem flickr freebox gravatar jamendo \
+ apple-trailers bliptv bookmarks dmap filesystem flickr freebox gravatar guardian-videos jamendo \
lastfm-albumart local-metadata magnatune metadata-store optical-media \
podcasts raitv shoutcast tmdb tracker upnp vimeo youtube
diff --git a/src/guardian-videos/Makefile.am b/src/guardian-videos/Makefile.am
new file mode 100644
index 0000000..542c296
--- /dev/null
+++ b/src/guardian-videos/Makefile.am
@@ -0,0 +1,50 @@
+#
+# Makefile.am
+#
+# Author: Bastien Nocera <hadess hadess net>
+#
+# Copyright (C) 2014 Bastien Nocera
+
+include $(top_srcdir)/gtester.mk
+
+ext_LTLIBRARIES = libgrlguardianvideos.la
+
+libgrlguardianvideos_la_CFLAGS = \
+ $(DEPS_GUARDIANVIDEOS_CFLAGS) \
+ -DG_LOG_DOMAIN=\"GrlFreebox\" \
+ -DLOCALEDIR=\"$(localedir)\"
+
+libgrlguardianvideos_la_LIBADD = \
+ $(DEPS_GUARDIANVIDEOS_LIBS)
+
+libgrlguardianvideos_la_LDFLAGS = \
+ -no-undefined \
+ -module \
+ -avoid-version
+
+libgrlguardianvideos_la_SOURCES = \
+ grl-guardianvideos.c \
+ grl-guardianvideos.h \
+ guardianvideosresources.h \
+ guardianvideosresources.c
+
+guardianvideosresources.h: guardianvideos.gresource.xml
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/guardianvideos.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --c-name _grl_guardianvideos --generate-header
+guardianvideosresources.c: guardianvideos.gresource.xml guardianvideosresources.h guardian.png
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/guardianvideos.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --c-name _grl_guardianvideos --generate-source
+
+extdir = $(GRL_PLUGINS_DIR)
+guardianvideosxmldir = $(GRL_PLUGINS_DIR)
+guardianvideosxml_DATA = $(GUARDIANVIDEOS_PLUGIN_ID).xml
+
+EXTRA_DIST = $(guardianvideosxml_DATA) guardian.png guardianvideos.gresource.xml
+
+MAINTAINERCLEANFILES = \
+ *.in \
+ *~
+
+CLEANFILES = guardianvideosresources.h guardianvideosresources.c
+
+DISTCLEANFILES = $(MAINTAINERCLEANFILES)
diff --git a/src/guardian-videos/grl-guardianvideos.c b/src/guardian-videos/grl-guardianvideos.c
new file mode 100644
index 0000000..d253c55
--- /dev/null
+++ b/src/guardian-videos/grl-guardianvideos.c
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2013 Bastien Nocera
+ *
+ * Contact: Bastien Nocera <hadess hadess net>
+ *
+ * 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 <gio/gio.h>
+#include <glib/gi18n-lib.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pls/grl-pls.h>
+
+#include "grl-guardianvideos.h"
+
+#define GUARDIANVIDEOS_URL "http://www.guardian.co.uk/video/rss"
+
+/* --------- Logging -------- */
+
+#define GRL_LOG_DOMAIN_DEFAULT guardianvideos_log_domain
+GRL_LOG_DOMAIN_STATIC(guardianvideos_log_domain);
+
+/* --- Plugin information --- */
+
+#define PLUGIN_ID GUARDIANVIDEOS_PLUGIN_ID
+
+#define SOURCE_ID "grl-guardianvideos"
+#define SOURCE_NAME _("The Guardian Videos")
+#define SOURCE_DESC _("A source for browsing videos from the Guardian")
+
+/* --- Grilo GuardianVideos Private --- */
+
+#define GRL_GUARDIANVIDEOS_SOURCE_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((object), \
+ GRL_GUARDIANVIDEOS_SOURCE_TYPE, \
+ GrlGuardianVideosSourcePrivate))
+
+struct _GrlGuardianVideosSourcePrivate {
+ GrlMedia *media;
+ int last_seen_channel;
+};
+
+/* --- Data types --- */
+
+static GrlGuardianVideosSource *grl_guardianvideos_source_new (void);
+
+static void grl_guardianvideos_source_finalize (GObject *object);
+
+gboolean grl_guardianvideos_plugin_init (GrlRegistry *registry,
+ GrlPlugin *plugin,
+ GList *configs);
+
+static const GList *grl_guardianvideos_source_supported_keys (GrlSource *source);
+
+static void grl_guardianvideos_source_browse (GrlSource *source,
+ GrlSourceBrowseSpec *bs);
+
+/* =================== GuardianVideos Plugin =============== */
+
+gboolean
+grl_guardianvideos_plugin_init (GrlRegistry *registry,
+ GrlPlugin *plugin,
+ GList *configs)
+{
+ GrlGuardianVideosSource *source;
+
+ GRL_LOG_DOMAIN_INIT (guardianvideos_log_domain, "guardianvideos");
+
+ GRL_DEBUG ("%s", __FUNCTION__);
+
+ /* Initialize i18n */
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ source = grl_guardianvideos_source_new ();
+ registry = grl_registry_get_default ();
+
+ grl_registry_register_source (registry,
+ plugin,
+ GRL_SOURCE (source),
+ NULL);
+
+ return TRUE;
+}
+
+GRL_PLUGIN_REGISTER (grl_guardianvideos_plugin_init,
+ NULL,
+ PLUGIN_ID);
+
+/* ================== GuardianVideos GObject ================ */
+
+
+G_DEFINE_TYPE (GrlGuardianVideosSource,
+ grl_guardianvideos_source,
+ GRL_TYPE_SOURCE);
+
+static GrlGuardianVideosSource *
+grl_guardianvideos_source_new (void)
+{
+ GIcon *icon;
+ GFile *file;
+ GrlGuardianVideosSource *object;
+
+ GRL_DEBUG ("%s", __FUNCTION__);
+
+ file = g_file_new_for_uri ("resource:///org/gnome/grilo/plugins/guardianvideos/guardian.png");
+ icon = g_file_icon_new (file);
+ g_object_unref (file);
+ object = g_object_new (GRL_GUARDIANVIDEOS_SOURCE_TYPE,
+ "source-id", SOURCE_ID,
+ "source-name", SOURCE_NAME,
+ "source-desc", SOURCE_DESC,
+ "supported-media", GRL_MEDIA_TYPE_VIDEO,
+ "source-icon", icon,
+ NULL);
+ return object;
+}
+
+static void
+grl_guardianvideos_source_class_init (GrlGuardianVideosSourceClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GrlSourceClass *source_class = GRL_SOURCE_CLASS (klass);
+
+ object_class->finalize = grl_guardianvideos_source_finalize;
+
+ source_class->supported_keys = grl_guardianvideos_source_supported_keys;
+ source_class->browse = grl_guardianvideos_source_browse;
+
+ g_type_class_add_private (klass, sizeof (GrlGuardianVideosSourcePrivate));
+}
+
+static void
+grl_guardianvideos_source_init (GrlGuardianVideosSource *source)
+{
+ GrlGuardianVideosSourcePrivate *priv;
+
+ priv = source->priv = GRL_GUARDIANVIDEOS_SOURCE_GET_PRIVATE(source);
+
+ priv->media = grl_media_new ();
+ grl_media_set_url (priv->media, GUARDIANVIDEOS_URL);
+}
+
+static void
+grl_guardianvideos_source_finalize (GObject *object)
+{
+ GrlGuardianVideosSource *source = GRL_GUARDIANVIDEOS_SOURCE (object);
+ GrlGuardianVideosSourcePrivate *priv = GRL_GUARDIANVIDEOS_SOURCE (source)->priv;
+
+ g_object_unref (priv->media);
+
+ G_OBJECT_CLASS (grl_guardianvideos_source_parent_class)->finalize (object);
+}
+
+/* ================== API Implementation ================ */
+
+static const GList *
+grl_guardianvideos_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_URL,
+ GRL_METADATA_KEY_THUMBNAIL,
+ GRL_METADATA_KEY_DESCRIPTION,
+ NULL);
+ }
+ return keys;
+}
+
+static GrlMedia *
+filter_func (GrlSource *source,
+ GrlMedia *media,
+ gpointer user_data)
+{
+ GrlMedia *ret;
+ const char *url;
+
+ url = grl_media_get_url (media);
+
+ ret = grl_media_video_new ();
+ grl_media_set_url (ret, url);
+ grl_media_set_id (ret, url);
+ grl_media_set_title (ret, grl_media_get_title (media));
+ grl_media_set_thumbnail (ret, grl_media_get_thumbnail (media));
+ grl_media_set_description (ret, grl_media_get_description (media));
+
+ g_object_unref (media);
+
+ return ret;
+}
+
+static void
+grl_guardianvideos_source_browse (GrlSource *source,
+ GrlSourceBrowseSpec *bs)
+{
+ GrlGuardianVideosSourcePrivate *priv = GRL_GUARDIANVIDEOS_SOURCE (source)->priv;
+
+ grl_pls_browse (source,
+ priv->media,
+ bs->keys,
+ bs->options,
+ filter_func,
+ bs->callback,
+ bs->user_data);
+}
diff --git a/src/guardian-videos/grl-guardianvideos.h b/src/guardian-videos/grl-guardianvideos.h
new file mode 100644
index 0000000..ef81487
--- /dev/null
+++ b/src/guardian-videos/grl-guardianvideos.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 Bastien Nocera
+ *
+ * Contact: Bastien Nocera <hadess hadess net>
+ *
+ * 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_GUARDIANVIDEOS_SOURCE_H_
+#define _GRL_GUARDIANVIDEOS_SOURCE_H_
+
+#include <grilo.h>
+
+#define GRL_GUARDIANVIDEOS_SOURCE_TYPE \
+ (grl_guardianvideos_source_get_type ())
+
+#define GRL_GUARDIANVIDEOS_SOURCE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ GRL_GUARDIANVIDEOS_SOURCE_TYPE, \
+ GrlGuardianVideosSource))
+
+#define GRL_IS_GUARDIANVIDEOS_SOURCE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ GRL_GUARDIANVIDEOS_SOURCE_TYPE))
+
+#define GRL_GUARDIANVIDEOS_SOURCE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GRL_GUARDIANVIDEOS_SOURCE_TYPE, \
+ GrlGuardianVideosSourceClass))
+
+#define GRL_IS_GUARDIANVIDEOS_SOURCE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass) \
+ GRL_GUARDIANVIDEOS_SOURCE_TYPE))
+
+#define GRL_GUARDIANVIDEOS_SOURCE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ GRL_GUARDIANVIDEOS_SOURCE_TYPE, \
+ GrlGuardianVideosSourceClass))
+
+
+typedef struct _GrlGuardianVideosSource GrlGuardianVideosSource;
+typedef struct _GrlGuardianVideosSourcePrivate GrlGuardianVideosSourcePrivate;
+
+struct _GrlGuardianVideosSource {
+
+ GrlSource parent;
+
+ /*< private >*/
+ GrlGuardianVideosSourcePrivate *priv;
+};
+
+typedef struct _GrlGuardianVideosSourceClass GrlGuardianVideosSourceClass;
+
+struct _GrlGuardianVideosSourceClass {
+
+ GrlSourceClass parent_class;
+
+};
+
+GType grl_guardianvideos_source_get_type (void);
+
+#endif /* _GRL_GUARDIANVIDEOS_SOURCE_H_ */
diff --git a/src/guardian-videos/grl-guardianvideos.xml b/src/guardian-videos/grl-guardianvideos.xml
new file mode 100644
index 0000000..2b291a3
--- /dev/null
+++ b/src/guardian-videos/grl-guardianvideos.xml
@@ -0,0 +1,10 @@
+<plugin>
+ <info>
+ <name>The Guardian Videos</name>
+ <module>libgrlguardianvideos</module>
+ <description>A plugin for browsing videos from the Guardian</description>
+ <author>GNOME</author>
+ <license>LGPL</license>
+ <site>http://www.gnome.org</site>
+ </info>
+</plugin>
diff --git a/src/guardian-videos/guardian.png b/src/guardian-videos/guardian.png
new file mode 100644
index 0000000..44a4ccc
Binary files /dev/null and b/src/guardian-videos/guardian.png differ
diff --git a/src/guardian-videos/guardianvideos.gresource.xml
b/src/guardian-videos/guardianvideos.gresource.xml
new file mode 100644
index 0000000..297f2d3
--- /dev/null
+++ b/src/guardian-videos/guardianvideos.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/grilo/plugins/guardianvideos">
+ <file compressed="false">guardian.png</file>
+ </gresource>
+</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]