[grilo-plugins] lua-factory: Add grl.is_video_site() function
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] lua-factory: Add grl.is_video_site() function
- Date: Tue, 21 Jul 2015 12:41:21 +0000 (UTC)
commit b5c2560bdc760c96b1101f498e414bb2215cc6e6
Author: Bastien Nocera <hadess hadess net>
Date: Sun Jul 19 16:16:46 2015 +0200
lua-factory: Add grl.is_video_site() function
Based upon totem-pl-parser's totem_pl_parser_can_parse_from_uri()
function.
https://bugzilla.gnome.org/show_bug.cgi?id=752595
configure.ac | 9 +++++++--
src/lua-factory/grl-lua-library.c | 27 +++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b0b3d2b..f480ad5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,6 +148,11 @@ PKG_CHECK_MODULES(GOA_WITH_POCKET, [goa-1.0 >= 3.11.4], HAVE_GOA_WITH_POCKET=yes
PKG_CHECK_MODULES(TOTEM_PL_PARSER, totem-plparser >= 3.4.1, HAVE_TOTEM_PL_PARSER=yes,
HAVE_TOTEM_PL_PARSER=no)
+PKG_CHECK_MODULES(TOTEM_PL_PARSER_MINI, totem-plparser-mini >= 3.4.1, HAVE_TOTEM_PL_PARSER_MINI=yes,
HAVE_TOTEM_PL_PARSER_MINI=no)
+if test "x$HAVE_TOTEM_PL_PARSER_MINI" = "xyes"; then
+ AC_DEFINE(HAVE_TOTEM_PLPARSER_MINI, 1, [totem-plparser-mini is available])
+fi
+
PKG_CHECK_MODULES(REST, [rest-0.7 >= 0.7.90], HAVE_REST=yes, HAVE_REST=no)
PKG_CHECK_MODULES([JSON], [json-glib-1.0], HAVE_JSON_GLIB=yes, HAVE_JSON_GLIB=no)
@@ -820,12 +825,12 @@ LUA_FACTORY_PLUGIN_ID="grl-lua-factory"
AC_SUBST(LUA_FACTORY_PLUGIN_ID)
AC_DEFINE_UNQUOTED([LUA_FACTORY_PLUGIN_ID], ["$LUA_FACTORY_PLUGIN_ID"], [Lua Factory plugin ID])
-DEPS_LUA_FACTORY_CFLAGS="$DEPS_CFLAGS $LUA_CFLAGS $ARCHIVE_CFLAGS $GRLNET_CFLAGS $JSON_CFLAGS"
+DEPS_LUA_FACTORY_CFLAGS="$DEPS_CFLAGS $LUA_CFLAGS $ARCHIVE_CFLAGS $GRLNET_CFLAGS $JSON_CFLAGS
$TOTEM_PL_PARSER_MINI_CFLAGS"
if test "x$enable_goa" = "xyes"; then
DEPS_LUA_FACTORY_CFLAGS="$DEPS_LUA_FACTORY_CFLAGS $GOA_CFLAGS"
fi
AC_SUBST(DEPS_LUA_FACTORY_CFLAGS)
-DEPS_LUA_FACTORY_LIBS="$DEPS_LIBS $LUA_LIBS $ARCHIVE_LIBS $GRLNET_LIBS $JSON_LIBS"
+DEPS_LUA_FACTORY_LIBS="$DEPS_LIBS $LUA_LIBS $ARCHIVE_LIBS $GRLNET_LIBS $JSON_LIBS $TOTEM_PL_PARSER_MINI_LIBS"
if test "x$enable_goa" = "xyes"; then
DEPS_LUA_FACTORY_LIBS="$DEPS_LUA_FACTORY_LIBS $GOA_LIBS"
fi
diff --git a/src/lua-factory/grl-lua-library.c b/src/lua-factory/grl-lua-library.c
index 564ea14..08e593d 100644
--- a/src/lua-factory/grl-lua-library.c
+++ b/src/lua-factory/grl-lua-library.c
@@ -34,6 +34,10 @@
#include "lua-library/lua-libraries.h"
#include "lua-library/htmlentity.h"
+#ifdef HAVE_TOTEM_PLPARSER_MINI
+#include <totem-pl-parser-mini.h>
+#endif
+
#define GRL_LOG_DOMAIN_DEFAULT lua_library_log_domain
GRL_LOG_DOMAIN_STATIC (lua_library_log_domain);
@@ -1342,6 +1346,28 @@ grl_l_goa_access_token (lua_State *L)
#endif
}
+static gint
+grl_l_is_video_site (lua_State *L)
+{
+ const char *url;
+ gboolean ret = FALSE;
+
+ luaL_argcheck (L, lua_isstring (L, 1), 1,
+ "expecting url as string");
+
+ url = lua_tolstring (L, 1, NULL);
+
+#ifdef HAVE_TOTEM_PLPARSER_MINI
+ ret = totem_pl_parser_can_parse_from_uri (url, FALSE);
+#else
+ GRL_DEBUG ("Return FALSE for whether '%s' is a video site, as compiled without totem-plparser-mini
support", url);
+#endif
+
+ lua_pushboolean (L, ret);
+
+ return 1;
+}
+
/* ================== Lua-Library initialization =========================== */
/** Load library included as GResource and run it with lua_pcall.
@@ -1388,6 +1414,7 @@ luaopen_grilo (lua_State *L)
{"unzip", &grl_l_unzip},
{"goa_access_token", &grl_l_goa_access_token},
{"goa_consumer_key", &grl_l_goa_consumer_key},
+ {"is_video_site", &grl_l_is_video_site},
{NULL, NULL}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]