[65] update imdb_awards

pull/1794/head
meisnate12 10 months ago
parent 38602542fc
commit 0e20fdb704

@ -1 +1 @@
1.19.1-develop64 1.19.1-develop65

@ -1,145 +0,0 @@
##############################################################################
# DE Content Rating Collections #
# Created by Yozora, Bullmoose20, & Sohjiro #
# EDITING THIS FILE MAY CAUSE PULLING NEW UPDATES TO FAIL #
# https://metamanager.wiki/en/latest/defaults/both/content_rating_de.html #
##############################################################################
external_templates:
pmm: templates
template_variables:
collection_section: "110"
collections:
Ratings Collections:
template:
- name: separator
separator: content_rating
key_name: Ratings
translation_key: separator
dynamic_collections:
DE Content Rating:
type: content_rating
title_format: <<key_name>> <<library_typeU>>s
other_name: Not Rated <<library_typeU>>s
template:
- smart_filter
- shared
other_template:
- other_collection
- smart_filter
- shared
template_variables:
search_term:
default: content_rating
image:
default: content_rating/de/<<key_name>>
other: content_rating/de/NR
translation_key:
default: content_rating
other: content_rating_other
dynamic:
default: true
include:
- "0"
- 6
- 12
- 16
- 18
<<<<<<< HEAD
- BPjM
=======
- BPJM
>>>>>>> bullmoose20/patch-17
addons:
0:
- de/0
- U
- 1
- 2
- 3
- 4
- 5
- "01"
- "02"
- "03"
- "04"
- "05"
- G
- TV-G
- TV-Y
- G - All Ages
- gb/U
- gb/0+
- E
- gb/E
- A
- no/A
- no/5
- no/05
6:
- de/6
- gb/9+
- TV-PG
- TV-Y7
- TV-Y7-FV
- PG
- 7
- 8
- 9
- 10
- 11
- "07"
- "08"
- "09"
- PG - Children
- no/6
- no/06
- no/7
- no/07
- no/9
- no/09
- no/10
- no/11
12:
- de/12
- gb/12
- no/12
- gb/15
- gb/14+
- TV-14
- 13
- 14
- 15
- PG-13 - Teens 13 or older
- PG-13
- no/15
16:
- de/16
- no/16
- A-17
- TVMA
- TV-MA
- R
- 17
- M/PG
18:
- de/18
- gb/18
- M
- no/18
- R18
- gb/R18
- gb/X
- X
- NC-17
- R+ - Mild Nudity
- Rx - Hentai
<<<<<<< HEAD
BPjM:
=======
BPJM:
>>>>>>> bullmoose20/patch-17
- de/BPjM Restricted
- BPjM Restricted

