mirror of
https://github.com/morpheus65535/bazarr.git
synced 2024-11-14 19:54:38 +08:00
24 lines
757 B
Python
24 lines
757 B
Python
import typing
|
|
|
|
from trakit.config import Config
|
|
from trakit.context import Context
|
|
from trakit.patterns import configure
|
|
|
|
|
|
class TrakItApi:
|
|
|
|
def __init__(self, config: typing.Optional[typing.Mapping[str, typing.Any]] = None):
|
|
self.rebulk = configure(Config(config))
|
|
|
|
def trakit(self, string: str, options: typing.Optional[typing.Mapping[str, typing.Any]] = None):
|
|
"""Return a mapping of extracted information."""
|
|
matches = self.rebulk.matches(string, Context(options))
|
|
guess: typing.Mapping[str, typing.Any] = matches.to_dict()
|
|
return guess
|
|
|
|
|
|
default_api = TrakItApi()
|
|
|
|
|
|
def trakit(string: str, options: typing.Optional[typing.Mapping[str, typing.Any]] = None):
|
|
return default_api.trakit(string, options)
|