Пример #1
0
void TopLists::cb_toplistArtistsComplete(sp_toplistbrowse *result,
		void *userdata) {
	Logger::printOut("toplist artists callback");
	TopLists *lists = (TopLists*) (userdata);

	vector<SxArtist*> newArtists;

	for (int index = 0; index < sp_toplistbrowse_num_artists(result); index++) {
		//dont load the albums and tracks for all artists here, it takes forever
		SxArtist* artist = ArtistStore::getInstance()->getArtist(
				sp_toplistbrowse_artist(result, index), false);
		if (artist != NULL)
			newArtists.push_back(artist);
	}

	lists->removeAllArtists();
	lists->m_artists = newArtists;

	struct timeb tmb;
	ftime(&tmb);
	lists->m_artistsNextReload.Set(1000 * 60 * 60 * 24);
	lists->m_waitingForArtists = false;
	lists->m_artistsLoaded = true;
	Logger::printOut("Toplist artists loaded");
}
Пример #2
0
/**
 * Callback for libspotify
 *
 * @param result    The toplist result object that is now done
 * @param userdata  The opaque pointer given to sp_toplistbrowse_create()
 */
static void got_toplist(sp_toplistbrowse *result, void *userdata)
{
	int i;

	// We print from all types. Only one of the loops will acually yield anything.

	for(i = 0; i < sp_toplistbrowse_num_artists(result); i++)
		print_artist(i + 1, sp_toplistbrowse_artist(result, i));

	for(i = 0; i < sp_toplistbrowse_num_albums(result); i++)
		print_album(i + 1, sp_toplistbrowse_album(result, i));

	for(i = 0; i < sp_toplistbrowse_num_tracks(result); i++) {
		printf("%3d: ", i + 1);
		print_track(sp_toplistbrowse_track(result, i));
	}

	sp_toplistbrowse_release(result);
	cmd_done();
}
Пример #3
0
/**
 * Callback for libspotify
 *
 * @param result    The toplist result object that is now done
 * @param userdata  The opaque pointer given to sp_toplistbrowse_create()
 */
static void got_toplist(sp_toplistbrowse *result, void *userdata)
{
	int i;
        json_t *json = json_object();
        json_t *toplist = json_object();

        json_object_set_new(json, "toplist", toplist);
        json_t *results = json_array();
        json_object_set_new(toplist, "result", results);
        // We print from all types. Only one of the loops will acually yield anything.

        for(i = 0; i < sp_toplistbrowse_num_artists(result); i++)
            json_array_append_new(results, get_artist(sp_toplistbrowse_artist(result, i)));

        for(i = 0; i < sp_toplistbrowse_num_albums(result); i++)
            json_array_append_new(results, get_album(sp_toplistbrowse_album(result, i)));

        for(i = 0; i < sp_toplistbrowse_num_tracks(result); i++)
            json_array_append_new(results, get_track(sp_toplistbrowse_track(result, i)));

        cmd_sendresponse(json, 200);
        sp_toplistbrowse_release(result);
        cmd_done();
}