@ -198,6 +198,11 @@ You can have some control of the files from inside your Configuration file by us
<div id="schedule" />Used to schedule when this file is run using the [schedule options](schedule.md). <div id="schedule" />Used to schedule when this file is run using the [schedule options](schedule.md).
??? warning
This does not work with Overlays as they cannot be scheduled individually. Use the
[`schedule_overlays` Library Attribute](libraries.md#schedule-overlays) to schedule Overlays.
<hr style="margin: 0px;"> <hr style="margin: 0px;">
**Attribute:** `schedule` **Attribute:** `schedule`

@ -356,7 +356,7 @@ The available attributes for each library are as follows:
??? blank "`schedule_overlays` - Used to schedule overlays.<a class="headerlink" href="#schedule-overlays" title="Permanent link"></a>" ??? blank "`schedule_overlays` - Used to schedule overlays.<a class="headerlink" href="#schedule-overlays" title="Permanent link"></a>"
<div id="schedule-overlays" />Used to schedule overlays to run when desired. Overlays are applied all at once in a <div id="schedule-overlays" />Used to schedule overlays to run when desired. Overlays are applied all at once in a
batch therfore you cannot schedule individual Overlay Files, as any unscheduled overlay file will be removed each batch therefore you cannot schedule individual Overlay Files, as any unscheduled overlay file will be removed each
time PMM is run. time PMM is run.
<hr style="margin: 0px;"> <hr style="margin: 0px;">

@ -130,13 +130,22 @@ collections:
Finds every item in an [IMDb Event](https://www.imdb.com/event/). Finds every item in an [IMDb Event](https://www.imdb.com/event/).
| Award Parameter | Description | | Award Parameter | Description |
|:------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------| |:--------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `event_id` | Specify the IMDb Event ID to search.<br>**Options:** The ID found in the URLs linked on the [IMDb Events Page](https://www.imdb.com/event/). (ex. `ev0000003`) | | `event_id` | Specify the IMDb Event ID to search. **This attribute is required.**<br>**Options:** The ID found in the URLs linked on the [IMDb Events Page](https://www.imdb.com/event/). (ex. `ev0000003`) |
| `event_year` | Specify the Year of the Event to look at.<br>**Options:** Any Year under the Event History Sidebar on an Event page. | | `event_year`<sup>1</sup> | Specify the year of the Event to look at. **This attribute is required.**<br>**Options:** Any year, list of years, or year range (ex. `2000-2009` or `2000-current`) from the years under the Event History Sidebar on an Event page. |
| `award_filter` | Filter by the Award heading. Can only accept multiple values as a list.<br>**Options:** Any Black Award heading on an Event Page. | | `award_filter` | Filter by the Award heading. Can only accept multiple values as a list.<br>**Options:** Any Black Award heading on an Event Page. |
| `category_filter` | Filter by the Category heading. Can only accept multiple values as a list.<br>**Options:** Any Gold/Yellow Category heading on an Event Page. | | `category_filter` | Filter by the Category heading. Can only accept multiple values as a list.<br>**Options:** Any Gold/Yellow Category heading on an Event Page. |
| `winning` | Filter by if the Item Won the award.<br>**Options:** `true`/`false`<br>**Default:** `false` | | `winning` | Filter by if the Item Won the award.<br>**Options:** `true`/`false`<br>**Default:** `false` |
1. When using multiple years the only available Event IDs are:
```yaml
{%
include-markdown "https://raw.githubusercontent.com/meisnate12/PMM-IMDb-Awards/master/event_ids.yml"
comments=false
%}
```
```yaml ```yaml
collections: collections:

@ -11,6 +11,9 @@
--md-default-bg-color: #252525; --md-default-bg-color: #252525;
--md-footer-bg-color--dark: var(--md-default-bg-color); --md-footer-bg-color--dark: var(--md-default-bg-color);
} }
strong {
color: #00bc8c;
}
.md-banner { .md-banner {
background-color: #252525; background-color: #252525;

@ -1507,18 +1507,35 @@ class CollectionBuilder:
for dict_data in util.parse(self.Type, method_name, method_data, datatype="listdict"): for dict_data in util.parse(self.Type, method_name, method_data, datatype="listdict"):
dict_methods = {dm.lower(): dm for dm in dict_data} dict_methods = {dm.lower(): dm for dm in dict_data}
event_id = util.parse(self.Type, "event_id", dict_data, parent=method_name, methods=dict_methods, regex=(r"(ev\d+)", "ev0000003")) event_id = util.parse(self.Type, "event_id", dict_data, parent=method_name, methods=dict_methods, regex=(r"(ev\d+)", "ev0000003"))
year_options = self.config.IMDb.get_event_years(event_id) git_event, year_options = self.config.IMDb.get_event_years(event_id)
if not year_options: if not year_options:
raise Failed(f"{self.Type} Error: imdb_award event_id attribute: No event found at {imdb.base_url}/event/{event_id}") raise Failed(f"{self.Type} Error: imdb_award event_id attribute: No event found at {imdb.base_url}/event/{event_id}")
event_year = str(util.parse(self.Type, "event_year", dict_data, parent=method_name, methods=dict_methods, options=year_options)) if "event_year" not in dict_methods:
try: raise Failed(f"{self.Type} Error: imdb_award event_year attribute not found")
award_filters = util.parse(self.Type, "award_filter", dict_data, parent=method_name, methods=dict_methods, datatype="lowerlist") og_year = dict_data[dict_methods["event_year"]]
except Failed: if not og_year:
award_filters = [] raise Failed(f"{self.Type} Error: imdb_award event_year attribute is blank")
try: if og_year == "all":
category_filters = util.parse(self.Type, "category_filter", dict_data, parent=method_name, methods=dict_methods, datatype="lowerlist") event_year = year_options
except Failed: elif not isinstance(og_year, list) and "-" in str(og_year) and len(str(og_year)) > 7:
category_filters = [] try:
min_year, max_year = og_year.split("-")
min_year = int(min_year)
max_year = int(max_year) if max_year != "current" else None
event_year = []
for option in year_options:
check = int(option.split("-")[0] if "-" in option else option)
if check >= min_year and (max_year is None or check <= max_year):
event_year.append(option)
except ValueError:
raise Failed(f"{self.Type} Error: imdb_award event_year attribute invalid: {og_year}")
else:
event_year = util.parse(self.Type, "event_year", og_year, parent=method_name, datatype="strlist", options=year_options)
if len(event_year) > 1 and not git_event:
raise Failed(f"{self.Type} Error: Only specific events work when using multiple years. Event Options: {self.config.IMDb.events_validation.keys()}")
award_filters = util.parse(self.Type, "award_filter", dict_data, parent=method_name, methods=dict_methods, datatype="lowerlist")
category_filters = util.parse(self.Type, "category_filter", dict_data, parent=method_name, methods=dict_methods, datatype="lowerlist")
final_category = [] final_category = []
final_awards = [] final_awards = []
if award_filters or category_filters: if award_filters or category_filters:

@ -72,6 +72,7 @@ event_options = {
"razzie": {"eventId": "ev0000558"}, "razzie": {"eventId": "ev0000558"},
} }
base_url = "https://www.imdb.com" base_url = "https://www.imdb.com"
git_base = "https://raw.githubusercontent.com/meisnate12/PMM-IMDb-Awards/master"
graphql_url = "https://api.graphql.imdb.com/" graphql_url = "https://api.graphql.imdb.com/"
list_url = f"{base_url}/list/ls" list_url = f"{base_url}/list/ls"
@ -81,6 +82,8 @@ class IMDb:
self._ratings = None self._ratings = None
self._genres = None self._genres = None
self._episode_ratings = None self._episode_ratings = None
self._events_validation = None
self._events = {}
def _request(self, url, language=None, xpath=None, params=None): def _request(self, url, language=None, xpath=None, params=None):
logger.trace(f"URL: {url}") logger.trace(f"URL: {url}")
@ -93,6 +96,17 @@ class IMDb:
def _graph_request(self, json_data): def _graph_request(self, json_data):
return self.config.post_json(graphql_url, headers={"content-type": "application/json"}, json=json_data) return self.config.post_json(graphql_url, headers={"content-type": "application/json"}, json=json_data)
@property
def events_validation(self):
if self._events_validation is None:
self._events_validation = self.config.load_yaml(f"{git_base}/event_validation.yml")
return self._events_validation
def get_event(self, event_id):
if event_id not in self._events:
self._events[event_id] = self.config.load_yaml(f"{git_base}/events/{event_id}.yml")
return self._events[event_id]
def validate_imdb_lists(self, err_type, imdb_lists, language): def validate_imdb_lists(self, err_type, imdb_lists, language):
valid_lists = [] valid_lists = []
for imdb_dict in util.get_list(imdb_lists, split=False): for imdb_dict in util.get_list(imdb_lists, split=False):
@ -146,13 +160,17 @@ class IMDb:
return valid_users return valid_users
def get_event_years(self, event_id): def get_event_years(self, event_id):
if event_id in self.events_validation:
return True, self.events_validation[event_id]["years"]
final = [] final = []
for event_link in self._request(f"{base_url}/event/{event_id}", xpath="//div[@class='event-history-widget']//a/@href"): for event_link in self._request(f"{base_url}/event/{event_id}", xpath="//div[@class='event-history-widget']//a/@href"):
parts = event_link.split("/") parts = event_link.split("/")
final.append(f"{parts[3]}{f'-{parts[4]}' if parts[4] != '1' else ''}") final.append(f"{parts[3]}{f'-{parts[4]}' if parts[4] != '1' else ''}")
return final return False, final
def get_award_names(self, event_id, event_year): def get_award_names(self, event_id, event_year):
if event_id in self.events_validation:
return self.events_validation[event_id]["awards"], self.events_validation[event_id]["categories"]
award_names = [] award_names = []
category_names = [] category_names = []
event_slug = f"{event_year}/1" if "-" not in event_year else event_year.replace("-", "/") event_slug = f"{event_year}/1" if "-" not in event_year else event_year.replace("-", "/")
@ -421,23 +439,34 @@ class IMDb:
def _award(self, data): def _award(self, data):
final_list = [] final_list = []
event_slug = f"{data['event_year']}/1" if "-" not in data["event_year"] else data["event_year"].replace("-", "/") if len(data["event_year"]) > 1:
for text in self._request(f"{base_url}/event/{data['event_id']}/{event_slug}/?ref_=ev_eh", xpath="//div[@class='article']/script/text()")[0].split("\n"): event_data = self.get_event(data["event_id"])
if text.strip().startswith("IMDbReactWidgets.NomineesWidget.push"): for event_year in data["event_year"]:
jsonline = text.strip() for award, categories in event_data[event_year].items():
obj = json.loads(jsonline[jsonline.find('{'):-3]) if data["award_filter"] and award not in data["award_filter"]:
for award in obj["nomineesWidgetModel"]["eventEditionSummary"]["awards"]:
if data["award_filter"] and award["awardName"] not in data["award_filter"]:
continue continue
for cat in award["categories"]: for cat in categories:
if data["category_filter"] and cat["categoryName"] not in data["category_filter"]: if data["category_filter"] and cat not in data["category_filter"]:
continue
final_list.extend(categories["winner" if data["winning"] else "nominee"])
else:
event_slug = f"{data['event_year'][0]}/1" if "-" not in data["event_year"][0] else data["event_year"][0].replace("-", "/")
for text in self._request(f"{base_url}/event/{data['event_id']}/{event_slug}/?ref_=ev_eh", xpath="//div[@class='article']/script/text()")[0].split("\n"):
if text.strip().startswith("IMDbReactWidgets.NomineesWidget.push"):
jsonline = text.strip()
obj = json.loads(jsonline[jsonline.find('{'):-3])
for award in obj["nomineesWidgetModel"]["eventEditionSummary"]["awards"]:
if data["award_filter"] and award["awardName"] not in data["award_filter"]:
continue continue
for nom in cat["nominations"]: for cat in award["categories"]:
if data["winning"] and not nom["isWinner"]: if data["category_filter"] and cat["categoryName"] not in data["category_filter"]:
continue continue
imdb_id = next((n["const"] for n in nom["primaryNominees"] + nom["secondaryNominees"] if n["const"].startswith("tt")), None) for nom in cat["nominations"]:
if imdb_id: if data["winning"] and not nom["isWinner"]:
final_list.append(imdb_id) continue
imdb_id = next((n["const"] for n in nom["primaryNominees"] + nom["secondaryNominees"] if n["const"].startswith("tt")), None)
if imdb_id:
final_list.append(imdb_id)
break break
return final_list return final_list
@ -501,7 +530,7 @@ class IMDb:
else: else:
raise Failed(f"IMDb Error: chart: {chart} not ") raise Failed(f"IMDb Error: chart: {chart} not ")
links = self._request(f"{base_url}/{url}", language=language, xpath="//li//a[@class='ipc-title-link-wrapper']/@href") links = self._request(f"{base_url}/{url}", language=language, xpath="//li//a[@class='ipc-title-link-wrapper']/@href")
return [re.search("(tt\\d+)", l).group(1) for l in links] return [re.search("(tt\\d+)", link).group(1) for link in links]
def get_imdb_ids(self, method, data, language): def get_imdb_ids(self, method, data, language):
if method == "imdb_id": if method == "imdb_id":
@ -518,8 +547,12 @@ class IMDb:
logger.info(f"Processing IMDb Watchlist: {data}") logger.info(f"Processing IMDb Watchlist: {data}")
return [(_i, "imdb") for _i in self._watchlist(data, language)] return [(_i, "imdb") for _i in self._watchlist(data, language)]
elif method == "imdb_award": elif method == "imdb_award":
event_slug = f"{data['event_year']}/1" if "-" not in data["event_year"] else data["event_year"].replace("-", "/") if len(data["event_year"]) == 1:
logger.info(f"Processing IMDb Award: {base_url}/{data['event_id']}/{event_slug}/?ref_=ev_eh") event_slug = f"{data['event_year'][0]}/1" if "-" not in data["event_year"][0] else data["event_year"][0].replace("-", "/")
logger.info(f"Processing IMDb Award: {base_url}/{data['event_id']}/{event_slug}/?ref_=ev_eh")
else:
logger.info(f"Processing IMDb Award: {data['event_id']}")
logger.info(f" event_year: {data['event_year']}")
for k in ["award_filter", "category_filter", "winning"]: for k in ["award_filter", "category_filter", "winning"]:
logger.info(f" {k}: {data[k]}") logger.info(f" {k}: {data[k]}")
return [(_i, "imdb") for _i in self._award(data)] return [(_i, "imdb") for _i in self._award(data)]

@ -776,7 +776,7 @@ def parse(error, attribute, data, datatype=None, methods=None, parent=None, defa
if not isinstance(value, list): if not isinstance(value, list):
value = [value] value = [value]
for v in value: for v in value:
if v: if v or v == 0:
if options is None or (options and (v in options or (datatype == "strlist" and str(v) in options))): if options is None or (options and (v in options or (datatype == "strlist" and str(v) in options))):
final_list.append(str(v) if datatype == "strlist" else v) final_list.append(str(v) if datatype == "strlist" else v)
elif options: elif options:

Loading…
Cancel
Save