def search_podcasts(q): if is_url(q): url = normalize_feed_url(q) try: podcast = Podcast.objects.get(urls__url=url) except Podcast.DoesNotExist: podcast = None updater = PodcastUpdater(url) if not podcast or not podcast.title: try: updater.update_podcast() except NoPodcastCreated as npc: return [] try: podcast = Podcast.objects.get(urls__url=url) return [podcast] except Podcast.DoesNotExist: return [] return search(q)
def post(self, request): user = request.user feed = FavoriteFeed(user) site = RequestSite(request) feed_url = feed.get_public_url(site.domain) podcast = Podcast.objects.get_or_create_for_url(feed_url).object PublishedPodcast.objects.get_or_create(podcast=podcast, publisher=user) updater = PodcastUpdater(feed_url) updater.update_podcast() return HttpResponseRedirect(reverse('share-favorites'))