Exemple #1
0
class VideoFeed(DjangoplicityArchiveFeed):
    """
    Implementation for Video Feeds. See Meta class definition for settings.


    # extract_items
    >> videoFeed = VideoFeed()
    >> VideoFeed.items()

    """
    title = feedsconf.get('VideoPodcastFeedSettings', 'title')
    link = feedsconf.get('VideoPodcastFeedSettings', 'link')
    description = feedsconf.get('VideoPodcastFeedSettings', 'description')
    title_template = 'feeds/video_title.html'

    class Meta(DjangoplicityArchiveFeed.Meta):
        model = Video
        options = VideoOptions
        latest_fieldname = Video.Archive.Meta.release_date_fieldname
        enclosure_resources = feedsconf.get('VideoPodcastFeedSettings',
                                            'enclosure_resources')

        enclosure_mimetype = 'video/x-m4v'
        default_query = VideoOptions.Queries.default
        category_query = VideoOptions.Queries.category
        items_to_display = 25

        external_feed_url = None
Exemple #2
0
class Top100Feed(ImageFeed):
    title = feedsconf.get('Top100FeedSettings', 'title', 'Top 100 Images')
    link = feedsconf.get('Top100FeedSettings', 'link', '/')
    description = feedsconf.get('Top100FeedSettings', 'description',
                                'Top 100 Feed')

    class Meta(DjangoplicityArchiveFeed.Meta):
        model = Image
        options = ImageOptions
        latest_fieldname = Image.Archive.Meta.release_date_fieldname
        enclosure_resources = {
            '': 'resource_screen',
            'screen': 'resource_screen',
        }
        default_query = ImageOptions.Queries.top100
        category_query = None
        items_to_display = 100
        external_feed_url = None

    def items(self, obj):
        """
        Returns the feed's items based on the obj returned by get_object
        """
        qs, dummy = self.Meta.default_query.queryset(self.Meta.model,
                                                     self.Meta.options,
                                                     None,
                                                     stringparam=self.category)
        return qs[:self.Meta.items_to_display]
Exemple #3
0
class ScienceAnnouncementFeed(DjangoplicityArchiveFeed):
    title = feedsconf.get('ScienceAnnouncementFeedSettings', 'title',
                          'Science Announcements')
    link = feedsconf.get('ScienceAnnouncementFeedSettings', 'link', '/')
    description = feedsconf.get('ScienceAnnouncementFeedSettings',
                                'description', '')

    def item_enclosure_mime_type(self, item):
        return 'image/jpeg'

    class Meta(DjangoplicityArchiveFeed.Meta):
        model = ScienceAnnouncement
        options = ScienceAnnouncementOptions
        latest_fieldname = ScienceAnnouncement.Archive.Meta.release_date_fieldname
        enclosure_resources = {'': 'resource_screen'}
        default_query = ScienceAnnouncementOptions.Queries.default
Exemple #4
0
class ImageFeed(DjangoplicityArchiveFeed):
    title = feedsconf.get('ImageFeedSettings', 'title', 'Images')
    link = feedsconf.get('ImageFeedSettings', 'link', '/')
    description = feedsconf.get('ImageFeedSettings', 'description',
                                'Images Feed')

    class Meta(DjangoplicityArchiveFeed.Meta):
        model = Image
        options = ImageOptions
        latest_fieldname = Image.Archive.Meta.release_date_fieldname
        enclosure_resources = {
            '': 'resource_screen',
            'screen': 'resource_screen',
        }
        default_query = ImageOptions.Queries.default
        category_query = ImageOptions.Queries.category
        extra_query = ImageOptions.Queries.top100
        external_feed_url = None
Exemple #5
0
class WebUpdateFeed(DjangoplicityArchiveFeed):
    title = feedsconf.get('WebUpdateFeedSettings', 'title', 'Web Updates')
    link = feedsconf.get('WebUpdateFeedSettings', 'link', '/')
    description = feedsconf.get('WebUpdateFeedSettings', 'description', '')
    description_template = 'feeds/description.html'
    override_guids = feedsconf.get('WebUpdateFeedSettings', 'override_guids',
                                   {})

    class Meta(DjangoplicityArchiveFeed.Meta):
        model = WebUpdate
        options = WebUpdateOptions
        latest_fieldname = WebUpdate.Archive.Meta.release_date_fieldname
        enclosure_resources = {'': 'resource_screen'}
        default_query = WebUpdateOptions.Queries.default
        category_query = None
        items_to_display = 10
        archive_query = "default"
        external_feed_url = feedsconf.get('WebUpdateFeedSettings',
                                          'external_feed_url', None)
