Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying remap rules for media info #214

Merged
merged 8 commits into from
Oct 14, 2022
Merged

Conversation

iamkroot
Copy link
Owner

@iamkroot iamkroot commented Oct 8, 2022

Closes #95

@iamkroot
Copy link
Owner Author

iamkroot commented Oct 8, 2022

WIP Schema and sample file (to be stored as TRAKT_CONFIG_DIR/remap_rules.toml):

# Sample trakt scrobbler remap file.

# schema:
# there should be a toplevel key "rules", which is a list of the following-
# [match]
#   - one or more of path, title, season, episode, year
#   - path should be valid a Python regex pattern
#     - you can also capture substrings using "(?P<name>pattern)" syntax. These will override the default-extracted values from guessit.
#   - season, episode, year support ranges.
#       - For instance, 'season: "1:3,5"' will match any season in {1,2,3,5}
#   - if needed, we can add a "fuzzy-title" in the future to do edit-distance based matching
#   - specifying multiple fields means all of them should match.
# [type]
#   - one of "episode" or "movie"
# [id]
#   - one of trakt_slug, trakt_id, or title (to select top result)
#   - can use placeholders for extracted values like "{episode}", "{title}", "{year}", etc.
#      - the placeholder names should match the extracted guessit keys or regex capture group names
#   - "title" can contain an optional year inside parentheses. Eg: "The Man from Earth (2007)"
# [season]
#   - optional. If not provided, the extracted value from path/regex will be used.
#   - any number starting from 0
#   - 0 corresponds to "Specials" season on Trakt
# [episode_delta]
#   - optional. Default is 0
#   - any integer (positive or negative)
#   - will be added to the episode number extracted from path/regex


# for this sample, the match paths correspond to the Monogatari torrent v2 from DB encodes.

[[rules]]
match.path = ".*/01 Bakemonogatari/.*"
match.episode = "1:12"

id.trakt_slug = "monogatari"
type = "episode"

season = 1

[[rules]]
match.path = ".*/01 Bakemonogatari/.*"
match.episode = "13:15"

id.trakt_slug = "monogatari"
type = "episode"

season = 0
episode_delta = -11

[[rules]]
match.path = ".*/Kizumonogatari/.*"
id.title = "Kizumonogatari Part {episode}"
type = "movie"

[[rules]]
match.path = ".*/02 Nisemonogatari/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 2

[[rules]]
match.path = ".*/03 Nekomonogatari (Kuro)/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 0
episode_delta = 5

[[rules]]
match.path = ".*/Arc 01 Nekomonogatari Shiro/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 3

[[rules]]
match.path = ".*/Arc 02 Kabukimonogatari/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 3
episode_delta = 5

[[rules]]
match.path = ".*/Arc 06 Hanamonogatari/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 0
episode_delta = 12

[[rules]]
match.path = ".*/Arc 03 Otorimonogatari/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 3
episode_delta = 9

[[rules]]
match.path = ".*/Arc 04 Onimonogatari/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 3
episode_delta = 13

[[rules]]
match.path = ".*/Arc 05 Koimonogatari/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 3
episode_delta = 17

[[rules]]
match.path = ".*/01 Tsukimonogatari/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 0
episode_delta = 17

[[rules]]
match.path = ".*/03 Koyomimonogatari/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 0
episode_delta = 21

[[rules]]
match.path = ".*/02 Owarimonogatari/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 4

[[rules]]
match.path = ".*/04 Owarimonogatari Second Season/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 0
episode_delta = 34

[[rules]]
match.path = ".*/05 Zoku Owarimonogatari/.*"

id.trakt_slug = "monogatari"
type = "episode"

season = 0
episode_delta = 41

@ahmubashshir
Copy link
Contributor

LGTM... Works on my machine™ XD

p.s. I'm moved beyond words by the fact that you didn't use yaml for this /s

@iamkroot iamkroot marked this pull request as ready for review October 12, 2022 14:13
@iamkroot
Copy link
Owner Author

Alright, this seems to be working well enough for me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Add support for overriding show parameters
2 participants