Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
int Controller::indexOfChannelInList(const std::string& feedURL, std::vector<PodcastChannel*>& channels)
{
  for (int i = 0; i < channels.size(); i++)
  {
    PodcastChannel* channel = channels[i];
    if (channel->getFeedURL() == feedURL)
    {
      return i;
    }
  }

  return -1;
}