bin_PROGRAMS = gmovies_test \
- gtranslate_test \
- watc_test
+ gtranslate_test
gmovies_test_SOURCES = \
gmovies.c
gtranslate_test_LDADD = \
$(DEPS_LIBS)
-watc_test_SOURCES = \
- test_watc.c \
- $(top_srcdir)/src/watc_provider.c \
- $(top_srcdir)/src/watc_provider.h
-
-watc_test_CFLAGS = \
- -I $(top_srcdir)/src/ \
- $(DEPS_CFLAGS)
-
-watc_test_LDADD = \
- $(DEPS_LIBS)
-
MAINTAINERCLEANFILES = \
*.in \
*~
+++ /dev/null
-/*
- * test_watc.c
- *
- * This file is part of maevies
- * Copyright (C) 2009 Simon Pena <spenap@gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- */
-
-#include <glib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include "watc_provider.h"
-
-static void show_watc_info(gpointer info, gpointer data);
-
-gint main(gint argc, gchar **argv) {
-
- GSList *result_list = NULL;
- const gchar *movie_name = NULL;
-
- if (argc != 2) {
- movie_name = "Zombieland";
- } else {
- movie_name = argv[1];
- }
-
- g_thread_init(NULL);
- g_type_init();
-
- result_list = watc_has_stingers(movie_name);
-
- g_slist_foreach(result_list, (GFunc) show_watc_info, NULL);
-
- watcinfo_list_unref(result_list);
-
- return 1;
-}
-
-static void show_watc_info(gpointer info, gpointer data) {
-
- WATCInfo *movie_info = (info);
-
- watcinfo_print(movie_info);
-
-}
+++ /dev/null
-/*
- * extra_scenes_provider.c
- *
- * This file is part of maevies
- * Copyright (C) 2009 Simón Pena <spenap@gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- */
-
-#include "extra_scenes_provider.h"
-#include "watc_provider.h"
-
-gboolean has_stingers(const gchar *movie) {
-
- /* There should be a mechanism here
- * allowing us to dynamically load new libraries
- * dlopen - http://stackoverflow.com/questions/384121/creating-a-module-system-dynamic-loading-in-c
- * Until we get it, we'll use just one of the provided providers ;)
- */
- GSList *result_list = watc_has_stingers(movie);
- WATCInfo *result = NULL;
- gboolean value = FALSE;
-
- if (g_slist_length(result_list) == 1) {
-
- result = (WATCInfo *) g_slist_nth(result_list, 0);
- if (result != NULL)
- value = result->has_stingers;
- }
-
- watcinfo_list_unref(result_list);
-
- return value;
-}
+++ /dev/null
-/*
- * extra_scenes_provider.h
- *
- * This file is part of maevies
- * Copyright (C) 2009 Simón Pena <spenap@gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- */
-
-#ifndef EXTRA_SCENES_PROVIDER_H_
-#define EXTRA_SCENES_PROVIDER_H_
-
-#include <hildon/hildon.h>
-
-gboolean has_stingers(const gchar *movie);
-
-#endif /* EXTRA_SCENES_PROVIDER_H_ */
+++ /dev/null
-/*
- * watc_provider.c
- *
- * This file is part of maevies
- * Copyright (C) 2009 Simón Pena <spenap@gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- */
-
-#include "watc_provider.h"
-#include "string.h"
-
-static GSList *parse_response(const gchar *response);
-
-GSList *watc_has_stingers(const gchar *name) {
-
- RestProxy *proxy;
- RestProxyCall *call;
- GSList *result_list;
- const gchar *response;
-
- /* Provider initialization, should be refactored. Maybe it can be reused between calls */
- proxy = rest_proxy_new(WATC_SERVICE_URL, FALSE);
- call = rest_proxy_new_call(proxy);
-
- /* Adding params to the call: check http://en.wikipedia.org/w/api.php
- *
- * There's only one variable param: the movie name
- * */
- rest_proxy_call_add_params(call, "action", "opensearch", "search", name,
- NULL);
-
- /* The actual call */
- rest_proxy_call_run(call, NULL, NULL);
-
- /* Retrieving the results: should be done in/should receive a callback function */
- response = rest_proxy_call_get_payload(call);
-
- result_list = parse_response(response);
-
- g_object_unref(call);
- g_object_unref(proxy);
-
- return result_list;
-}
-
-/* Ad-hoc implementation. Will give a wrong result if the query had more than one result,
- * if the title has a * in its text, or if the conventions used in what's after the credits vary.
- *
- * ["2012",["2012 (2009)","2012 (2009)?"]]
- */
-static GSList *parse_response(const gchar *response) {
-
- GSList *result_list = NULL;
- gint i;
- gchar **tokens = NULL;
- WATCInfo *result = NULL;
-
- /* We split the response into tokens.
- * - First: before [
- * - Second: before "
- * - Third: search term
- * - Fourth: before,
- * - Fifth: before [
- * - Sixth: before "
- * - Seventh: first actual result
- * */
- tokens = g_strsplit_set(response, "[],\"", -1);
-
- for (i = 4; i < g_strv_length(tokens); i++) {
- if (strlen(tokens[i])) {
- result = g_new0(WATCInfo,1);
- result->movie_name = g_strdup(tokens[i]);
- result->has_stingers = g_str_has_suffix(tokens[i], "*")
- || g_str_has_suffix(tokens[i], "?");
- result_list = g_slist_append(result_list, result);
- }
- }
-
- g_strfreev(tokens);
-
- return result_list;
-}
-
-void watcinfo_print(WATCInfo *info) {
-
- g_print("Movie: %s", info->movie_name);
- g_print(" %s\n", (info->has_stingers) ? "has extra scenes"
- : "doesn't have extra scenes");
-
-}
-
-void watcinfo_unref(WATCInfo *info) {
-
- g_free(info->movie_name);
- g_free(info);
-}
-
-void watcinfo_list_unref(GSList *list) {
-
- g_slist_foreach(list, (GFunc) watcinfo_unref, NULL);
- g_slist_free(list);
-
-}
+++ /dev/null
-/*
- * watc_provider.h
- *
- * This file is part of maevies
- * Copyright (C) 2009 Simón Pena <spenap@gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- */
-
-#ifndef WATC_PROVIDER_H_
-#define WATC_PROVIDER_H_
-
-#include <stdio.h>
-#include <rest-0.6/rest/rest-proxy.h>
-#include <unistd.h>
-
-#define WATC_SERVICE_URL "http://whatsafterthecredits.com/api.php"
-typedef struct _WATCInfo WATCInfo;
-
-struct _WATCInfo {
- gchar *movie_name;
- gboolean has_stingers;
-};
-
-GSList *watc_has_stingers(const gchar *name);
-
-void watcinfo_unref(WATCInfo *info);
-
-void watcinfo_list_unref(GSList *list);
-
-void watcinfo_print(WATCInfo *info);
-
-#endif /* WATC_PROVIDER_H_ */