void DownloadAnalyzedSongsAlreadyInRemoteCatalog_CatalogReadCompleted(
object sender, EchoNestApiEventArgs e)
{
if (e.Error == null)
{
Catalog cat = (Catalog)e.GetResultData();
if (cat.Items.Count > 0)
{
StoreDownloadedSongs(cat);
}
if (SongsToAnalyze.Count == 0)
{
// Yay, we are done
AllDone = true;
logger.Info("No songs left to analyze, all done");
logger.Info("Completed DownloadAnalyzedSongsAlreadyInRemoteCatalog");
}
else
{
if (cat.Items.Count == downloadTake)
{
// We grabbed a full downloadTake number of items, so
// there must be more items
logger.Debug("Check if songs are already in remote catalog completed, " +
"will run again since extra items are found");
DownloadSkip++;
DownloadAnalyzedSongsAlreadyInRemoteCatalogNeedsToRunAgain();
}
else
{
// Or it could be that we are done with the remote catalog, but we
// still need to analyze some songs that weren't there, so we need
// to go through with the rest of the process
DownloadSkip = 0;
SongsToAnalyzeBatchDownloadReady = true;
logger.Info("Completed DownloadAnalyzedSongsAlreadyInRemoteCatalog");
}
}
}
else
{
logger.Error("Check if songs are already in remote catalog failed, retrying");
DownloadAnalyzedSongsAlreadyInRemoteCatalogNeedsToRunAgain();
}
}