Skip to content

Commit

Permalink
Merge pull request #565 from quickmic/next-gen-dev-python3
Browse files Browse the repository at this point in the history
11.1.21, review changelog for details
  • Loading branch information
quickmic authored Jan 17, 2025
2 parents 0ff1a26 + 8be0c51 commit 4fa2269
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 143 deletions.
2 changes: 1 addition & 1 deletion 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="plugin.service.emby-next-gen" name="Emby for Kodi Next Gen" version="11.1.20" provider-name="quickmic">
<addon id="plugin.service.emby-next-gen" name="Emby for Kodi Next Gen" version="11.1.21" provider-name="quickmic">
<requires>
<import addon="xbmc.python" version="3.0.1"/>
<import addon="script.module.dateutil" version="2.8.1" />
Expand Down
11 changes: 11 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
11.1.21
=============
fix shuffle playback session info
fix lastplayed date updates when playcount was not modified
update Chinese langague file
fix sync when a content item has no name (invalid item reported by Emby server)
fix edge case http communication issue when Emby server connection was inerrupted
add warning message when Kodi companion addon is not installed on Emby server



11.1.20
=============
fix sync folder removal issue in native mode
Expand Down
4 changes: 4 additions & 0 deletions core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,10 @@ def delete_ContentItem(Item, SQLs, KodiType, EmbyType, isSpecial=False):
return False

def verify_content(Item, MediaType):
if 'Name' not in Item:
xbmc.log(f"EMBY.core.common: Name not found in Item {Item}", 3) # LOGERROR
return False

if 'Path' not in Item:
xbmc.log(f"EMBY.core.common: Path not found in Item {Item['Id']}", 3) # LOGERROR
return False
Expand Down
9 changes: 6 additions & 3 deletions database/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,12 @@ def KodiStartSync(self, Firstrun): # Threaded by caller -> emby.py
xbmc.log("EMBY.database.library: -->[ Kodi companion ]", 1) # LOGINFO
result = self.EmbyServer.API.get_sync_queue(self.LastSyncTime) # Kodi companion

if 'ItemsRemoved' in result and result['ItemsRemoved']:
UpdateSyncData = True
self.removed(result['ItemsRemoved'], True)
if 'ItemsRemoved' in result:
if result['ItemsRemoved']:
UpdateSyncData = True
self.removed(result['ItemsRemoved'], True)
else:
utils.Dialog.ok(utils.addon_name, utils.Translate(33716))

