From: Simón Pena Date: Sun, 16 May 2010 19:12:32 +0000 (+0200) Subject: Project: Removed previous TMDB references X-Git-Url: https://vcs.maemo.org/git/?p=maevies;a=commitdiff_plain;h=a9eef173a7c9b383db756371569abc1c17c2aa3c Project: Removed previous TMDB references In the previous version, tmdb datasource was connected using synchronous queries, and didn't have the GObject wrappers. This commit removes those previous tmdb references, and updates Makefile.am. This is also a step towards removing librest dependency, in favor of just libxml. --- diff --git a/examples/Makefile.am b/examples/Makefile.am index 282c9fa..3f97a4e 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,5 +1,4 @@ bin_PROGRAMS = gmovies_test \ - tmdb_test \ gtranslate_test \ watc_test @@ -12,18 +11,6 @@ gmovies_test_CFLAGS = \ gmovies_test_LDADD = \ $(DEPS_LIBS) -tmdb_test_SOURCES = \ - test_tmdb.c \ - $(top_srcdir)/src/tmdb_movie.c \ - $(top_srcdir)/src/tmdb_movie.h - -tmdb_test_CFLAGS = \ - -I $(top_srcdir)/src/ \ - $(DEPS_CFLAGS) - -tmdb_test_LDADD = \ - $(DEPS_LIBS) - gtranslate_test_SOURCES = \ gtranslate.c diff --git a/examples/test_tmdb.c b/examples/test_tmdb.c deleted file mode 100644 index 57b83d5..0000000 --- a/examples/test_tmdb.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * test_tmdb.c - * - * This file is part of maevies - * Copyright (C) 2009 Simón Pena - * - * 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 -#include -#include -#include "tmdb_movie.h" - -gint main(gint argc, gchar **argv) { - - TMDBMovie *movie = NULL; - const gchar *title = NULL; - - if (argc != 2) { - title = "Zombieland"; - } else { - title = argv[1]; - } - - g_thread_init(NULL); - g_type_init(); - - movie = tmdb_get_info(title); - - tmdb_movie_print(movie); - - tmdb_movie_unref(movie); - return 1; -} diff --git a/src/maevies_movie.c b/src/maevies_movie.c deleted file mode 100644 index 989a939..0000000 --- a/src/maevies_movie.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * movie.c - * - * This file is part of maevies - * Copyright (C) 2009 Simón Pena - * - * 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 "maevies_movie.h" -#include "movie_info_provider.h" -#include "extra_scenes_provider.h" - -MaeviesMovie *maevies_movie_new(const gchar *name) { - - MaeviesMovie *movie = g_new0(MaeviesMovie,1); - - movie->title = name; - - return movie; -} - -void movie_get_info(MaeviesMovie *movie, GCallback callback) { - - /* Get movie info */ - get_info(movie); - - /* Get movie stingers */ - movie->has_stingers = has_stingers(movie->title); -} - diff --git a/src/maevies_movie.h b/src/maevies_movie.h deleted file mode 100644 index e13e500..0000000 --- a/src/maevies_movie.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * movie.h - * - * This file is part of maevies - * Copyright (C) 2009 Simón Pena - * - * 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 MOVIE_H_ -#define MOVIE_H_ - -#include -#include "maevies_movieschedule.h" - -G_BEGIN_DECLS - -typedef struct _MaeviesMovie MaeviesMovie; - -struct _MaeviesMovie { - - gboolean has_stingers; - const gchar *title; - gchar *director; - GSList *cast; - gfloat ranking; - GDate *released; - const gchar *overview; - const gchar *url; - GSList* movieScheduleList; - -}; - -MaeviesMovie *maevies_movie_new(const char *name); - -void movie_get_info(MaeviesMovie *movie, GCallback callback); - -G_END_DECLS - -#endif /* MOVIE_H_ */ diff --git a/src/tmdb_movie.c b/src/tmdb_movie.c deleted file mode 100644 index 150b1fd..0000000 --- a/src/tmdb_movie.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * tmdb_movie.c - * - * This file is part of maevies - * Copyright (C) 2009 Simón Pena - * - * 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 "tmdb_movie.h" - -static void do_get_info(TMDBMovie *movie); - -static void parse_xml_response(RestProxyCall *call, TMDBMovie *movie); - -TMDBMovie *tmdb_get_info(const gchar *name) { - - TMDBMovie *movie = g_new0(TMDBMovie, 1); - - movie->name = g_strdup(name); - - do_get_info(movie); - - /* - * movie->rating = 10; - * movie->released = g_date_new_dmy(1, G_DATE_FEBRUARY, 2009); - */ - - return movie; -} - -static void do_get_info(TMDBMovie *movie) { - - RestProxy *proxy; - RestProxyCall *call; - gchar *tmdb_function; - - proxy = rest_proxy_new(TMDB_SERVICE_URL, FALSE); - call = rest_proxy_new_call(proxy); - - /* Generate the function string. - * It's METHOD/LANGUAGE/FORMAT/APIKEY/MOVIENAME, - * so the actual query puts that after the URL */ - tmdb_function = g_strdup_printf("%s/%s/%s/%s/%s", TMDB_SEARCH_METHOD, - TMDB_LANGUAGE, TMDB_FORMAT, TMDB_API_KEY, movie->name); - - rest_proxy_call_set_function(call, tmdb_function); - - /* The actual call */ - rest_proxy_call_run(call, NULL, NULL); - - parse_xml_response(call, movie); - - /* Object disposal, should be refactored. */ - g_object_unref(call); - g_free(tmdb_function); - g_object_unref(proxy); -} - -static void parse_xml_response(RestProxyCall *call, TMDBMovie *movie) { - RestXmlParser *parser; - RestXmlNode *root; - RestXmlNode *tmp; - RestXmlNode *field; - gint total_results; - - parser = rest_xml_parser_new(); - - root = rest_xml_parser_parse_from_data(parser, rest_proxy_call_get_payload( - call), rest_proxy_call_get_payload_length(call)); - - tmp = g_hash_table_lookup(root->children, g_intern_string( - "opensearch:totalResults")); - - total_results = atof(tmp->content); - - tmp = g_hash_table_lookup(root->children, g_intern_string("movies")); - - tmp = g_hash_table_lookup(tmp->children, g_intern_string("movie")); - - while (tmp != NULL) { - - field = g_hash_table_lookup(tmp->children, - g_intern_string("popularity")); - movie->popularity = atoi(field->content); - - field = g_hash_table_lookup(tmp->children, g_intern_string("name")); - movie->name = g_strdup(field->content); - - field = g_hash_table_lookup(tmp->children, g_intern_string( - "alternative_name")); - movie->alternative_name = g_strdup(field->content); - - field = g_hash_table_lookup(tmp->children, g_intern_string("id")); - movie->id = atoi(field->content); - - field = g_hash_table_lookup(tmp->children, g_intern_string("imdb_id")); - movie->imdb_id = g_strdup(field->content); - - field = g_hash_table_lookup(tmp->children, g_intern_string("url")); - movie->url = g_strdup(field->content); - - field = g_hash_table_lookup(tmp->children, g_intern_string("rating")); - movie->rating = atof(field->content); - - field = g_hash_table_lookup(tmp->children, g_intern_string("released")); - movie->released = g_date_new(); - g_date_set_parse(movie->released, field->content); - - field = g_hash_table_lookup(tmp->children, g_intern_string("overview")); - movie->overview = g_strdup(field->content); - - /* tmp = tmp->next; */ - tmp = NULL; - } - - g_object_unref(parser); - rest_xml_node_unref(root); -} - -void tmdb_movie_unref(TMDBMovie *movie) { - - g_free(movie->alternative_name); - g_free(movie->imdb_id); - g_free(movie->name); - g_free(movie->overview); - g_free(movie->url); - - if (movie->released != NULL) - g_date_free(movie->released); - - g_free(movie); -} - -void tmdb_movie_print(const TMDBMovie *movie) { - - g_print("themoviedb.org - The Movie Database.\n"); - g_print("Movie name: %s\n", GET_MESSAGE(movie->name)); - g_print("Alternate name: %s\n", GET_MESSAGE(movie->alternative_name)); - g_print("Rating: %f\n", movie->rating); - g_print("Overview:\n %s\n", GET_MESSAGE(movie->overview)); - g_print("ID: %d\n", movie->id); - g_print("IMDB ID: %s\n", GET_MESSAGE(movie->imdb_id)); - g_print("Popularity: %d\n", movie->popularity); - g_print("URL: %s\n", GET_MESSAGE(movie->url)); - g_print("Runtime: %d\n", movie->runtime); - if (g_date_valid(movie->released)) { - g_print("Released: %d-%d-%d\n", g_date_get_year(movie->released), - g_date_get_month(movie->released), g_date_get_day( - movie->released)); - } -} diff --git a/src/tmdb_movie.h b/src/tmdb_movie.h deleted file mode 100644 index 894b89f..0000000 --- a/src/tmdb_movie.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * tmdb_movie.h - * - * This file is part of maevies - * Copyright (C) 2009 Simón Pena - * - * 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 TMDB_MOVIE_H_ -#define TMDB_MOVIE_H_ - -#include -#include -#include -#include -#include - -#define GET_MESSAGE(x) ( (x) ? x : " - " ) -#define TMDB_API_KEY "249e1a42df9bee09fac5e92d3a51396b" -#define TMDB_SERVICE_URL "http://api.themoviedb.org/2.1" -#define TMDB_LANGUAGE "en" -#define TMDB_FORMAT "xml" -#define TMDB_SEARCH_METHOD "Movie.search" - -typedef struct _TMDBMovie TMDBMovie; - -struct _TMDBMovie { - - gint popularity; - gchar *name; - gchar *alternative_name; - gint id; - gchar *imdb_id; - gchar *url; - gchar *overview; - gfloat rating; - GDate *released; - gint runtime; -/* categories */ -/* images */ -}; - -TMDBMovie *tmdb_get_info(const gchar *name); - -void tmdb_movie_unref(TMDBMovie *movie); - -void tmdb_movie_print(const TMDBMovie *movie); - -#endif /* TMDB_MOVIE_H_ */