Skip to content

Commit

Permalink
Fix toggle watched (#150)
Browse files Browse the repository at this point in the history
* Used native notification dialog

* Removed unneeded string decoding

* Fixed toggle watched
  • Loading branch information
quarckster authored Dec 23, 2020
1 parent 31811e4 commit f5b077f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
13 changes: 7 additions & 6 deletions src/resources/lib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ def _make_request(self, request, timeout=600):
self.plugin.logger.error(f"{type(e).__name__}. Message: {e.message}")
notice(e.message, "Ошибка")
else:
response = json.loads(response.read())
if response["status"] == 200:
return response
else:
self.plugin.logger.error(f"Unknown error. Code: {response['status']}")
notice(f"Код ответа сервера {response['status']}", "Неизвестная ошибка")
if r := response.read():
response = json.loads(r)
if response["status"] == 200:
return response
else:
self.plugin.logger.error(f"Unknown error. Code: {response['status']}")
notice(f"Код ответа сервера {response['status']}", "Ошибка")

def get(self, data=""):
data = f"?{urllib.parse.urlencode(data)}" if data else ""
Expand Down
8 changes: 4 additions & 4 deletions src/resources/lib/listitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _addWatchlistContextMenuItem(self, menu_items):
url = self.plugin.routing.build_url(
"toggle_watchlist", self.getProperty("id"), added=int(not int(in_watchlist))
)
menu_items.append((label, f"XBMC.RunPlugin({url})"))
menu_items.append((label, f"Container.Update({url})"))

def _addWatchedContextMenuItem(self, menu_items):
item_id = self.getProperty("id")
Expand All @@ -69,21 +69,21 @@ def _addWatchedContextMenuItem(self, menu_items):
else:
kwargs = {"video": video_number}
url = self.plugin.routing.build_url("toggle_watched", item_id, **kwargs)
menu_items.append((label, f"XBMC.RunPlugin({url})"))
menu_items.append((label, f"Container.Update({url})"))

def _addBookmarksContextMenuItem(self, menu_items):
if self.getVideoInfoTag().getMediaType() == "season":
return
item_id = self.getProperty("id")
label = "Изменить закладки"
url = self.plugin.routing.build_url("edit_bookmarks", item_id)
menu_items.append((label, f"XBMC.RunPlugin({url})"))
menu_items.append((label, f"Container.Update({url})"))

def _addCommentsContextMenuItem(self, menu_items):
item_id = self.getProperty("id")
label = "Комментарии KinoPub"
url = self.plugin.routing.build_url("comments", item_id)
menu_items.append((label, f"XBMC.RunPlugin({url})"))
menu_items.append((label, f"Container.Update({url})"))

def _addSimilarContextMenuItem(self, menu_items):
item_id = self.getProperty("id")
Expand Down
4 changes: 1 addition & 3 deletions src/resources/lib/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ def __getstate__(self):
return odict

def __repr__(self):
return (
f"{type(self).__name__}(item_id: {self.item_id}; title: {self.title.encode('utf-8')})"
)
return f"{type(self).__name__}(item_id: {self.item_id}; title: {self.title})"


class PlayableItem(ItemEntity):
Expand Down
4 changes: 2 additions & 2 deletions src/resources/lib/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import xbmc
import xbmcgui


def notice(message, heading="", time=4000):
xbmc.executebuiltin(f'XBMC.Notification("{heading}", "{message}", "{time}")')
xbmcgui.Dialog().notification(heading, message, time=time)

0 comments on commit f5b077f

Please sign in to comment.