void PodcastInfoWidget::SetPodcast(const Podcast& podcast) {
  if (image_id_) {
    app_->album_cover_loader()->CancelTask(image_id_);
    image_id_ = 0;
  }

  podcast_ = podcast;

  if (podcast.ImageUrlLarge().isValid()) {
    // Start loading an image for this item.
    image_id_ = app_->album_cover_loader()->LoadImageAsync(
          cover_options_, podcast.ImageUrlLarge().toString(), QString());
  }

  ui_->image->hide();

  SetText(podcast.title(), ui_->title);
  SetText(podcast.description(), ui_->description);
  SetText(podcast.copyright(), ui_->copyright, ui_->copyright_label);
  SetText(podcast.author(), ui_->author, ui_->author_label);
  SetText(podcast.owner_name(), ui_->owner, ui_->owner_label);
  SetText(podcast.link().toString(), ui_->website, ui_->website_label);
  SetText(podcast.extra("gpodder:subscribers").toString(), ui_->subscribers, ui_->subscribers_label);

  if (!image_id_) {
    emit LoadingFinished();
  }
}
Song PodcastEpisode::ToSong(const Podcast& podcast) const {
  Song ret;
  ret.set_valid(true);
  ret.set_title(title().simplified());
  ret.set_artist(author().simplified());
  ret.set_length_nanosec(kNsecPerSec * duration_secs());
  ret.set_year(publication_date().date().year());
  ret.set_comment(description());

  if (downloaded() && QFile::exists(local_url().toLocalFile())) {
    ret.set_url(local_url());
  } else {
    ret.set_url(url());
  }

  ret.set_basefilename(QFileInfo(ret.url().path()).fileName());

  // Use information from the podcast if it's set
  if (podcast.is_valid()) {
    ret.set_album(podcast.title().simplified());
    ret.set_art_automatic(podcast.ImageUrlLarge().toString());

    if (author().isEmpty()) ret.set_artist(podcast.title().simplified());
  }
  return ret;
}