Skip to content

Instantly share code, notes, and snippets.

@tdfischer
Last active August 29, 2015 14:01
Show Gist options
  • Save tdfischer/04dfdca11f2ab656dba1 to your computer and use it in GitHub Desktop.
Save tdfischer/04dfdca11f2ab656dba1 to your computer and use it in GitHub Desktop.
int main (int argc, char** argv)
{
EntropyCollection *collection;
GList *resources, cur;
collection = entropy_client_get_default_collection ();
resources = entropy_collection_sparql ("SELECT ?a { ?a a entropy:Resource . ?a dc:title \"Anamanaguchi\" . ?a a nfo:Audio .?a nmm:streamingBitrate ?b . FILTER (?b < 128.0 )}");
cur = resources;
while (cur) {
GInputStream *input;
gssize read_size;
gchar buf[1024];
GError *error = NULL;
input = entropy_resource_get_input_stream (ENTROPY_RESOURCE (cur->data));
read_size = g_input_stream_read (input, &buf, sizeof (buf), NULL, &error);
if (error) {
g_error ("Error while reading: %s", error->message);
}
while (read_size > 0) {
fwrite (buf, read_size, 1, stdout);
read_size = g_input_stream_read (input, &buf, sizeof (buf), NULL, &error);
}
if (error)
g_error ("Error while reading: %s", error->message);
g_object_unref (input);
cur = cur->next;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment