<commit_before>import os

from kubrick.datasources import Datasource

import kaa.metadata


class MediainfosDatasource(Datasource):

    def attach(self, movie_hash, movie):
        filename = os.path.join(self.tree, '.kub', 'movies', movie_hash)
        infos = kaa.metadata.parse(filename)
        if infos is None:
            return movie

        movie['container'] = infos['type']

        # Set the quality of the video depending on its definition:
        if infos.video[0].width < 1280:
            movie['quality'] = 'SD'
        elif 1280 <= infos.video[0].width < 1920:
            movie['quality'] = '720p'
        else:
            movie['quality'] = '1080p'

        # Set the file extension depending on its mimetype:
        movie['ext'] = infos['mime'].split('/')[-1]

        # Set the movie length (in minutes)
        movie['runtime'] = int(infos['length'] / 60)

        return movie
<commit_msg>Added a strip on the media type (mediainfo datasource)<commit_after>import os

from kubrick.datasources import Datasource

import kaa.metadata


class MediainfosDatasource(Datasource):

    def attach(self, movie_hash, movie):
        filename = os.path.join(self.tree, '.kub', 'movies', movie_hash)
        infos = kaa.metadata.parse(filename)
        if infos is None:
            return movie

        movie['container'] = infos['type'].strip()

        # Set the quality of the video depending on its definition:
        if infos.video[0].width < 1280:
            movie['quality'] = 'SD'
        elif 1280 <= infos.video[0].width < 1920:
            movie['quality'] = '720p'
        else:
            movie['quality'] = '1080p'

        # Set the file extension depending on its mimetype:
        movie['ext'] = infos['mime'].split('/')[-1]

        # Set the movie length (in minutes)
        movie['runtime'] = int(infos['length'] / 60)

        return movie

{'fraction_non_alphanumeric': 0.1246684350132626, 'fraction_numerical': 0.02546419098143236, 'mean_word_length': 2.4166666666666665, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6625355', 'n_tokens_mistral': 609, 'n_tokens_neox': 552, 'n_words': 156}