void DownloadAnalyzedSongs_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("Completed DownloadAnalyzedSongs");
}
else
{
if (cat.Items.Count == downloadTake)
{
// There are more songs to download, run again
DownloadSkip++;
}
else
{
// There are no more songs in the remote catalog, but
// we still have unanalyzed songs. Sigh... start
// from the beginning
DownloadSkip = 0;
}
logger.Debug("Download of analyzed songs completed, " +
"will continue to run until all songs analyzed");
DownloadAnalyzedSongsNeedsToRunAgain();
}
}
else
{
logger.Error("Download of analyzed songs failed, retrying");
DownloadAnalyzedSongsNeedsToRunAgain();
}
}