From 2a5c1275bbca3eccff2faccb53b7368d8e87d6d8 Mon Sep 17 00:00:00 2001 From: Dmitry Mostovoy Date: Thu, 15 Nov 2018 14:05:46 +0300 Subject: [PATCH 1/2] Move Ratings at the top of Video description --- resources/lib/addonutils.py | 51 +++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/resources/lib/addonutils.py b/resources/lib/addonutils.py index 4dbc698..7747c2b 100644 --- a/resources/lib/addonutils.py +++ b/resources/lib/addonutils.py @@ -56,39 +56,52 @@ def alphanum_key(key): # if there is no such quality then return a link with the highest available quality return files[natural_sort(files.keys())[-1]][stream_type] +def get_plot(item): + year_ratings = [] + output = [] -def video_info(item, extend=None): + if int(item["year"]): + year_ratings.append(u"[COLOR FF12A0C7]{}[/COLOR]".format(int(item["year"]))) - def get_plot(): - plot_1 = item["plot"] - if item["kinopoisk_rating"]: - plot_2 = u"Кинопоиск: {}".format(str(round(item["kinopoisk_rating"], 1))) - else: - plot_2 = u"Кинопоиск: нет" - if item["imdb_rating"]: - plot_3 = u"IMDB: {}".format(str(round(item["imdb_rating"], 1))) - else: - plot_3 = u"IMDB: нет" - return "\n".join([plot_1, plot_2, plot_3]) + if item["imdb_rating"]: + year_ratings.append(u"[COLOR FFFFF000]IMDB:[/COLOR] {}".format(str(round(item["imdb_rating"], 1)))) - def get_status(): - if item["finished"] and item["type"] == "serial": - return u"окончен" + if item["kinopoisk_rating"]: + year_ratings.append(u"[COLOR FFFFF000]Кинопоиск:[/COLOR] {}".format(str(round(item["kinopoisk_rating"], 1)))) + + if year_ratings: + output.append(u"{}".format(", ".join(year_ratings))) + + if item["type"] == "serial": + if item["finished"]: + status = u"[COLOR FFFF0000]окончен[/COLOR]" else: - if item["type"] == "serial": - return u"в эфире" + status = u"в эфире" + + output.append(u"[COLOR FFFFF000]Статус: [/COLOR]{}".format(status)) + if item["plot"]: + if output: + output.append(u"") + + output.append(item["plot"]) + + if output: + return "\n".join(output) + else: + return u"" + +def video_info(item, extend=None): info = { "year": int(item["year"]), "genre": ", ".join([x["title"] for x in item["genres"]]), "rating": float(item["rating"]), "cast": [x.strip() for x in item["cast"].split(",")], "director": item["director"], - "plot": get_plot(), + "plot": get_plot(item), "title": item["title"], "duration": item.get("duration", {}).get("average"), "code": item["imdb"], - "status": get_status(), "votes": item["rating_votes"], "country": ", ".join([x["title"] for x in item["countries"]]) } From 04972de5683e3ffe234e7dd7b9ad4a85bfe65438 Mon Sep 17 00:00:00 2001 From: Dmitry Misharov Date: Sat, 17 Nov 2018 09:07:14 +0100 Subject: [PATCH 2/2] Removed status from the plot --- resources/lib/addonutils.py | 53 +++++++++++++++---------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/resources/lib/addonutils.py b/resources/lib/addonutils.py index 7747c2b..142b933 100644 --- a/resources/lib/addonutils.py +++ b/resources/lib/addonutils.py @@ -56,40 +56,28 @@ def alphanum_key(key): # if there is no such quality then return a link with the highest available quality return files[natural_sort(files.keys())[-1]][stream_type] -def get_plot(item): - year_ratings = [] - output = [] - - if int(item["year"]): - year_ratings.append(u"[COLOR FF12A0C7]{}[/COLOR]".format(int(item["year"]))) +def build_plot(item): + final_plot = [] if item["imdb_rating"]: - year_ratings.append(u"[COLOR FFFFF000]IMDB:[/COLOR] {}".format(str(round(item["imdb_rating"], 1)))) - + final_plot.append("IMDB: {}".format(str(round(item["imdb_rating"], 1)))) if item["kinopoisk_rating"]: - year_ratings.append(u"[COLOR FFFFF000]Кинопоиск:[/COLOR] {}".format(str(round(item["kinopoisk_rating"], 1)))) - - if year_ratings: - output.append(u"{}".format(", ".join(year_ratings))) - - if item["type"] == "serial": - if item["finished"]: - status = u"[COLOR FFFF0000]окончен[/COLOR]" - else: - status = u"в эфире" - - output.append(u"[COLOR FFFFF000]Статус: [/COLOR]{}".format(status)) - - if item["plot"]: - if output: - output.append(u"") - - output.append(item["plot"]) - - if output: - return "\n".join(output) + final_plot.append(u"Кинопоиск: {}".format(str(round(item["kinopoisk_rating"], 1)))) + # a new line between the ratings and the plot + if item["imdb_rating"] or item["kinopoisk_rating"]: + final_plot.append("") + final_plot.append(item["plot"]) + return "\n".join(final_plot) + + +def get_status(item): + if item["type"] == "serial" and item["finished"]: + return u"окончен" + elif item["type"] == "serial" and not item["finished"]: + return u"в эфире" else: - return u"" + return + def video_info(item, extend=None): info = { @@ -98,10 +86,11 @@ def video_info(item, extend=None): "rating": float(item["rating"]), "cast": [x.strip() for x in item["cast"].split(",")], "director": item["director"], - "plot": get_plot(item), + "plot": build_plot(item), "title": item["title"], "duration": item.get("duration", {}).get("average"), - "code": item["imdb"], + "imdbnumber": item["imdb"], + "status": get_status(item), "votes": item["rating_votes"], "country": ", ".join([x["title"] for x in item["countries"]]) }