diff --git a/ATTRIBUTES.md b/ATTRIBUTES.md index ef71ba0..9d553de 100644 --- a/ATTRIBUTES.md +++ b/ATTRIBUTES.md @@ -18,4 +18,4 @@ the string language (eg. `english`), and if not, this is simply `True` - `senior`: bool, specifies if this showing is for senior citizens only - `subtitled`: string or bool, specifies if the film is subtitled. If the language of the subtitling is known, this is the string language (eg. `english`), and if not, this is simply `True` - +- `kids`: this film is for kids, and adults must be accompanying a child diff --git a/src/showingpreviously/cinemas/picturehouse.py b/src/showingpreviously/cinemas/picturehouse.py index c9f0daf..28f756b 100644 --- a/src/showingpreviously/cinemas/picturehouse.py +++ b/src/showingpreviously/cinemas/picturehouse.py @@ -21,6 +21,8 @@ SHOWING_URL_ID_PATTERN = re.compile(r'/movie-details/\d+/(?P.+?)/(?P.+)') SLUG_YEAR_PATTERN = re.compile(r'(?P(?:18|19|20)\d{2})') JS_TO_URL_PATTERN = re.compile(r'"(?Phttps?://.+?)"') +DUBBED_LANGUAGE_PATTERN = re.compile(r'Please note, this screening features the Dubbed (?P.+?) version of the film') +SUBBED_LANGUAGE_PATTERN = re.compile(r'have (?P.+?) subtitles') def get_showing_dates() -> str: @@ -72,6 +74,8 @@ def get_film_year(film_link: str) -> str: soup = BeautifulSoup(r.text, features='html.parser') metadata = soup.find('div', {'class': 'directorDiv'}) + if not metadata: + return UNKNOWN_FILM_YEAR date = metadata.find('li', text='Release Date :').findNext('li').text year = date[-4:] return year @@ -113,6 +117,13 @@ def get_attributes(attributes: [dict[str, any]]) -> dict[str, any]: json_attributes['ad-trailer-free'] = True elif attribute['attribute'] == 'Sub Cinema': json_attributes['subtitled'] = True + language = SUBBED_LANGUAGE_PATTERN.search(attribute['description']) + if language: + json_attributes['subtitled'] = language.group('sub_language') + elif attribute['attribute'] == 'Dub Cinema': + language = DUBBED_LANGUAGE_PATTERN.search(attribute['description']) + if language: + json_attributes['language'] = language.group('dub_language') elif attribute['attribute'] == 'LiveSat': json_attributes['format'].append('Live') elif attribute['attribute'] == 'Audio D': @@ -125,6 +136,8 @@ def get_attributes(attributes: [dict[str, any]]) -> dict[str, any]: json_attributes['format'].append('4K') elif attribute['attribute'] == 'Toddler Ti': json_attributes['carers-and-babies'] = True + elif attribute['attribute'] == "Kids' Club": + json_attributes['kids'] = True if len(json_attributes['format']) == 0: del json_attributes['format'] return json_attributes