猜猜-从视频文件名猜猜信息的库。
guessit的Python项目详细描述
猜猜看
猜想这是一个python库,它从视频文件名中提取尽可能多的信息。
它有一个非常强大的匹配器,只允许使用文件名猜测视频的属性。 此匹配器可用于电影和电视节目集。
例如,猜测可以执行以下操作:
$ guessit "Treme.1x03.Right.Place,.Wrong.Time.HDTV.XviD-NoTV.avi" For: Treme.1x03.Right.Place,.Wrong.Time.HDTV.XviD-NoTV.avi GuessIt found: { "title": "Treme", "season": 1, "episode": 3, "episode_title": "Right Place, Wrong Time", "source": "HDTV", "video_codec": "Xvid", "release_group": "NoTV", "container": "avi", "mimetype": "video/x-msvideo", "type": "episode" }
有关更多信息,请访问 readthedocs
迁移说明
猜测2是从头重写的。猜测它现在只是一个版本名解析器,并且支持 诸如哈希计算之类的功能已被删除。
要从猜测 0.x 或 1.x 迁移到猜测2.x,请阅读 迁移.rst
要从guessit 2.x 迁移到 3.x ,请阅读
用法
我猜可以从命令行使用:
$ guessit usage: guessit [-h] [-t TYPE] [-n] [-Y] [-D] [-L ALLOWED_LANGUAGES] [-C ALLOWED_COUNTRIES] [-E] [-T EXPECTED_TITLE] [-G EXPECTED_GROUP] [--includes INCLUDES] [--excludes EXCLUDES] [-f INPUT_FILE] [-v] [-P SHOW_PROPERTY] [-a] [-s] [-l] [-j] [-y] [-c CONFIG] [--no-user-config] [--no-default-config] [-p] [-V] [--version] [filename [filename ...]] positional arguments: filename Filename or release name to guess optional arguments: -h, --help show this help message and exit Naming: -t TYPE, --type TYPE The suggested file type: movie, episode. If undefined, type will be guessed. -n, --name-only Parse files as name only, considering "/" and "\" like other separators. -Y, --date-year-first If short date is found, consider the first digits as the year. -D, --date-day-first If short date is found, consider the second digits as the day. -L ALLOWED_LANGUAGES, --allowed-languages ALLOWED_LANGUAGES Allowed language (can be used multiple times) -C ALLOWED_COUNTRIES, --allowed-countries ALLOWED_COUNTRIES Allowed country (can be used multiple times) -E, --episode-prefer-number Guess "serie.213.avi" as the episode 213. Without this option, it will be guessed as season 2, episode 13 -T EXPECTED_TITLE, --expected-title EXPECTED_TITLE Expected title to parse (can be used multiple times) -G EXPECTED_GROUP, --expected-group EXPECTED_GROUP Expected release group (can be used multiple times) --includes INCLUDES List of properties to be detected --excludes EXCLUDES List of properties to be ignored Input: -f INPUT_FILE, --input-file INPUT_FILE Read filenames from an input text file. File should use UTF-8 charset. Output: -v, --verbose Display debug output -P SHOW_PROPERTY, --show-property SHOW_PROPERTY Display the value of a single property (title, series, video_codec, year, ...) -a, --advanced Display advanced information for filename guesses, as json output -s, --single-value Keep only first value found for each property -l, --enforce-list Wrap each found value in a list even when property has a single value -j, --json Display information for filename guesses as json output -y, --yaml Display information for filename guesses as yaml output Configuration: -c CONFIG, --config CONFIG Filepath to configuration file. Configuration file contains the same options as those from command line options, but option names have "-" characters replaced with "_". This configuration will be merged with default and user configuration files. --no-user-config Disable user configuration. If not defined, guessit tries to read configuration files at ~/.guessit/options.(json|yml|yaml) and ~/.config/guessit/options.(json|yml|yaml) --no-default-config Disable default configuration. This should be done only if you are providing a full configuration through user configuration or --config option. If no "advanced_config" is provided by another configuration file, it will still be loaded from default configuration. Information: -p, --properties Display properties that can be guessed. -V, --values Display property values that can be guessed. --version Display the guessit version.
它还可以用作python模块:
>>> from guessit import guessit >>> guessit('Treme.1x03.Right.Place,.Wrong.Time.HDTV.XviD-NoTV.avi') MatchesDict([('title', 'Treme'), ('season', 1), ('episode', 3), ('episode_title', 'Right Place, Wrong Time'), ('source', 'HDTV'), ('video_codec', 'Xvid'), ('release_group', 'NoTV'), ('container', 'avi'), ('mimetype', 'video/x-msvideo'), ('type', 'episode')])
matches dict 是一个保持匹配顺序的dict。
命令行选项可以作为dict或string指定给第二个参数。
码头工人
猜测功能也可以在Docker Hub上作为Docker图像使用。
$ docker run -it guessit/guessit "Treme.1x03.Right.Place,.Wrong.Time.HDTV.XviD-NoTV.avi" For: Treme.1x03.Right.Place,.Wrong.Time.HDTV.XviD-NoTV.avi GuessIt found: { "title": "Treme", "season": 1, "episode": 3, "episode_title": "Right Place, Wrong Time", "source": "HDTV", "video_codec": "Xvid", "release_group": "NoTV", "container": "avi", "mimetype": "video/x-msvideo", "type": "episode" }
支持
该项目位于github上。如果你认为自己 在猜测中发现错误或遗漏了某些内容。
猜测依赖于模式和规则注册的rebuild项目。