From 3c939c65d5cf84a71475cf0f67ee9dc7d0f38ed6 Mon Sep 17 00:00:00 2001 From: Dmitry Misharov Date: Sun, 11 Nov 2018 10:24:44 +0100 Subject: [PATCH] Added profile information. Fixed #18. --- resources/lib/addonworker.py | 16 ++++++++++++++++ tests/tests.py | 1 + 2 files changed, 17 insertions(+) diff --git a/resources/lib/addonworker.py b/resources/lib/addonworker.py index 52026c3..9c1e531 100644 --- a/resources/lib/addonworker.py +++ b/resources/lib/addonworker.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import json +from datetime import date import xbmc import xbmcgui @@ -133,6 +134,8 @@ def index(): xbmcplugin.addDirectoryItem(request.handle, get_internal_link("login"), li, False) else: response = KinoPubClient("types").get() + li = ExtendedListItem("[COLOR FFFFF000]Профиль[/COLOR]") + xbmcplugin.addDirectoryItem(request.handle, get_internal_link("profile"), li, False) add_default_headings(fmt="slph") li = ExtendedListItem("[COLOR FFFFF000]ТВ[/COLOR]") xbmcplugin.addDirectoryItem(request.handle, get_internal_link("tv"), li, True) @@ -578,6 +581,19 @@ def create_bookmarks_folder(): xbmc.executebuiltin("Container.Refresh") +@route("/profile") +def profile(): + user_data = KinoPubClient("user").get()["user"] + reg_date = date.fromtimestamp(user_data["reg_date"]) + dialog = xbmcgui.Dialog() + dialog.ok( + "Информация о профиле", + "Имя пользователя: [B]{}[/B]".format(user_data["username"]), + "Дата регистрации: [B]{0:%d} {0:%B} {0:%Y}[/B]".format(reg_date), + "Остаток дней подписки: [B]{}[/B]".format(int(user_data["subscription"]["days"])) + ) + + # Entry point def init(): ROUTES[request.path](**request.args) diff --git a/tests/tests.py b/tests/tests.py index 306f350..f8a8b90 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -111,6 +111,7 @@ def test_index(mocker, index, main, xbmcplugin, ExtendedListItem): main() c = u"[COLOR FFFFF000]{}[/COLOR]" expected_results = [ + (handle, plugin.format("profile"), c.format(u"Профиль"), False), (handle, plugin.format("search?type=None"), c.format(u"Поиск"), False), (handle, plugin.format("items?type=None"), c.format(u"Последние"), True), (handle, plugin.format("items?type=None&shortcut=%2Fpopular"), c.format(u"Популярные"),