Esempio n. 1
0
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)
Esempio n. 2
0
    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'))
Esempio n. 3
0
    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'))
Esempio n. 4
0
File: views.py Progetto: fk-lx/mygpo
    def post(self, request):
        user = request.user

        feed = FavoriteFeed(user)
        site = RequestSite(request)
        feed_url = feed.get_public_url(site.domain)

        podcast = podcast_for_url(feed_url, create=True)

        if not podcast.get_id() in user.published_objects:
            user.published_objects.append(podcast.get_id())
            user.save()

        updater = PodcastUpdater()
        updater.update(feed_url)

        return HttpResponseRedirect(reverse('share-favorites'))
Esempio n. 5
0
    def handle(self, *args, **options):

        queue = self.get_podcasts(*args, **options)

        max_podcasts = options.get("max")
        if max_podcasts:
            queue = islice(queue, 0, max_podcasts)

        if options.get("list"):
            for podcast in queue:
                logger.info("Podcast %s", podcast)

        else:
            logger.info("Updating podcasts...")

            updater = PodcastUpdater()
            for podcast in updater.update_queue(queue):
                logger.info("Updated podcast %s", podcast)
Esempio n. 6
0
    def handle(self, *args, **options):

        queue = self.get_podcasts(*args, **options)

        max_podcasts = options.get('max')
        if max_podcasts:
            queue = islice(queue, 0, max_podcasts)

        if options.get('list'):
            for podcast in queue:
                logger.info('Podcast %s', podcast)

        else:
            logger.info('Updating podcasts...')

            updater = PodcastUpdater()
            for podcast in updater.update_queue(queue):
                logger.info('Updated podcast %s', podcast)
Esempio n. 7
0
def search_podcasts(q, limit=20, skip=0):

    if is_url(q):
        url = normalize_feed_url(q)

        podcast = podcast_for_url(url, create=False)

        if not podcast or not podcast.title:

            updater = PodcastUpdater()

            try:
                updater.update(url)
            except NoPodcastCreated as npc:
                return [], 0

        podcast = podcast_for_url(url)
        if podcast:
            return [podcast], 1
        else:
            return [], 0

    return search(q, skip, limit)
Esempio n. 8
0
File: views.py Progetto: fk-lx/mygpo
    def get(self, request):

        site = RequestSite(request)

        # check if we're doing a query
        url = request.GET.get('q', None)

        if not url:
            podcast = None
            can_add = False

        else:
            podcast = podcast_for_url(url)

            # if the podcast does already exist, there's nothing more to do
            if podcast:
                can_add = False

            # check if we could add a podcast for the given URL
            else:
                podcast = False
                updater = PodcastUpdater()

                try:
                    can_add = updater.verify_podcast_url(url)

                except (ParserException, FetchFeedException,
                        NoEpisodesException) as ex:
                    can_add = False
                    messages.error(request, unicode(ex))

        return render(request, 'missing.html', {
                'site': site,
                'q': url,
                'podcast': podcast,
                'can_add': can_add,
            })
Esempio n. 9
0
def update_podcasts(podcast_urls):
    """ Task to update a podcast """
    from mygpo.data.feeddownloader import PodcastUpdater
    updater = PodcastUpdater()
    podcasts = updater.update_queue(podcast_urls)
    return list(podcasts)
Esempio n. 10
0
File: tasks.py Progetto: fk-lx/mygpo
def update_podcasts(podcast_urls):
    """ Task to update a podcast """
    updater = PodcastUpdater()
    podcasts = updater.update_queue(podcast_urls)
    return list(podcasts)