Exemple #6
0
 class Meta(DjangoplicityArchiveFeed.Meta):
     model = WebUpdate
     options = WebUpdateOptions
     latest_fieldname = WebUpdate.Archive.Meta.release_date_fieldname
     enclosure_resources = {'': 'resource_screen'}
     default_query = WebUpdateOptions.Queries.default
     category_query = None
     items_to_display = 10
     archive_query = "default"
     external_feed_url = feedsconf.get('WebUpdateFeedSettings',
                                       'external_feed_url', None)
Exemple #7
0
 class Meta(DjangoplicityArchiveFeed.Meta):
     model = PictureOfTheWeek
     options = PictureOfTheWeekOptions
     latest_fieldname = PictureOfTheWeek.Archive.Meta.release_date_fieldname
     enclosure_resources = {'': 'resource_hd_and_apple'}
     enclosure_mimetype = 'video/x-m4v'
     default_query = PictureOfTheWeekOptions.Queries.default
     category_query = None
     items_to_display = 25
     external_feed_url = feedsconf.get('PictureOfTheWeekFeedSettings',
                                       'external_feed_url', None)
Exemple #8
0
class AnnouncementFeed(DjangoplicityArchiveFeed):
    title = feedsconf.get('AnnouncementFeedSettings', 'title', 'Announcements')
    link = feedsconf.get('AnnouncementFeedSettings', 'link', '/')
    description = feedsconf.get('AnnouncementFeedSettings', 'description', '')
    description_template = 'feeds/announcement_description.html'
    override_guids = feedsconf.get('AnnouncementFeedSettings',
                                   'override_guids', {})

    def item_enclosure_mime_type(self, item):
        return 'image/jpeg'

    class Meta(DjangoplicityArchiveFeed.Meta):
        model = Announcement
        options = AnnouncementOptions
        latest_fieldname = Announcement.Archive.Meta.release_date_fieldname
        enclosure_resources = {'': 'resource_screen'}
        default_query = AnnouncementOptions.Queries.default
        category_query = None
        items_to_display = 10
        archive_query = "default"
        external_feed_url = feedsconf.get('AnnouncementFeedSettings',
                                          'external_feed_url', None)
Exemple #9
0
    class Meta(DjangoplicityArchiveFeed.Meta):
        model = Video
        options = VideoOptions
        latest_fieldname = Video.Archive.Meta.release_date_fieldname
        enclosure_resources = feedsconf.get('VideoPodcastFeedSettings',
                                            'enclosure_resources')

        enclosure_mimetype = 'video/x-m4v'
        default_query = VideoOptions.Queries.default
        category_query = VideoOptions.Queries.category
        items_to_display = 25

        external_feed_url = None
Exemple #10
0
class ReleaseFeed(DjangoplicityArchiveFeed):
    title = feedsconf.get('ReleaseFeedSettings', 'title', 'News')
    link = feedsconf.get('ReleaseFeedSettings', 'link', '/')
    description = feedsconf.get('ReleaseFeedSettings', 'description', 'News')
    override_guids = feedsconf.get('ReleaseFeedSettings', 'override_guids', {})
    title_template = feedsconf.get('ReleaseFeedSettings', 'title_template',
                                   'feeds/release_title.html')
    description_template = feedsconf.get('ReleaseFeedSettings',
                                         'description_template',
                                         'feeds/release_description.html')

    class Meta(DjangoplicityArchiveFeed.Meta):
        model = Release
        options = ReleaseOptions
        latest_fieldname = Release.Archive.Meta.release_date_fieldname
        enclosure_resources = {'': 'resource_screen'}
        default_query = ReleaseOptions.Queries.default
        category_query = None
        items_to_display = 10
        archive_query = "default"
        external_feed_url = feedsconf.get('ReleaseFeedSettings',
                                          'external_feed_url', None)

    def item_pubdate(self, item):
        """
        Takes an news item, as returned by items(), and returns the news'
        release date.
        """
        return item.release_date

    def item_enclosure_url(self, item):
        """
        Use main image for press release as enclosure.
        """
        im = item.main_image
        if im and im.resource_screen:
            return im.resource_screen.absolute_url
        else:
            return None

    def item_enclosure_mime_type(self, item):
        return 'image/jpeg'
