Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[service.watchedlist] 1.3.5 #2159

Merged
merged 1 commit into from Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion service.watchedlist/addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.watchedlist"
name="WatchedList"
version="1.3.4"
version="1.3.5"
provider-name="schapplm">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
Expand Down
3 changes: 3 additions & 0 deletions 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

Expand Down
58 changes: 28 additions & 30 deletions service.watchedlist/lib/watchedlist/watchedlist.py
Expand Up @@ -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
Expand Down Expand Up @@ -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})
Expand All @@ -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([])
Expand All @@ -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
Expand All @@ -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
})
Expand All @@ -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
Expand All @@ -683,20 +681,20 @@ 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'])
# add data to the class-variables
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():
Expand Down
Expand Up @@ -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."
Expand Down
Expand Up @@ -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"
Expand Down
Expand Up @@ -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."
Expand Down