")) {
parse_movie ();
} else if (((string) current).has_prefix("
")) {
parse_cinema ();
} else {
current += i;
}
next_tag ();
}
}
public async void query (MovieFilter filter, string? location, MovieSource.ReceiveMovieFunction callback, Cancellable? cancellable) {
_get_callback = callback;
_filter = filter;
if (filter.title.chr(filter.title.length, '*') != null) {
pattern = new PatternSpec (filter.title);
} else {
pattern = null;
}
try {
// TODO - use google.de in Germany, also provides genres
string uri = "http://google.com/movies";
if (location != null && location != "")
uri += "?near=" + location;
stdout.printf ("GET: %s\n", uri);
File file = File.new_for_uri (uri);
InputStream stream = yield file.read_async (Priority.DEFAULT_IDLE, null);
char[] buf = new char[256*1024];
size_t nread;
size_t total = 0;
while (total < 256*1024) {
nread = yield stream.read_async ((char *)buf + total, 256*1024 - total, Priority.DEFAULT_IDLE, cancellable);
total += nread;
if (cancellable.is_cancelled ())
return;
if (nread == 0)
break;
}
buf[total] = 0;
parse (ref buf);
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
}
}