Esempio n. 1
0
def example_podcasts(request, format):

    podcasts = cache.get('example-podcasts', None)

    try:
        scale = int(request.GET.get('scale_logo', 64))
    except (TypeError, ValueError):
        return HttpResponseBadRequest('scale_logo has to be a numeric value')

    if scale not in range(1, 257):
        return HttpResponseBadRequest('scale_logo has to be a number from 1 to 256')


    if not podcasts:

        try:
            examples = ExamplePodcasts.get('example_podcasts')
            ids = examples.podcast_ids
            podcasts = podcasts_by_id(ids)
            cache.set('example-podcasts', podcasts)

        except ResourceNotFound:
            podcasts = []

    title = 'gPodder Podcast Directory'
    domain = RequestSite(request).domain
    p_data = lambda p: podcast_data(p, domain, scale)
    return format_podcast_list(
            podcasts,
            format,
            title,
            json_map=p_data,
            xml_template='podcasts.xml',
            request=request,
        )
Esempio n. 2
0
    def handle(self, *args, **options):

        urls = list(map(str.strip, fileinput.input(args)))

        try:
            examples = ExamplePodcasts.get(EXAMPLES_DOCID)
        except ResourceNotFound:
            examples = ExamplePodcasts()
            examples._id = EXAMPLES_DOCID

        podcasts = filter(None, [Podcast.for_url(url) for url in urls])
        examples.podcast_ids = [podcast.get_id() for podcast in podcasts]
        examples.updated = datetime.utcnow()
        examples.save()