xbmc.log("EMBY.database.library: --<[ Kodi companion ]", 1) # LOGINFO
ProgressBarTotal = len(self.LibrarySynced) / 100
Expand Down
8 changes: 3 additions & 5 deletions database/video_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,12 +1244,10 @@ def update_bookmark_playstate(self, KodiFileId, playcount, date_played, Progress
self.cursor.execute("SELECT playCount FROM files WHERE idFile = ?", (KodiFileId,))
Data = self.cursor.fetchone()
CurrentPlayCount = Data[0]
self.cursor.execute("UPDATE files SET playCount = ?, lastPlayed = ? WHERE idFile = ?", (playcount, date_played, KodiFileId))

if CurrentPlayCount != playcount:
self.cursor.execute("UPDATE files SET playCount = ?, lastPlayed = ? WHERE idFile = ?", (playcount, date_played, KodiFileId))

if (CurrentPlayCount and playcount and playcount -1 != CurrentPlayCount) or (not playcount and CurrentPlayCount) or (not CurrentPlayCount and playcount):
Update = True
if (CurrentPlayCount != playcount) and ((CurrentPlayCount and playcount and playcount -1 != CurrentPlayCount) or (not playcount and CurrentPlayCount) or (not CurrentPlayCount and playcount)):
Update = True

return Update

Expand Down
13 changes: 9 additions & 4 deletions emby/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,16 @@ def socket_request(self, Method, Handler, Params, Binary, TimeoutSend, TimeoutRe
if ParamsString:
ParamsString = f"?{ParamsString[:-1]}"

StatusCodeSocket, _ = self.socket_io(f"{Method} {self.Connection[ConnectionId]['SubUrl']}{Handler}{ParamsString} HTTP/1.1\r\n{HeaderString}Content-Length: 0\r\n\r\n".encode("utf-8"), ConnectionId, TimeoutSend)
Request = f"{Method} {self.Connection[ConnectionId]['SubUrl']}{Handler}{ParamsString} HTTP/1.1\r\n{HeaderString}Content-Length: 0\r\n\r\n"
StatusCodeSocket, _ = self.socket_io(Request.encode("utf-8"), ConnectionId, TimeoutSend)
else:
if Params:
ParamsString = json.dumps(Params)
else:
ParamsString = ""

StatusCodeSocket, _ = self.socket_io(f"{Method} {self.Connection[ConnectionId]['SubUrl']}{Handler} HTTP/1.1\r\n{HeaderString}Content-Length: {len(ParamsString)}\r\n\r\n{ParamsString}".encode("utf-8"), ConnectionId, TimeoutSend)
Request = f"{Method} {self.Connection[ConnectionId]['SubUrl']}{Handler} HTTP/1.1\r\n{HeaderString}Content-Length: {len(ParamsString)}\r\n\r\n{ParamsString}"
StatusCodeSocket, _ = self.socket_io(Request.encode("utf-8"), ConnectionId, TimeoutSend)

if StatusCodeSocket:
return StatusCodeSocket, {}, ""
Expand Down Expand Up @@ -459,12 +461,15 @@ def socket_request(self, Method, Handler, Params, Binary, TimeoutSend, TimeoutRe
continue

IncomingData = IncomingData.split(b'\r\n\r\n', 1) # Split header/payload
IncomingMetaData = IncomingData[0].decode("utf-8").split("\r\n")

try:
IncomingMetaData = IncomingData[0].decode("utf-8").split("\r\n")
StatusCode = int(IncomingMetaData[0].split(" ")[1])
except Exception as error: # Can happen on Emby server hard reboot
xbmc.log(f"EMBY.emby.http: StatusCode error {ConnectionId}: Undefined error {error}", 3) # LOGERROR
xbmc.log(f"EMBY.emby.http: StatusCode error {ConnectionId}: Undefined error: {error}", 3) # LOGERROR
xbmc.log(f"EMBY.emby.http: StatusCode error {ConnectionId}: Binary: {Binary}", 3) # LOGERROR
xbmc.log(f"EMBY.emby.http: StatusCode error {ConnectionId}: Request: {Request}", 3) # LOGERROR
xbmc.log(f"EMBY.emby.http: StatusCode error {ConnectionId}: IncomingData: {IncomingData}", 3) # LOGERROR
return 612, {}, ""

IncomingDataHeaderArray = IncomingMetaData[1:]
Expand Down
6 changes: 3 additions & 3 deletions helper/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,13 +886,13 @@ def init_EmbyPlayback(KodiType, RunTimeTicks, PositionTicks, PlaylistPosition):

Ret = utils.SendJson('{"jsonrpc": "2.0", "id": 1, "method": "Player.GetProperties", "params": {"playerid": 0, "properties": ["repeat", "shuffled"]}}', False).get('result', {})
RepeatMode[0] = parse_repeat(Ret.get("repeat", "off"))
Shuffled[0] = parse_repeat(Ret.get("shuffled", False))
Shuffled[0] = Ret.get("shuffled", False)
Ret = utils.SendJson('{"jsonrpc": "2.0", "id": 1, "method": "Player.GetProperties", "params": {"playerid": 1, "properties": ["repeat", "shuffled"]}}', False).get('result', {})
RepeatMode[1] = parse_repeat(Ret.get("repeat", "off"))
Shuffled[1] = parse_repeat(Ret.get("shuffled", False))
Shuffled[1] = Ret.get("shuffled", False)
Ret = utils.SendJson('{"jsonrpc": "2.0", "id": 1, "method": "Player.GetProperties", "params": {"playerid": 2, "properties": ["repeat", "shuffled"]}}', False).get('result', {})
RepeatMode[2] = parse_repeat(Ret.get("repeat", "off"))
Shuffled[2] = parse_repeat(Ret.get("shuffled", False))
Shuffled[2] = Ret.get("shuffled", False)
SkipIntroDialog.set_JumpFunction(jump_Intro)
SkipIntroDialogEmbuary.set_JumpFunction(jump_Intro)
SkipCreditsDialog.set_JumpFunction(jump_Credits)
Expand Down
4 changes: 4 additions & 0 deletions resources/language/resource.language.cs_cz/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -3014,3 +3014,7 @@ msgstr "Podle časového limitu http"
msgctxt "#33715"
msgid "Set local content as default"
msgstr ""

msgctxt "#33716"
msgid "Kodi companion addon not installed on Emby server! Please install"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -3010,3 +3010,7 @@ msgstr "Folge http timeouts"
msgctxt "#33715"
msgid "Set local content as default"
msgstr ""

msgctxt "#33716"
msgid "Kodi companion addon not installed on Emby server! Please install"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -3014,3 +3014,7 @@ msgstr ""
msgctxt "#33715"
msgid "Set local content as default"
msgstr ""

msgctxt "#33716"
msgid "Kodi companion addon not installed on Emby server! Please install"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.es_es/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -3013,3 +3013,7 @@ msgstr "Seguir el tiempo de espera de http"
msgctxt "#33715"
msgid "Set local content as default"
msgstr ""

msgctxt "#33716"
msgid "Kodi companion addon not installed on Emby server! Please install"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.fr_fr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -3014,3 +3014,7 @@ msgstr "Suivre le délai d'attente http"
msgctxt "#33715"
msgid "Set local content as default"
msgstr ""

msgctxt "#33716"
msgid "Kodi companion addon not installed on Emby server! Please install"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.it_it/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -3014,3 +3014,7 @@ msgstr "Segui il timeout http"
msgctxt "#33715"
msgid "Set local content as default"
msgstr ""

msgctxt "#33716"
msgid "Kodi companion addon not installed on Emby server! Please install"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -3014,3 +3014,7 @@ msgstr "Volg http-time-out"
msgctxt "#33715"
msgid "Set local content as default"
msgstr ""

msgctxt "#33716"
msgid "Kodi companion addon not installed on Emby server! Please install"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.pl_pl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -3014,3 +3014,7 @@ msgstr "Przekroczono limit czasu protokołu http"
msgctxt "#33715"
msgid "Set local content as default"
msgstr ""

msgctxt "#33716"
msgid "Kodi companion addon not installed on Emby server! Please install"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.sv_se/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -3014,3 +3014,7 @@ msgstr "Följ http timeout"
msgctxt "#33715"
msgid "Set local content as default"
msgstr ""

msgctxt "#33716"
msgid "Kodi companion addon not installed on Emby server! Please install"
msgstr ""
Loading

0 comments on commit 4fa2269

Please sign in to comment.