mirror of
https://github.com/zoriya/guessit.git
synced 2025-12-06 06:16:09 +00:00
feat(week): add week property
This commit is contained in:
@@ -42,6 +42,10 @@ Main properties
|
||||
|
||||
Year of movie (or episode).
|
||||
|
||||
- **week**
|
||||
|
||||
Week number, from 1 to 52, of episode.
|
||||
|
||||
- **release\_group**
|
||||
|
||||
Name of (non)scene group that released the file.
|
||||
|
||||
@@ -839,6 +839,9 @@
|
||||
"Yahoo": "YHOO",
|
||||
"YouTube Red": "RED",
|
||||
"ZDF": "ZDF"
|
||||
},
|
||||
"date": {
|
||||
"week_words": ["week"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ def valid_year(year):
|
||||
return 1920 <= year < 2030
|
||||
|
||||
|
||||
def valid_week(week):
|
||||
"""Check if number is a valid week"""
|
||||
return 1 <= week < 53
|
||||
|
||||
|
||||
def _is_int(string):
|
||||
"""
|
||||
Check if the input string is an integer
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
date and year properties
|
||||
date, week and year properties
|
||||
"""
|
||||
import re
|
||||
|
||||
from rebulk import Rebulk, RemoveMatch, Rule
|
||||
|
||||
from ..common.date import search_date, valid_year
|
||||
from ..common import dash
|
||||
from ..common.date import search_date, valid_year, valid_week
|
||||
from ..common.pattern import is_disabled
|
||||
from ..common.validators import seps_surround
|
||||
from ...reutils import build_or_pattern
|
||||
|
||||
|
||||
def date(config): # pylint:disable=unused-argument
|
||||
@@ -28,6 +32,15 @@ def date(config): # pylint:disable=unused-argument
|
||||
else '__default__',
|
||||
validator=lambda match: seps_surround(match) and valid_year(match.value))
|
||||
|
||||
rebulk.regex(build_or_pattern(config.get('week_words')) + r"-?(\d{1,2})",
|
||||
name="week", formatter=int,
|
||||
children=True,
|
||||
flags=re.IGNORECASE, abbreviations=[dash],
|
||||
conflict_solver=lambda match, other: other
|
||||
if other.name in ('episode', 'season') and len(other.raw) < len(match.raw)
|
||||
else '__default__',
|
||||
validator=lambda match: seps_surround(match) and valid_week(match.value))
|
||||
|
||||
def date_functional(string, context): # pylint:disable=inconsistent-return-statements
|
||||
"""
|
||||
Search for date in the string and retrieves match
|
||||
|
||||
@@ -330,7 +330,14 @@
|
||||
season: 2010
|
||||
episode: 2
|
||||
|
||||
? Show Name - S32-Dummy 45-Ep 6478
|
||||
: title: Show Name
|
||||
episode_title: Dummy 45
|
||||
season: 32
|
||||
episode: 6478
|
||||
|
||||
? Show Name - S32-Week 45-Ep 6478
|
||||
: title: Show Name
|
||||
season: 32
|
||||
week: 45
|
||||
episode: 6478
|
||||
|
||||
Reference in New Issue
Block a user