File: mb-test.c

package info (click to toggle)
sound-juicer 2.14.6-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,776 kB
  • ctags: 724
  • sloc: sh: 8,890; ansic: 5,870; xml: 2,658; cpp: 443; makefile: 173
file content (58 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <glib.h>
#include <stdlib.h>
#include "sj-structures.h"
#include "sj-metadata.h"
#include "sj-metadata-musicbrainz.h"

static void
metadata_cb (SjMetadata *metadata, GList *albums, GError *error)
{
  if (error != NULL) {
    g_print ("Error: %s\n", error->message);
    g_error_free (error);
    g_object_unref (metadata);
    exit (1);
  }

  while (albums) {
    AlbumDetails *album;
    album = (AlbumDetails*)albums->data;
    g_print ("'%s', by %s\n", album->title, album->artist);
    while (album->tracks) {
      TrackDetails *track = (TrackDetails*)album->tracks->data;
      g_print (" Track %d; Title: %s; Artist: %s Duration: %d sec\n", track->number, track->title, track->artist, track->duration);
      album->tracks = g_list_next (album->tracks);
    }
    albums = g_list_next (albums);
  }

  g_object_unref (metadata);
  exit (0);
}

int main (int argc, char** argv)
{
  SjMetadata *metadata;
  GMainLoop *loop;

  g_type_init ();
  g_thread_init (NULL);
  
  metadata = (SjMetadata*)sj_metadata_musicbrainz_new ();

  if (argc == 2) {
    sj_metadata_set_cdrom (metadata, argv[1]);
  } else {
    g_print ("Usage: %s [CD device]\n", argv[0]);
    exit (1);
  }

  g_signal_connect (G_OBJECT (metadata), "metadata",
		    G_CALLBACK (metadata_cb), NULL);
  sj_metadata_list_albums (metadata, NULL);

  loop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (loop);

  return 0;
}