Skip to content

Commit

Permalink
Added profile information. Fixed #18.
Browse files Browse the repository at this point in the history
  • Loading branch information
quarckster committed Nov 11, 2018
1 parent bd68c61 commit 3c939c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions resources/lib/addonworker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import json
from datetime import date

import xbmc
import xbmcgui
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"Популярные"),
Expand Down

0 comments on commit 3c939c6

Please sign in to comment.