Exemple #11
0
class VideoPodcastFeed(VideoFeed):
    """
    Extends the Feed class VideoFeed to provide for podcast-specific
    elements e.g. those used by iTunes and Adobe Media Player
    """
    title = feedsconf.get('VideoPodcastFeedSettings', 'title',
                          'Video Podcast Feed')
    link = feedsconf.get('VideoPodcastFeedSettings', 'link', '/')
    description = feedsconf.get('VideoPodcastFeedSettings', 'description',
                                'Video Podcast Feed')

    override_guids = feedsconf.get('VideoPodcastFeedSettings',
                                   'override_guids', {})
    override_guids_format = feedsconf.get('VideoPodcastFeedSettings',
                                          'override_guids_format', {})

    feed_type = VideoPodcastFeedGen
    header_template = None
    footer_template = None

    description_template = 'feeds/video_description.html'

    def item_extra_kwargs(self, item):
        """
        Returns a dict with extra keywords needed for each item in the RSS feed
        """
        if self.feed_type != VideoPodcastFeedGen:
            return {}

        dict = {
            'itunes:author':
            item.creator,
            'itunes:subtitle':
            strip_tags(item.headline)[:250] if item.headline else '',
            'itunes:summary':
            strip_tags(item.headline) if item.headline else '',
            'itunes:explicit':
            'No',
            'itunes:keywords':
            item.keywords if hasattr(item, 'keywords') else '',
            'media:thumbnail': {
                u"url":
                "https://%s%s" %
                (Site.objects.get_current().domain, item.resource_thumb.url)
                if item.resource_thumb else ''
            },
        }

        # parse H:m:s:ff format to seconds
        dict['itunes:duration'] = ''
        if item.file_duration:
            try:
                dict['itunes:duration'] = str(
                    timestring_to_seconds(item.file_duration))
            except ValueError:
                pass

        return dict

    def feed_extra_kwargs(self, obj):
        """
        Returns a dict with extra keywords needed for the root of the RSS feed
        """

        dict = {}

        if hasattr(self, 'header_template'):
            dict['header_template'] = self.header_template

        if hasattr(self, 'footer_template'):
            dict['footer_template'] = self.footer_template

        if hasattr(self, 'format'):
            dict['format'] = self.format

        return dict
Exemple #12
0
class PictureOfTheWeekFeed(DjangoplicityArchiveFeed):
    title = feedsconf.get('PictureOfTheWeekFeedSettings', 'title',
                          'Picture of The Week')
    link = feedsconf.get('PictureOfTheWeekFeedSettings', 'link', '/')
    description = feedsconf.get('PictureOfTheWeekFeedSettings', 'description',
                                'Picture of The Week Feed')

    title_template = 'feeds/potw_title.html'
    description_template = 'feeds/potw_description.html'

    class Meta(DjangoplicityArchiveFeed.Meta):
        model = PictureOfTheWeek
        options = PictureOfTheWeekOptions
        latest_fieldname = PictureOfTheWeek.Archive.Meta.release_date_fieldname
        enclosure_resources = {'': 'resource_hd_and_apple'}
        enclosure_mimetype = 'video/x-m4v'
        default_query = PictureOfTheWeekOptions.Queries.default
        category_query = None
        items_to_display = 25
        external_feed_url = feedsconf.get('PictureOfTheWeekFeedSettings',
                                          'external_feed_url', None)

    def item_title(self, item):
        if item.image:
            return item.image.title
        elif item.video:
            return item.video.title
        else:
            return None

    def item_pubdate(self, item):
        """
        Takes an news item, as returned by items(), and returns the news'
        release date.
        """
        return item.release_date

    def item_enclosure_url(self, item):
        if item.image:
            im = item.image
            if im.resource_screen:
                return im.resource_screen.absolute_url
            else:
                return None
        if item.comparison:
            im = item.comparison
            if im.resource_screen:
                return "https://%s%s" % (Site.objects.get_current().domain,
                                         im.resource_screen.url)
            else:
                return None
        elif item.video:
            vi = item.video
            #TODO: include in settings
            if vi.resource_hd_and_apple:
                return "https://%s%s" % (Site.objects.get_current().domain,
                                         vi.resource_hd_and_apple.url)
            elif vi.resource_hd720p_screen:
                return "https://%s%s" % (Site.objects.get_current().domain,
                                         vi.resource_hd720p_screen.url)

            else:
                return None

    def item_enclosure_length(self, item):
        if item.image:
            im = item.image
            if im.resource_screen:
                return int(im.resource_screen.size)
            else:
                return None
        elif item.video:
            vi = item.video
            if vi.resource_hd_and_apple:
                return int(vi.resource_hd_and_apple.size)
            else:
                return None

    def item_enclosure_mime_type(self, item):
        if item.image:
            return 'image/jpeg'
        elif item.video:
            return 'video/x-m4v'