Skip to main content

TorTitle

一个用于从种⼦标题中解析电影、剧集、音乐等信息的 Python 库,支持主标题和副标题的提取。

安装

pip install tortitle

使用方法

解析主标题 (TorTitle)

TorTitle 用于解析种⼦标题,并提取主要信息,例如标题、年份、季数、集数、分辨率等。

基础用法

from tortitle import TorTitle

# 电视剧示例
torrent_name = "The.Mandalorian.S01E01.1080p.WEB-DL.DDP5.1.H.264-NTC"
title = TorTitle(torrent_name)

print(f"标题: {title.title}")           # The Mandalorian
print(f"中文标题: {title.cntitle}")     # (为空)
print(f"类型: {title.type}")            # tv
print(f"季: {title.season}")            # S01
print(f"集: {title.episode}")           # E01
print(f"分辨率: {title.resolution}")    # 1080p
print(f"片源: {title.media_source}")    # webdl
print(f"音频: {title.audio}")           # DDP5.1
print(f"制作组: {title.group}")         # NTC

支持的类型 (type 字段)

  • movie - 电影
  • tv - 电视剧
  • music - 音乐
  • ebook - 电子书
  • other - 其他

字段说明

字段 说明 示例
title 英文或主标题 The Mandalorian
cntitle 中文标题 曼达洛人
year 发行年份 2019
type 内容类型 tvmovie
season 季号(格式化) S01
episode 集号(格式化) E01E01-E05
seasons 季号列表 [1][1, 2, 3]
episodes 集号列表 [1][1, 2, 3, 4, 5]
resolution 分辨率 1080p, 2160p, 720p
media_source 片源类型 webdl, bluray, remux, encode
video 视频编码 H.264, HEVC, x265
audio 音频信息 DDP5.1, TrueHD, DTS-HD MA
group 制作组/发布组 NTC, CMCC
full_season 是否为完整季 TrueFalse

范围格式支持

季和集支持范围格式:

title = TorTitle("[The.Mandalorian].S01E01-E05.(2019).1080p.WEB-DL-GROUP")
print(title.season)    # S01
print(title.episode)   # E01-E05
print(title.episodes)  # [1, 2, 3, 4, 5]

中文标题支持

title = TorTitle("[曼达洛人].The.Mandalorian.S01E01.2019.1080p.WEB-DL-NTb")
print(title.title)     # The Mandalorian
print(title.cntitle)   # 曼达洛人

多种输出格式

torrent_name = "[美国][金钱世界][All.the.Money.in.the.World.2017.1080p.BluRay.x264.DTS.5.1-CMCC]"
title = TorTitle(torrent_name)

# 方式1:逐个访问属性
print(title.title)     # All the Money in the World
print(title.year)      # 2017

# 方式2:获取完整字典
result = title.to_dict()
print(result)
# 输出:
# {
#   'title': 'All the Money in the World',
#   'cntitle': '金钱世界',
#   'year': '2017',
#   'type': 'movie',
#   'season': '',
#   'episode': '',
#   'seasons': [],
#   'episodes': [],
#   'media_source': 'bluray',
#   'video': 'x264',
#   'audio': 'DTS5.1',
#   'group': 'CMCC',
#   'resolution': '1080p',
#   'full_season': False
# }

更多示例

# 电影示例
t1 = TorTitle("Inception.2010.1080p.BluRay.x264-GROUP")
print(t1.type)  # movie
print(t1.year)  # 2010

# 多集电视剧
t2 = TorTitle("Breaking.Bad.S01E01-E10.720p.BluRay.x264-GROUP")
print(t2.season)   # S01
print(t2.episodes) # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# 完整季
t3 = TorTitle("Game.of.Thrones.Season.1.Complete.1080p.BluRay.x264")
print(t3.full_season)  # True

# 音乐
t4 = TorTitle("Artist - Album (2023) [SACD]")
print(t4.type)  # music

# 电子书
t5 = TorTitle("MyBook.epub")
print(t5.type)  # ebook

解析副标题 (TorSubtitle)

