def feed(self, limit=None, **kwargs): """ Generate a media rss feed of the latest media :param limit: the max number of results to return. Defaults to 30 """ if request.settings['rss_display'] != 'True': abort(404) response.content_type = content_type_for_response( ['application/rss+xml', 'application/xml', 'text/xml']) media = Media.query.published() if c.category: media = media.in_category(c.category) media_query = media.order_by(Media.publish_on.desc()) media = viewable_media(media_query) if limit is not None: media = media.limit(limit) return dict( media = media, title = u'%s Media' % c.category.name, )
def feed(self, limit=None, **kwargs): """ Generate a media rss feed of the latest media :param limit: the max number of results to return. Defaults to 30 """ if request.settings['rss_display'] != 'True': abort(404) response.content_type = content_type_for_response( ['application/rss+xml', 'application/xml', 'text/xml']) media = Media.query.published() if c.category: media = media.in_category(c.category) media_query = media.order_by(Media.publish_on.desc()) media = viewable_media(media_query) if limit is not None: media = media.limit(limit) return dict( media=media, title=u'%s Media' % c.category.name, )
def mrss(self, **kwargs): """Generate a media rss (mRSS) feed of all the sites media.""" if request.settings['sitemaps_display'] != 'True': abort(404) response.content_type = content_type_for_response( ['application/rss+xml', 'application/xml', 'text/xml']) media = viewable_media(Media.query.published()) return dict( media=media, title='MediaRSS Sitemap', )
def mrss(self, **kwargs): """Generate a media rss (mRSS) feed of all the sites media.""" if request.settings['sitemaps_display'] != 'True': abort(404) response.content_type = content_type_for_response( ['application/rss+xml', 'application/xml', 'text/xml']) media = viewable_media(Media.query.published()) return dict( media = media, title = 'MediaRSS Sitemap', )
def google(self, page=None, limit=10000, **kwargs): """Generate a sitemap which contains googles Video Sitemap information. This action may return a <sitemapindex> or a <urlset>, depending on how many media items are in the database, and the values of the page and limit params. :param page: Page number, defaults to 1. :type page: int :param page: max records to display on page, defaults to 10000. :type page: int """ if request.settings['sitemaps_display'] != 'True': abort(404) response.content_type = \ content_type_for_response(['application/xml', 'text/xml']) media = viewable_media(Media.query.published()) if page is None: if media.count() > limit: return dict(pages=math.ceil(media.count() / float(limit))) else: page = int(page) media = media.offset(page * limit).limit(limit) if page: links = [] else: links = [ url_for(controller='/', qualified=True), url_for(controller='/media', show='popular', qualified=True), url_for(controller='/media', show='latest', qualified=True), url_for(controller='/categories', qualified=True), ] return dict( media = media, page = page, links = links, )
def latest(self, limit=None, skip=0, **kwargs): """Generate a media rss (mRSS) feed of all the sites media.""" if request.settings['rss_display'] != 'True': abort(404) response.content_type = content_type_for_response( ['application/rss+xml', 'application/xml', 'text/xml']) media_query = Media.query.published().order_by(Media.publish_on.desc()) media = viewable_media(media_query) if limit is not None: media = media.limit(limit) if skip > 0: media = media.offset(skip) return dict( media = media, title = 'Latest Media', )
def feed(self, slug, limit=None, **kwargs): """Serve the feed as RSS 2.0. If :attr:`~mediadrop.model.podcasts.Podcast.feedburner_url` is specified for this podcast, we redirect there if the useragent does not contain 'feedburner', as described here: http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=78464 :param feedburner_bypass: If true, the redirect to feedburner is disabled. :rtype: Dict :returns: podcast A :class:`~mediadrop.model.podcasts.Podcast` instance. episodes A list of :class:`~mediadrop.model.media.Media` instances that belong to the ``podcast``. Renders: :data:`podcasts/feed.xml` XML """ podcast = fetch_row(Podcast, slug=slug) if (podcast.feedburner_url and not 'feedburner' in request.environ.get( 'HTTP_USER_AGENT', '').lower() and not kwargs.get('feedburner_bypass', False)): redirect(podcast.feedburner_url.encode('utf-8')) response.content_type = content_type_for_response( ['application/rss+xml', 'application/xml', 'text/xml']) episode_query = podcast.media.published().order_by( Media.publish_on.desc()) episodes = viewable_media(episode_query) if limit is not None: episodes = episodes.limit(limit) return dict( podcast=podcast, episodes=episodes, )
def feed(self, slug, limit=None, **kwargs): """Serve the feed as RSS 2.0. If :attr:`~mediadrop.model.podcasts.Podcast.feedburner_url` is specified for this podcast, we redirect there if the useragent does not contain 'feedburner', as described here: http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=78464 :param feedburner_bypass: If true, the redirect to feedburner is disabled. :rtype: Dict :returns: podcast A :class:`~mediadrop.model.podcasts.Podcast` instance. episodes A list of :class:`~mediadrop.model.media.Media` instances that belong to the ``podcast``. Renders: :data:`podcasts/feed.xml` XML """ podcast = fetch_row(Podcast, slug=slug) if (podcast.feedburner_url and not 'feedburner' in request.environ.get('HTTP_USER_AGENT', '').lower() and not kwargs.get('feedburner_bypass', False)): redirect(podcast.feedburner_url.encode('utf-8')) response.content_type = content_type_for_response( ['application/rss+xml', 'application/xml', 'text/xml']) episode_query = podcast.media.published().order_by(Media.publish_on.desc()) episodes = viewable_media(episode_query) if limit is not None: episodes = episodes.limit(limit) return dict( podcast = podcast, episodes = episodes, )