コード例 #1
0
ファイル: Controller.cpp プロジェクト: toyners/PodPoacher
int Controller::scanChannel(int channelIndex)
{
  std::vector<PodcastChannel*> channels = storage->getChannels();
  PodcastChannel* originalChannel = channels[channelIndex];

  PodcastChannel* newChannel = createChannelFromFeed(originalChannel->getFeedURL(), originalChannel->getDirectory());

  // Get the number of podcasts to download.
  int podcastCount = 0;
  std::string latestPublishDate = originalChannel->getPodcast(0)->getPublishedDate();
  for (int index = 0; index < newChannel->getPodcastCount(); index++)
  {
    PodcastDetails* podcast = newChannel->getPodcast(index);
    if (latestPublishDate == podcast->getPublishedDate())
    {
      break;
    }

    podcastCount++;
  }

  storage->updateChannel(*originalChannel, *newChannel);

  return podcastCount;
}