Skip to content

Commit

Permalink
[script.extendedinfo] 6.0.7
Browse files Browse the repository at this point in the history
1.  rework tmdb authentication -- current api key is being rejected by tmdb
2.  fix script dialog management when play video from script
3.  lutils131/utils change use of variable name "time"
4.  kutils131/utils add timeout protection on calls to "requests"
5.  kutils131/youtube fix handing of youtube supplied "duration"
6.  add/improve docstrings various locations
7.  use "f-string" formatting various locations
8.  fix pylint nags various locations

logic error
  • Loading branch information
scott967 committed Dec 20, 2023
1 parent 17c1a1b commit b885046
Show file tree
Hide file tree
Showing 22 changed files with 458 additions and 200 deletions.
4 changes: 2 additions & 2 deletions script.extendedinfo/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.extendedinfo" name="ExtendedInfo Script" version="6.0.5" provider-name="scott967">
<addon id="script.extendedinfo" name="ExtendedInfo Script" version="6.0.7" provider-name="scott967">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="resource.images.studios.white" version="0.0.25"/>
Expand All @@ -24,7 +24,7 @@
<forum>http://forum.kodi.tv/showthread.php?tid=160558</forum>
<source>https://github.com/scott967/script.extendedinfo</source>
<email>[email protected]</email>
<news>Python 3 fixes and Nexus/Matrix updates by scott967. Original addon for Leia and prior by phil65 (Philipp Temminghoff). Requires Kutils module version 1.3.0 from Kodi official repo</news>
<news>Python 3 fixes and Omega/Nexus/Matrix updates by scott967. Original addon for Leia and prior by phil65 (Philipp Temminghoff).</news>
<assets>
<icon>resources/icon.png</icon>
<fanart>resources/fanart.jpg</fanart>
Expand Down
4 changes: 4 additions & 0 deletions script.extendedinfo/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v6.0.7
- reworked tmdb logon / accreditation
- various code refactoring / pylint items / docstrings (WIP)

v6.0.5
- removed support for broken/obsolete addons artwork downloader, couch potato, sick rage, trakt helper
- removed support for youtube-dl
Expand Down
2 changes: 1 addition & 1 deletion script.extendedinfo/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def pass_list_to_skin(name: str, data, prefix: str = "", limit: int = False) ->
name (str): Type of data being returned derived from runscript info
parameter. Used to construct the skin window property key
eg. topratedmovies from invocation parameter info=
data (kutils.itemlist.ItemList): collection of ListItems
data (kutils131.itemlist.ItemList): collection of ListItems
(Video or Audio)
prefix (str, optional): Optional prefix for the name. May be set
as a param in runscript. Defaults to "".
Expand Down
1 change: 1 addition & 0 deletions script.extendedinfo/resources/kutil131/actionhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"symbols": xbmcgui.ACTION_SYMBOLS,
"cursorleft": xbmcgui.ACTION_CURSOR_LEFT,
"cursorright": xbmcgui.ACTION_CURSOR_RIGHT,
"built-in": xbmcgui.ACTION_BUILT_IN_FUNCTION,
"showtime": xbmcgui.ACTION_SHOW_OSD_TIME,
"analogseekforward": xbmcgui.ACTION_ANALOG_SEEK_FORWARD,
"analogseekback": xbmcgui.ACTION_ANALOG_SEEK_BACK,
Expand Down
1 change: 1 addition & 0 deletions script.extendedinfo/resources/kutil131/dialogbaselist.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (C) 2015 - Philipp Temminghoff <[email protected]>
# This program is Free Software see LICENSE file for details

from __future__ import annotations
import xbmc
import xbmcgui

Expand Down
12 changes: 6 additions & 6 deletions script.extendedinfo/resources/kutil131/kodiaddon.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ def encode_string(clear: str) -> str:
enc = []
key = str(uuid.getnode())
clear_enc = clear.encode()
for i in range(len(clear_enc)):
for i, ele in enumerate(clear_enc):
key_c = key[i % len(key)]
enc_c = chr((clear_enc[i] + ord(key_c)) % 256)
enc_c = chr((ele + ord(key_c)) % 256)
enc.append(enc_c)
return base64.urlsafe_b64encode("".join(enc).encode()).decode()