TorSubtitle 用于从 PT 站的种⼦副标题中提取可能是标题的信息(这里叫 extitle),以及 season, episode 等。

基础用法

from tortitle import TorSubtitle

torrent_name = "舌尖上的中国 第一季 | 全7集 | 导演: 陈晓卿 | 主演: 李立宏 国语/中字 4K高码版"
subtitle = TorSubtitle(torrent_name)

print(f"标题: {subtitle.extitle}")      # 舌尖上的中国
print(f"季: {subtitle.season}")         # 1
print(f"集: {subtitle.episode}")        # (为空,因为是全季)
print(f"全季: {subtitle.full_season}")  # True

字段说明

字段 说明 示例
extitle 提取的标题 舌尖上的中国
season 季号(整数) 14
episode 集号(格式化) E07E07-E10
total_episodes 总集数 7
full_season 是否为完整季 TrueFalse

详细示例

# 单季单集
sub1 = TorSubtitle("盾之勇者成名录 第四季 | 第07集 | 1080p | 类型: 动画")
print(sub1.extitle)      # 盾之勇者成名录
print(sub1.season)       # 4
print(sub1.episode)      # E07

# 多集范围
sub2 = TorSubtitle("锦月如歌 | 第32-36集 | 4K 杜比视界")
print(sub2.extitle)      # 锦月如歌
print(sub2.episode)      # E32-E36

# 全季
sub3 = TorSubtitle("暗蚀 Andhera 全8集 | 类型: 剧情")
print(sub3.extitle)      # 暗蚀
print(sub3.full_season)  # True
print(sub3.total_episodes)  # 8

# 中英混合
sub4 = TorSubtitle("夜樱家的大作战 | 全27集 | 4K 高码 | 导演: 凑未来")
print(sub4.extitle)      # 夜樱家的大作战
print(sub4.total_episodes)  # 27

# 带 / 分隔的标题(提取第一个)
sub5 = TorSubtitle("坏蛋联盟2 / 大坏蛋2 / 坏家伙2 | 类别:喜剧 动作 动画")
print(sub5.extitle)      # 坏蛋联盟2

多种输出格式

torrent_name = "盾之勇者成名录 / The Rising of the Shield Hero Season 4 第四季 | 第07集 | 1080p | 类型: 动画"
subtitle = TorSubtitle(torrent_name)

# 方式1:逐个访问属性
print(subtitle.extitle)     # 盾之勇者成名录
print(subtitle.season)      # 4

# 方式2:获取完整字典
result = subtitle.to_dict()
print(result)
# 输出:
# {
#   "extitle": "盾之勇者成名录",
#   "season": 4,
#   "episode": "E07",
#   "total_episodes": 0,
#   "full_season": False
# }

便利函数

# 快速提取标题,不需要其他字段时
from tortitle import parse_subtitle

title = parse_subtitle("夏目友人帐 第七季 | 全12集+OVA | 中日双语字幕")
print(title)  # 夏目友人帐

Contribution

欢迎提交 Pull Request

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tortitle-0.2.2.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tortitle-0.2.2-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file tortitle-0.2.2.tar.gz.

File metadata

  • Download URL: tortitle-0.2.2.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for tortitle-0.2.2.tar.gz
Algorithm Hash digest
SHA256 669fd48fbea557311b2e4b4af2bf27e9d211293158448fac68899b338e98c586
MD5 52b34c958e23e2bb550c74b0739335c7
BLAKE2b-256 d001d4b4ce10931f5f4ab601e162aa729331ff5b2db830b2b9dbdad62cad0bb6

See more details on using hashes here.

File details

Details for the file tortitle-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: tortitle-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for tortitle-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b69146a4921b88529c864d2e680842798f833dcf45a4380e5c460276dc51a17d
MD5 7f1c59d9d0af0354c156f9cfb17ae99c
BLAKE2b-256 a90911d4ca82e5c635ff3731e90eff48cb4e090697939d51fc604e2d825e07ee

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

This release

0.2.2 This release

2 files

0.2.1

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page