How to use the guessit.u function in guessit

To help you get started, we’ve selected a few guessit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github caronc / nzb-subliminal / Subliminal / guessit / guess.py View on Github external
def to_dict(self, advanced=False):
        """Return the guess as a dict containing only base types, ie:
        where dates, languages, countries, etc. are converted to strings.

        if advanced is True, return the data as a json string containing
        also the raw information of the properties."""
        data = dict(self)
        for prop, value in data.items():
            if isinstance(value, datetime.date):
                data[prop] = value.isoformat()
            elif isinstance(value, (UnicodeMixin, base_text_type)):
                data[prop] = u(value)
            elif isinstance(value, (Language, Country)):
                data[prop] = value.guessit
            elif isinstance(value, list):
                data[prop] = [u(x) for x in value]
            if advanced:
                metadata = self.metadata(prop)
                prop_data = {'value': data[prop]}
                if metadata.raw:
                    prop_data['raw'] = metadata.raw
                if metadata.confidence:
                    prop_data['confidence'] = metadata.confidence
                data[prop] = prop_data

        return data
github CouchPotato / CouchPotatoServer / libs / guessit / __main__.py View on Github external
def detect_filename(filename, filetype, info=['filename'], advanced = False):
    filename = u(filename)

    print('For:', filename)
    print('GuessIt found:', guess_file_info(filename, filetype, info).nice_string(advanced))
github pymedusa / Medusa / lib / guessit / __main__.py View on Github external
def guess_file(filename, info='filename', options=None, **kwargs):
    options = options or {}
    filename = u(filename)

    if not options.get('yaml') and not options.get('show_property'):
        print('For:', filename)
    guess = guess_file_info(filename, info, options, **kwargs)

    if not options.get('unidentified'):
        try:
            del guess['unidentified']
        except KeyError:
            pass

    if options.get('show_property'):
        print(guess.get(options.get('show_property'), ''))
        return

    if options.get('yaml'):
github CouchPotato / CouchPotatoServer / libs / guessit / guess.py View on Github external
def to_dict(self, advanced=False):
        data = dict(self)
        for prop, value in data.items():
            if isinstance(value, datetime.date):
                data[prop] = value.isoformat()
            elif isinstance(value, (Language, Country, base_text_type)):
                data[prop] = u(value)
            elif isinstance(value, list):
                data[prop] = [u(x) for x in value]
            if advanced:
                data[prop] = {"value": data[prop], "raw": self.raw(prop), "confidence": self.confidence(prop)}

        return data
github nzbget / VideoSort / lib / guessit / guess.py View on Github external
def __unicode__(self):
        return u(self.to_dict())
github nzbget / VideoSort / lib / guessit / __main__.py View on Github external
def guess_file(filename, info='filename', options=None, **kwargs):
    options = options or {}
    filename = u(filename)

    if not options.get('yaml') and not options.get('show_property'):
        print('For:', filename)
    guess = guess_file_info(filename, info, options, **kwargs)

    if not options.get('unidentified'):
        try:
            del guess['unidentified']
        except KeyError:
            pass

    if options.get('show_property'):
        print (guess.get(options.get('show_property'), ''))
        return

    if options.get('yaml'):
github CouchPotato / CouchPotatoServer / libs / guessit / fileutils.py View on Github external
def load_file_in_same_dir(ref_file, filename):
    """Load a given file. Works even when the file is contained inside a zip."""

    from couchpotato.core.helpers.encoding import toUnicode
    path = split_path(toUnicode(ref_file))[:-1] + [filename]

    for i, p in enumerate(path):
        if p.endswith('.zip'):
            zfilename = os.path.join(*path[:i + 1])
            zfile = zipfile.ZipFile(zfilename)
            return zfile.read('/'.join(path[i + 1:]))

    return u(io.open(os.path.join(*path), encoding='utf-8').read())
github h3llrais3r / Auto-Subliminal / lib / guessit / guess.py View on Github external
def __unicode__(self):
        return u(self.to_dict())
github h3llrais3r / Auto-Subliminal / lib / guessit / guess.py View on Github external
def to_dict(self, advanced=False):
        """Return the guess as a dict containing only base types, ie:
        where dates, languages, countries, etc. are converted to strings.

        if advanced is True, return the data as a json string containing
        also the raw information of the properties."""
        data = dict(self)
        for prop, value in data.items():
            if isinstance(value, datetime.date):
                data[prop] = value.isoformat()
            elif isinstance(value, (UnicodeMixin, base_text_type)):
                data[prop] = u(value)
            elif isinstance(value, (Language, Country)):
                data[prop] = value.guessit
            elif isinstance(value, list):
                data[prop] = [u(x) for x in value]
            if advanced:
                metadata = self.metadata(prop)
                prop_data = {'value': data[prop]}
                if metadata.raw:
                    prop_data['raw'] = metadata.raw
                if metadata.confidence:
                    prop_data['confidence'] = metadata.confidence
                data[prop] = prop_data

        return data
github clinton-hall / nzbToMedia / libs / guessit / matcher.py View on Github external
# split into '-' separated subgroups (with required separator chars
        # around the dash)
        apply_transfo('split_on_dash')

        # 5- try to identify the remaining unknown groups by looking at their
        #    position relative to other known elements
        if mtree.guess['type'] in ('episode', 'episodesubtitle', 'episodeinfo'):
            apply_transfo('guess_episode_info_from_position')
        else:
            apply_transfo('guess_movie_title_from_position')

        # 6- perform some post-processing steps
        apply_transfo('post_process')

        log.debug('Found match tree:\n%s' % u(mtree))