<commit_before>from django.db import models
from django.contrib.staticfiles import finders


class Video(models.Model):
    annotation = models.TextField(blank=True)
    source = models.CharField(max_length=1048, blank=True)
    filename = models.CharField(max_length=100, blank=True, unique=True)
    image_list = models.TextField(blank=True)
    host = models.CharField(max_length=1048, blank=True)
    verified = models.BooleanField(default=False)

    @classmethod
    def from_list(cls, path_to_list, *, source, host, filename_prefix=''):
        created = []
        for line in open(path_to_list, 'r'):
            if line:
                video = cls(source=source, filename=filename_prefix + line.strip(), host=host)
                video.save()
                created.append(video)
        return created

    def __str__(self):
        return '/video/{}'.format(self.id)

    @property
    def url(self):
        if finders.find('videos/{}.mp4'.format(self.id)):
            return '/static/videos/{}.mp4'.format(self.id)
        elif self.image_list:
            return 'Image List'
        elif self.filename and self.host:
            return self.host
        else:
            raise Exception('Video {0} does not have a filename, host or image_list. Possible fixes: \n1) Place {0}.mp4 into static/videos to serve locally. \n2) Update the filename & host fields of the Video with id={0}'.format(self.id)) + self.filename

    def count_keyframes(self, at_time=None):
        if at_time is None:<commit_msg>fixed video loading<commit_after>from django.db import models
from django.contrib.staticfiles import finders


class Video(models.Model):
    annotation = models.TextField(blank=True)
    source = models.CharField(max_length=1048, blank=True)
    filename = models.CharField(max_length=100, blank=True, unique=True)
    image_list = models.TextField(blank=True)
    host = models.CharField(max_length=1048, blank=True)
    verified = models.BooleanField(default=False)

    @classmethod
    def from_list(cls, path_to_list, *, source, host, filename_prefix=''):
        created = []
        for line in open(path_to_list, 'r'):
            if line:
                video = cls(source=source, filename=filename_prefix + line.strip(), host=host)
                video.save()
                created.append(video)
        return created

    def __str__(self):
        return '/video/{}'.format(self.id)

    @property
    def url(self):
        if finders.find('videos/{}.mp4'.format(self.id)):
            return '/static/videos/{}.mp4'.format(self.id)
        elif self.image_list:
            return 'Image List'
        elif self.filename and self.host:
            return self.host + self.filename
        else:
            raise Exception('Video {0} does not have a filename, host or image_list. Possible fixes: \n1) Place {0}.mp4 into static/videos to serve locally. \n2) Update the filename & host fields of the Video with id={0}'.format(self.id)) + self.filename

    def count_keyframes(self, at_time=None):
        if at_time is None:
{'fraction_non_alphanumeric': 0.11488250652741515, 'fraction_numerical': 0.012402088772845953, 'mean_word_length': 2.80272952853598, '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': '5788538', 'n_tokens_mistral': 929, 'n_tokens_neox': 892, 'n_words': 228}