+++ /dev/null
-/*
- * movie.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 "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);
-}
-
+++ /dev/null
-/*
- * tmdb_movie.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 "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));
- }
-}
+++ /dev/null
-/*
- * tmdb_movie.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 TMDB_MOVIE_H_
-#define TMDB_MOVIE_H_
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <rest-0.6/rest/rest-proxy.h>
-#include <rest-0.6/rest/rest-proxy-call.h>
-#include <rest-0.6/rest/rest-xml-parser.h>
-
-#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_ */