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