4 * This file is part of maevies
5 * Copyright (C) 2009 Simón Pena <bulfaiter@gmail.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
19 #include "watc_provider.h"
22 gboolean watc_has_stingers(const gchar *name) {
26 const gchar *response;
29 /* Initialization: most probably done in the invoker */
30 /* g_thread_init(NULL);
33 /* Provider initialization, should be refactored. Maybe it can be reused between calls */
34 proxy = rest_proxy_new(WATC_SERVICE_URL, FALSE);
35 call = rest_proxy_new_call(proxy);
37 /* Adding params to the call: check http://en.wikipedia.org/w/api.php
39 * There's only one variable param: the movie name
41 rest_proxy_call_add_params(call, "action", "opensearch", "search", name,
45 rest_proxy_call_run(call, NULL, NULL);
47 /* Retrieving the results: should be done in/should receive a callback function */
48 response = rest_proxy_call_get_payload(call);
49 len = rest_proxy_call_get_payload_length(call);
51 /* Process the output: must be checked whether the response has a * in the expected result
53 write(1, response, len);
56 /* Object disposal, should be refactored. */
58 g_object_unref(proxy);
60 return parse_response(response);
63 /* Ad-hoc implementation. Will give a wrong result if the query had more than one result,
64 * if the title has a * in its text, or if the conventions used in what's after the credits vary.
66 gboolean parse_response(const gchar *response) {
68 return (strpbrk(response, "*") != NULL);