#include #include #include @@ -32,12 +9,6 @@ char error[256], data[256], temp[256], *args[2]; int ret, numTracks, trackNum, i, isMultipleArtist = 0, numDates, albumNum; - if (argc < 2) - { - printf("Usage: getalbum \n"); - exit(0); - } - // Create the musicbrainz object, which will be needed for subsequent calls o = mb_New(); @@ -62,16 +33,29 @@ else mb_SetDepth(o, 4); - // Set up the args for the find album query - args[0] = argv[1]; + ret = mb_Query (o, MBQ_GetCDTOC); + if (!ret) + { + mb_GetQueryError(o, error, 256); + printf("Query failed: %s\n", error); + mb_Delete(o); + return 0; + } + + ret = mb_GetResultData(o, MBE_TOCGetCDIndexId, data, 256); + if (!ret) + { + mb_GetQueryError(o, error, 256); + printf("Query failed: %s\n", error); + mb_Delete(o); + return 0; + } + + args[0] = data; args[1] = NULL; - if (strlen(argv[1]) != MB_CDINDEX_ID_LEN) - // Execute the MB_GetAlbumById query - ret = mb_QueryWithArgs(o, MBQ_GetAlbumById, args); - else - // Execute the MBQ_GetCDInfoFromCDIndexId - ret = mb_QueryWithArgs(o, MBQ_GetCDInfoFromCDIndexId, args); + // Execute the MBQ_GetCDInfoFromCDIndexId + ret = mb_QueryWithArgs(o, MBQ_GetCDInfoFromCDIndexId, args); if (!ret) {