def decode_string(enc: str) -> str:
def decode_string(enc: str, uuick: str='') -> str:
"""return decoded string (encoded with uuid)
Args:
Expand All @@ -130,10 +130,10 @@ def decode_string(enc: str) -> str:
str: the decoded string
"""
dec = []
key = str(uuid.getnode())
key = str(uuid.getnode()) if not uuick else uuick
enc = base64.urlsafe_b64decode(enc.encode()).decode()
for i in range(len(enc)):
for i, ele in enumerate(enc):
key_c = key[i % len(key)]
dec_c = ((256 + ord(enc[i]) - ord(key_c)) % 256).to_bytes(1, 'little')
dec_c = ((256 + ord(ele) - ord(key_c)) % 256).to_bytes(1, 'little')
dec.append(dec_c)
return bytes.join(b'', dec).decode()
5 changes: 3 additions & 2 deletions script.extendedinfo/resources/kutil131/listitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def __getitem__(self, key):
def __repr__(self):
return "\n".join(["Label:", self.label,
"Label2:", self.label2,
"Path:", self.path,
"InfoLabels:", utils.dump_dict(self._infos),
"Properties:", utils.dump_dict(self._properties),
"Artwork:", utils.dump_dict(self._artwork),
Expand Down Expand Up @@ -387,7 +388,7 @@ class VideoItem(ListItem):
"""Kodi video listitem, based on built-in datatypes
Args:
ListItem (class): The Kutils ListItem class
ListItem (class): The kutils131 ListItem class
"""

def __init__(self, *args, **kwargs):
Expand All @@ -407,7 +408,7 @@ def __repr__(self):

def from_listitem(self, listitem: xbmcgui.ListItem):
"""
xbmcgui listitem -> kodi65 listitem
xbmcgui listitem -> kutils131 listitem
"""
info = listitem.getVideoInfoTag()
self.label = listitem.getLabel()
Expand Down
6 changes: 3 additions & 3 deletions script.extendedinfo/resources/kutil131/localdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def handle_movie(self, movie:dict) -> VideoItem:
'playcount': movie.get("playcount"),
'setid': movie.get("setid"),
'top250': movie.get("top250"),
'imdbnumber': movie.get("uniqueid").get("imdb", ""),
'imdbnumber': movie.get("uniqueid", {}).get("imdb", ""),
'userrating': movie.get('userrating'),
'trailer': trailer,
'rating': round(float(movie['rating']), 1),
Expand Down Expand Up @@ -413,7 +413,7 @@ def get_imdb_id(self, media_type, dbid):
data = kodijson.get_json(method="VideoLibrary.GetMovieDetails",
params={"properties": ["uniqueid", "title", "year"], "movieid": int(dbid)})
if "result" in data and "moviedetails" in data["result"]:
try:
try:
return data['result']['moviedetails']['uniqueid']['imdb']
except KeyError:
return None
Expand Down Expand Up @@ -441,7 +441,7 @@ def get_tmdb_id(self, media_type, dbid):
if "result" in data and "tvshowdetails" in data["result"]:
return data['result']['tvshowdetails']['uniqueid'].get('tmdb', None)
return None

def get_tvshow_id_by_episode(self, dbid):
if not dbid:
return None
Expand Down
56 changes: 45 additions & 11 deletions script.extendedinfo/resources/kutil131/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,52 @@ def __init__(self, *args, **kwargs):

def onPlayBackEnded(self):
self.stopped = True
self.started = False

def onPlayBackStopped(self):
self.stopped = True
self.started = False

def onPlayBackError(self):
self.stopped = True
self.started = False

def onAVStarted(self):
self.started = True
self.stopped = False

def onPlayBackStarted(self):
self.started = True
self.stopped = False

@busy.set_busy
def youtube_info_by_id(self, youtube_id):
vid = utils.get_youtube_info(youtube_id)
def youtube_info_by_id(self, youtube_id) -> None:
"""function uses inop YTStreamextractor
Args:
youtube_id (_type_): _description_
Returns:
_type_: function retained for future use
"""
#vid = utils.get_youtube_info(youtube_id)
vid = {}
if not vid:
return None, None
listitem = xbmcgui.ListItem(label=vid.title)
listitem.setArt({'thumb': vid.thumbnail})
listitem.setInfo(type='video',
infoLabels={"genre": vid.sourceName,
"plot": vid.description})
return vid.streamURL(), listitem
#listitem = xbmcgui.ListItem(label=vid.title)
#listitem.setArt({'thumb': vid.thumbnail})
#listitem.setInfo(type='video',
# infoLabels={"genre": vid.sourceName,
# "plot": vid.description})
#return vid.streamURL(), listitem

def wait_for_video_end(self):
monitor: xbmc.Monitor = xbmc.Monitor()
while not monitor.waitForAbort(1.0):
if monitor.abortRequested():
break
if self.stopped:
break

self.stopped = False

def wait_for_video_start(self):
Expand All @@ -53,11 +70,28 @@ def wait_for_video_start(self):
"""
monitor = xbmc.Monitor()
timeout = 15
while not monitor.waitForAbort(1.0): #wait 10 sec to see if video starts
while not monitor.waitForAbort(1.5): #wait to see if video starts
if monitor.abortRequested():
break
timeout += -1
if self.started:
break
if timeout == 0:
self.stopped = True
break

def wait_for_kodivideo_start(self):
"""Timer called from dialogmovieinfo that checks if Kodi can play selected listitem
Sets a 20 sec timer to attempt play local db media. If
timer ends videoplayer self.stopped is set
"""
monitor = xbmc.Monitor()
timeout = 20
while not monitor.waitForAbort(1): #wait to see if video starts
if monitor.abortRequested():
break
timeout += -1
if self.stopped or self.started:
if self.started:
break
if timeout == 0:
self.stopped = True
Expand Down
Loading

0 comments on commit b885046

Please sign in to comment.