<commit_before>import datetime

from django.contrib.syndication.feeds import Feed
from django.core.urlresolvers import reverse
from django.http import HttpResponse
from django.utils.translation import ugettext as _

from localtv import models
from localtv.decorators import get_sitelocation


FLASH_ENCLOSURE_STATIC_LENGTH = 1

LOCALTV_FEED_LENGTH = 30

class BaseVideosFeed(Feed):
    title_template = "localtv/subsite/feed/title.html"
    description_template = "localtv/subsite/feed/description.html"

    def __init__(self, *args, **kwargs):
        Feed.__init__(self, *args, **kwargs)
        self.sitelocation = models.SiteLocation.objects.get(
            site=models.Site.objects.get_current())

    def item_pubdate(self, video):
        return video.when_approved

    def item_link(self, video):
        return reverse('localtv_view_video', kwargs={'video_id': video.id})

    def item_enclosure_url(self, video):
        if video.file_url:
            return video.file_url
        elif video.flash_enclosure_url:
            return video.flash_enclosure_url

    def item_enclosure_length(self, video):
        if video.file_url:
            return video.file_url_length
        elif video.flash_enclosure_url:<commit_msg>show the thumbnail in the RSS feed<commit_after>import datetime

from django.contrib.syndication.feeds import Feed
from django.core.files.storage import default_storage
from django.core.urlresolvers import reverse
from django.http import HttpResponse
from django.utils import feedgenerator
from django.utils.translation import ugettext as _

from localtv import models

FLASH_ENCLOSURE_STATIC_LENGTH = 1

LOCALTV_FEED_LENGTH = 30

class ThumbnailFeedGenerator(feedgenerator.DefaultFeed):

    def add_item_elements(self, handler, item):
        feedgenerator.DefaultFeed.add_item_elements(self, handler, item)
        if 'thumbnail' in item:
            handler.addQuickElement('thumbnail', item['thumbnail'])


class BaseVideosFeed(Feed):
    title_template = "localtv/subsite/feed/title.html"
    description_template = "localtv/subsite/feed/description.html"
    feed_type = ThumbnailFeedGenerator

    def __init__(self, *args, **kwargs):
        Feed.__init__(self, *args, **kwargs)
        self.sitelocation = models.SiteLocation.objects.get(
            site=models.Site.objects.get_current())

    def item_pubdate(self, video):
        return video.when_approved

    def item_link(self, video):
        return reverse('localtv_view_video', kwargs={'video_id': video.id})

    def item_extra_kwargs(self, item):
        if not item.has_thumbnail:
            return {}
        return {
            'thumbnail': 'http://%s%s' % (
                self.sitelocation.site.domain,
                default_storage.url(
                    item.get_resized_thumb_storage_path(375, 295)))
            }

    def item_enclosure_url(self, video):
        if video.file_url:
            return video.file_url
        elif video.flash_enclosure_url:
            return video.flash_enclosure_url

    def item_enclosure_length(self, video):
        if video.file_url:
            return video.file_url_length
        elif video.flash_enclosure_url:
{'fraction_non_alphanumeric': 0.08364779874213836, 'fraction_numerical': 0.0037735849056603774, 'mean_word_length': 3.2526737967914436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '946342', 'n_tokens_mistral': 964, 'n_tokens_neox': 929, 'n_words': 198}