00001
00022 #include "common.h"
00023
00024 static void dump_plinfo(LIBMTP_mtpdevice_t *device, LIBMTP_playlist_t *pl)
00025 {
00026 uint32_t i;
00027
00028 printf("Playlist ID: %d\n", pl->playlist_id);
00029 if (pl->name != NULL)
00030 printf(" Name: %s\n", pl->name);
00031 printf(" Tracks:\n");
00032
00033 for (i = 0; i < pl->no_tracks; i++) {
00034 LIBMTP_track_t *track;
00035
00036 track = LIBMTP_Get_Trackmetadata(device, pl->tracks[i]);
00037 if (track != NULL) {
00038 printf(" %u: %s - %s\n", pl->tracks[i], track->artist, track->title);
00039 LIBMTP_destroy_track_t(track);
00040 } else {
00041 printf(" %u: INVALID TRACK REFERENCE!\n", pl->tracks[i]);
00042 LIBMTP_Dump_Errorstack(device);
00043 LIBMTP_Clear_Errorstack(device);
00044 }
00045 }
00046 }
00047
00048 int main (int argc, char **argv)
00049 {
00050 LIBMTP_mtpdevice_t *device;
00051 LIBMTP_playlist_t *playlists;
00052
00053 fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
00054
00055 LIBMTP_Init();
00056 device = LIBMTP_Get_First_Device();
00057 if (device == NULL) {
00058 printf("No devices.\n");
00059 exit (0);
00060 }
00061
00062
00063 playlists = LIBMTP_Get_Playlist_List(device);
00064 if (playlists == NULL) {
00065 printf("No playlists.\n");
00066 } else {
00067 LIBMTP_playlist_t *pl, *tmp;
00068 pl = playlists;
00069 while (pl != NULL) {
00070 dump_plinfo(device, pl);
00071 tmp = pl;
00072 pl = pl->next;
00073 LIBMTP_destroy_playlist_t(tmp);
00074 }
00075 }
00076
00077 LIBMTP_Release_Device(device);
00078 printf("OK.\n");
00079 exit (0);
00080 }