mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 13:44:33 -04:00
Add episode title promotion rule
This commit is contained in:
parent
9dde2475fc
commit
5821a79af9
@ -6,6 +6,62 @@ from rebulk.match import Matches, Match
|
||||
from copy import copy
|
||||
|
||||
|
||||
class EpisodeTitlePromotion(Rule):
|
||||
"""Promote "episode_title" to "episode" when the title is in fact the episode number
|
||||
|
||||
Example: '[Erai-raws] Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e S3 - 05 [1080p][Multiple Subtitle][0DDEAFCD].mkv'
|
||||
|
||||
Default:
|
||||
```json
|
||||
{
|
||||
"release_group": "Erai-raws",
|
||||
"title": "Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e",
|
||||
"season": 3,
|
||||
"episode_title": "05",
|
||||
"screen_size": "1080p",
|
||||
"subtitle_language": "Multiple languages",
|
||||
"crc32": "0DDEAFCD",
|
||||
"container": "mkv",
|
||||
"mimetype": "video/x-matroska",
|
||||
"type": "episode"
|
||||
}
|
||||
```
|
||||
|
||||
Expected:
|
||||
```json
|
||||
{
|
||||
"release_group": "Erai-raws",
|
||||
"title": "Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e",
|
||||
"season": 3,
|
||||
"episode": 5,
|
||||
"screen_size": "1080p",
|
||||
"subtitle_language": "Multiple languages",
|
||||
"crc32": "0DDEAFCD",
|
||||
"container": "mkv",
|
||||
"mimetype": "video/x-matroska",
|
||||
"type": "episode"
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
priority = POST_PROCESS
|
||||
consequence = [RemoveMatch, AppendMatch]
|
||||
|
||||
def when(self, matches: Matches, context) -> Any:
|
||||
ep_title: List[Match] = matches.named("episode_title") # type: ignore
|
||||
if not ep_title:
|
||||
return
|
||||
|
||||
to_remove = [match for match in ep_title if str(match.value).isdecimal()]
|
||||
to_add = []
|
||||
for tmatch in to_remove:
|
||||
match = copy(tmatch)
|
||||
match.name = "episode"
|
||||
match.value = int(str(tmatch.value))
|
||||
to_add.append(match)
|
||||
return [to_remove, to_add]
|
||||
|
||||
|
||||
class MultipleSeasonRule(Rule):
|
||||
"""Understand `abcd Season 2 - 5.mkv` as S2E5
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user