From 5b2cced50fea2f6368d6e52864a6b47578ba6af1 Mon Sep 17 00:00:00 2001 From: Moritz Schappler Date: Sun, 28 Nov 2021 10:42:02 +0100 Subject: [PATCH] [service.watchedlist] 1.3.5 (#2159) --- service.watchedlist/addon.xml | 2 +- service.watchedlist/changelog.txt | 3 + .../lib/watchedlist/watchedlist.py | 58 +++++++++---------- .../resource.language.de_de/strings.po | 4 +- .../resource.language.en_gb/strings.po | 2 +- .../resource.language.he_il/strings.po | 4 +- 6 files changed, 37 insertions(+), 36 deletions(-) diff --git a/service.watchedlist/addon.xml b/service.watchedlist/addon.xml index fbd89a38c3..f83b03adb6 100644 --- a/service.watchedlist/addon.xml +++ b/service.watchedlist/addon.xml @@ -1,7 +1,7 @@  diff --git a/service.watchedlist/changelog.txt b/service.watchedlist/changelog.txt index 7bf376483a..f97056bf08 100644 --- a/service.watchedlist/changelog.txt +++ b/service.watchedlist/changelog.txt @@ -1,3 +1,6 @@ +version 1.3.5 (28.11.2021) +* Fix for inconsistent imdb/tvdb numbers and new database format + version 1.3.4 (23.10.2021) * Fix for The Movie Database scraper diff --git a/service.watchedlist/lib/watchedlist/watchedlist.py b/service.watchedlist/lib/watchedlist/watchedlist.py index a9f68b43c1..a165ba97ad 100644 --- a/service.watchedlist/lib/watchedlist/watchedlist.py +++ b/service.watchedlist/lib/watchedlist/watchedlist.py @@ -148,8 +148,8 @@ def __init__(self, externalcall=False): self.watchedmovielist_xbmc = list([]) # 0imdbnumber, 1empty, 2empty, 3lastPlayed, 4playCount, 5title, 6empty, 7movieid self.watchedepisodelist_xbmc = list([]) # 0tvdbnumber, 1season, 2episode, 3lastplayed, 4playcount, 5name, 6empty, 7episodeid - self.tvshows = {} # dict: key=xbmcid, value=[imdbnumber, showname] - self.tvshownames = {} # dict: key=imdbnumber, value=showname + self.tvshows = {} # dict: key=xbmcid, value=[tvdbnumber, showname] + self.tvshownames = {} # dict: key=tvdbnumber, value=showname self.sqlcon_wl = 0 self.sqlcursor_wl = 0 @@ -588,7 +588,7 @@ def get_watched_xbmc(self, silent): "jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { - "properties": ["title", "imdbnumber"], + "properties": ["title", "uniqueid"], "sort": {"order": "ascending", "method": "title"} }, "id": 1}) @@ -598,23 +598,19 @@ def get_watched_xbmc(self, silent): self.close_db(3) return 4 tvshowId_xbmc = int(item['tvshowid']) + if not 'uniqueid' in item: + utils.log(u'get_watched_xbmc: tv show "%s" has no field uniqueid in database. tvshowid=%d. Try rescraping.' % (item['title'], tvshowId_xbmc), xbmc.LOGINFO) + continue try: - # check if series number is in imdb-format (scraper=imdb?) - res = re.compile(r'tt(\d+)').findall(item['imdbnumber']) - if not res: - # number in thetvdb-format - tvshowId_imdb = int(item['imdbnumber']) - else: - # number in imdb-format - tvshowId_imdb = int(res[0]) + tvshowId_tvdb = int(item['uniqueid']['tvdb']) except BaseException: - utils.log(u'get_watched_xbmc: tv show "%s" has no imdb-number in database. tvshowid=%d. Try rescraping.' % (item['title'], tvshowId_xbmc), xbmc.LOGINFO) + utils.log(u'get_watched_xbmc: tv show "%s" has no tvdb-number in database. tvshowid=%d. Unique IDs: %s. Try rescraping.' % (item['title'], tvshowId_xbmc, str(list(item['uniqueid'].keys()))), xbmc.LOGINFO) if not silent: utils.showNotification(utils.getString(32101), utils.getString(32297) % (item['title'], tvshowId_xbmc), xbmc.LOGINFO) - tvshowId_imdb = int(0) - self.tvshows[tvshowId_xbmc] = list([tvshowId_imdb, item['title']]) - if tvshowId_imdb > 0: - self.tvshownames[tvshowId_imdb] = item['title'] + tvshowId_tvdb = int(0) + self.tvshows[tvshowId_xbmc] = list([tvshowId_tvdb, item['title']]) + if tvshowId_tvdb > 0: + self.tvshownames[tvshowId_tvdb] = item['title'] # Get all watched movies and episodes by unique id from xbmc-database via JSONRPC self.watchedmovielist_xbmc = list([]) @@ -635,7 +631,7 @@ def get_watched_xbmc(self, silent): "jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { - "properties": ["title", "year", "imdbnumber", "lastplayed", "playcount"], + "properties": ["title", "year", "lastplayed", "playcount", "uniqueid"], "sort": {"order": "ascending", "method": "title"} }, "id": 1 @@ -645,7 +641,7 @@ def get_watched_xbmc(self, silent): "jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { - "properties": ["tvshowid", "season", "episode", "playcount", "showtitle", "lastplayed"] + "properties": ["tvshowid", "season", "episode", "playcount", "showtitle", "lastplayed", "uniqueid"] }, "id": 1 }) @@ -658,19 +654,21 @@ def get_watched_xbmc(self, silent): for item in json_response['result'][searchkey]: if self.monitor.abortRequested(): break + if not 'uniqueid' in item: + if modus == 'movie': + utils.log(u'get_watched_xbmc: Movie %s has no field uniqueid in database. Try rescraping.' % (item['title']), xbmc.LOGINFO) + else: # episode + utils.log(u'get_watched_xbmc: Episode id %d (show %d, S%02dE%02d) has no field uniqueid in database. Try rescraping.' % (item['episodeid'], item['tvshowid'], item['season'], item['episode']), xbmc.LOGINFO) + continue if modus == 'movie': name = item['title'] + ' (' + str(item['year']) + ')' try: # check if movie number is in imdb-format (scraper=imdb) - res = re.compile(r'tt(\d+)').findall(item['imdbnumber']) - if not res: - # movie number is in themoviedb format - imdbId = int(item['imdbnumber']) - else: - imdbId = int(res[0]) + res = re.compile(r'tt(\d+)').findall(item['uniqueid']['imdb']) + imdbId = int(res[0]) except BaseException: - # no imdb-number or themoviedb-number for this movie in database. Skip - utils.log(u'get_watched_xbmc: Movie %s has no imdb-number or themoviedb-number in database. movieid=%d. Try rescraping' % (name, int(item['movieid'])), xbmc.LOGINFO) + # no imdb-number for this movie in database. Skip + utils.log(u'get_watched_xbmc: Movie %s has no imdb-number in database. movieid=%d. IDs are %s. Try rescraping' % (name, int(item['movieid']), str(list(item['uniqueid'].keys()))), xbmc.LOGINFO) imdbId = 0 continue else: # episodes @@ -683,12 +681,12 @@ def get_watched_xbmc(self, silent): continue name = '%s S%02dE%02d' % (tvshowName_xbmc, item['season'], item['episode']) try: - tvshowId_imdb = self.tvshows[tvshowId_xbmc][0] + tvshowId_tvdb = self.tvshows[tvshowId_xbmc][0] except BaseException: utils.log(u'get_watched_xbmc: Kodi tv showid %d is not in Kodi-table tvshows. Skipping episode id %d (%s)' % (item['tvshowid'], item['episodeid'], name), xbmc.LOGINFO) continue - if tvshowId_imdb == 0: - utils.log(u'get_watched_xbmc: tvshow %d has no imdb-number. Skipping episode id %d (%s)' % (item['tvshowid'], item['episodeid'], name), xbmc.LOGDEBUG) + if tvshowId_tvdb == 0: + utils.log(u'get_watched_xbmc: tvshow %d has no tvdb-number. Skipping episode id %d (%s)' % (item['tvshowid'], item['episodeid'], name), xbmc.LOGDEBUG) continue lastplayed = utils.sqlDateTimeToTimeStamp(item['lastplayed']) # convert to integer-timestamp playcount = int(item['playcount']) @@ -696,7 +694,7 @@ def get_watched_xbmc(self, silent): if modus == 'movie': self.watchedmovielist_xbmc.append(list([imdbId, 0, 0, lastplayed, playcount, name, 0, int(item['movieid'])])) # 0imdbnumber, 1empty, 2empty, 3lastPlayed, 4playCount, 5title, 6empty, 7movieid else: - self.watchedepisodelist_xbmc.append(list([tvshowId_imdb, int(item['season']), int(item['episode']), lastplayed, playcount, name, 0, int(item['episodeid'])])) # 0tvdbnumber, 1season, 2episode, 3lastplayed, 4playcount, 5name, 6empty, 7episodeid + self.watchedepisodelist_xbmc.append(list([tvshowId_tvdb, int(item['season']), int(item['episode']), lastplayed, playcount, name, 0, int(item['episodeid'])])) # 0tvdbnumber, 1season, 2episode, 3lastplayed, 4playcount, 5name, 6empty, 7episodeid if not silent: utils.showNotification(utils.getString(32101), utils.getString(32299) % (len(self.watchedmovielist_xbmc), len(self.watchedepisodelist_xbmc)), xbmc.LOGINFO) if self.monitor.abortRequested(): diff --git a/service.watchedlist/resources/language/resource.language.de_de/strings.po b/service.watchedlist/resources/language/resource.language.de_de/strings.po index 08e8f7ba9e..3eeb7c43b4 100644 --- a/service.watchedlist/resources/language/resource.language.de_de/strings.po +++ b/service.watchedlist/resources/language/resource.language.de_de/strings.po @@ -253,8 +253,8 @@ msgid "Access denied (user '%s', DB '%s')" msgstr "Zugriff verweigert (Benutzer '%s', DB '%s')" msgctxt "#32297" -msgid "TV-Show \"%s\" (ID %d) has no imdb-number. No processing with WL possible. Try rescraping." -msgstr "TV-Serie \"%s\" (ID %d) hat keine imdb-Nummer. Keine Verarbeitung mit WL möglich." +msgid "TV-Show \"%s\" (ID %d) has no tvdb-number. No processing with WL possible. Try rescraping." +msgstr "TV-Serie \"%s\" (ID %d) hat keine tvdb-Nummer. Keine Verarbeitung mit WL möglich." msgctxt "#32298" msgid "%d movies and %d episodes read from WL." diff --git a/service.watchedlist/resources/language/resource.language.en_gb/strings.po b/service.watchedlist/resources/language/resource.language.en_gb/strings.po index f92a017741..e64d9df329 100644 --- a/service.watchedlist/resources/language/resource.language.en_gb/strings.po +++ b/service.watchedlist/resources/language/resource.language.en_gb/strings.po @@ -269,7 +269,7 @@ msgstr "" # empty strings from id 32211 to 32296 msgctxt "#32297" -msgid "TV-Show \"%s\" (ID %d) has no imdb-number. No processing with WL possible. Try rescraping." +msgid "TV-Show \"%s\" (ID %d) has no tvdb-number. No processing with WL possible. Try rescraping." msgstr "" msgctxt "#32298" diff --git a/service.watchedlist/resources/language/resource.language.he_il/strings.po b/service.watchedlist/resources/language/resource.language.he_il/strings.po index f4ab7c5045..610f7762d5 100644 --- a/service.watchedlist/resources/language/resource.language.he_il/strings.po +++ b/service.watchedlist/resources/language/resource.language.he_il/strings.po @@ -268,8 +268,8 @@ msgstr "הגישה נדחתה (המשתמש '%s', DB '%s')" # empty strings from id 32211 to 32296 msgctxt "#32297" -msgid "TV-Show \"%s\" (ID %d) has no imdb-number. No processing with WL possible. Try rescraping." -msgstr "סדרות \"%s\" (מזהה %d) אין מספר-imdb. אין אפשרות לעבד עם WL. נסה לבצע סקרייפינג מחדש." +msgid "TV-Show \"%s\" (ID %d) has no tvdb-number. No processing with WL possible. Try rescraping." +msgstr "סדרות \"%s\" (מזהה %d) אין מספר-tvdb. אין אפשרות לעבד עם WL. נסה לבצע סקרייפינג מחדש." msgctxt "#32298" msgid "%d movies and %d episodes read from WL."