Skip to content

Commit

Permalink
fix subtitle zh
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Nov 23, 2024
1 parent 5c51479 commit 5abe38c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
36 changes: 18 additions & 18 deletions pt_repost/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,26 @@ def process_task(

count = 3

site_implement = SSD(self.config)

tc = self.qb.torrents_export(info_hash)

torrent_name = six.ensure_str(bencode2.bdecode(tc)[b"info"][b"name"])

options = site_implement.parse_mediainfo_as_options(
torrent_name, parse_mediainfo_json(mediainfo_json)
)

if douban_id:
url = f"https://movie.douban.com/subject/{douban_id}/"
elif imdb_id:
url = f"https://www.imdb.com/title/{imdb_id}/"
else:
raise ValueError("missing media site id")

images = self.db.fetch_all("select * from image where task_id = ?", [task_id])

if len(images) < count:
if (len(images) < count) and not dry_run:
with tempfile.TemporaryDirectory(prefix="pt-repost-") as tempdir:
for file in generate_images(
video_file, count=count, tmpdir=Path(tempdir)
Expand All @@ -171,23 +188,6 @@ def process_task(
)
]

site_implement = SSD(self.config)

tc = self.qb.torrents_export(info_hash)

torrent_name = six.ensure_str(bencode2.bdecode(tc)[b"info"][b"name"])

options = site_implement.parse_mediainfo_as_options(
torrent_name, parse_mediainfo_json(mediainfo_json)
)

if douban_id:
url = f"https://movie.douban.com/subject/{douban_id}/"
elif imdb_id:
url = f"https://www.imdb.com/title/{imdb_id}/"
else:
raise ValueError("missing media site id")

info = extract_meta_info(douban_id or imdb_id)
if dry_run:
logger.info("dry-run mode, skipping create post")
Expand Down
18 changes: 13 additions & 5 deletions pt_repost/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,19 @@ def parse_mediainfo_as_options(
for text in m.text:
lang = text.language.lower()
title = text.title.lower()
for word in {"zh-cn", "zh-cn", "zh-cn", "chinese", "cmn-hans", "cmn-hant"}:
if (word in lang) or (word in title):
logger.info('find tag "中字"')
options["subtitlezh"] = "1"
break
if any(
((word in lang) or (word in title))
for word in {
"zh",
"zh-cn",
"chinese",
"cmn-hans",
"cmn-hant",
}
):
logger.info('find tag "中字"')
options["subtitlezh"] = "1"
break

return options

Expand Down

0 comments on commit 5abe38c

Please sign in to comment.