Skip to content

Commit

Permalink
Merge pull request #25 from stavultras/ratings_changes
Browse files Browse the repository at this point in the history
Move Ratings at the top of Video description
  • Loading branch information
quarckster authored Nov 17, 2018
2 parents 32ac470 + 04972de commit 322b56a
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions resources/lib/addonutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,38 +57,40 @@ def alphanum_key(key):
return files[natural_sort(files.keys())[-1]][stream_type]


def video_info(item, extend=None):

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])
def build_plot(item):
final_plot = []
if item["imdb_rating"]:
final_plot.append("IMDB: {}".format(str(round(item["imdb_rating"], 1))))
if item["kinopoisk_rating"]:
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

def get_status():
if item["finished"] and item["type"] == "serial":
return u"окончен"
else:
if item["type"] == "serial":
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": build_plot(item),
"title": item["title"],
"duration": item.get("duration", {}).get("average"),
"code": item["imdb"],
"status": get_status(),
"imdbnumber": item["imdb"],
"status": get_status(item),
"votes": item["rating_votes"],
"country": ", ".join([x["title"] for x in item["countries"]])
}
Expand Down

0 comments on commit 322b56a

Please sign in to comment.