diff --git a/addon.xml b/addon.xml index 4dceff04..a1414437 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/changelog.txt b/changelog.txt index cd56e45a..17fb1d89 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +version 3.1.3 + - bugfix for movies being rated with 1 on sync + - added fallback for dates outside of the unix timespan - they will now fall back to the current date/time + - fixed rating popup not showing up for content from external addons + version 3.1.2 - bugfix for movie playback progress sync diff --git a/scrobbler.py b/scrobbler.py index ffa4c9bf..838455c3 100644 --- a/scrobbler.py +++ b/scrobbler.py @@ -163,15 +163,16 @@ def playbackStarted(self, data): if utilities.getSettingAsBool('scrobble_movie') or utilities.getSettingAsBool('scrobble_episode'): result = self.__scrobble('start') elif utilities.getSettingAsBool('rate_movie') and utilities.isMovie(self.curVideo['type']) and 'ids' in self.curVideoInfo: - result = {'movie': self.traktapi.getMovieSummary(utilities.best_id(self.curVideoInfo['ids'])).to_dict()} - result['movie']['movieid'] = self.curVideo['id'] + best_id = utilities.best_id(self.curVideoInfo['ids']) + result = {'movie': self.traktapi.getMovieSummary(best_id).to_dict()} + if 'id' in self.curVideo: result['movie']['movieid'] = self.curVideo['id'] elif utilities.getSettingAsBool('rate_episode') and utilities.isEpisode(self.curVideo['type']) and 'ids' in self.traktShowSummary: best_id = utilities.best_id(self.traktShowSummary['ids']) result = {'show': self.traktapi.getShowSummary(best_id).to_dict(), 'episode': self.traktapi.getEpisodeSummary(best_id, self.curVideoInfo['season'], self.curVideoInfo['number']).to_dict()} result['episode']['season'] = self.curVideoInfo['season'] - result['episode']['episodeid']= self.curVideo['id'] + if 'id' in self.curVideo: result['episode']['episodeid'] = self.curVideo['id'] self.__preFetchUserRatings(result) diff --git a/service.py b/service.py index 617531e7..186b0297 100644 --- a/service.py +++ b/service.py @@ -450,10 +450,9 @@ def onPlayBackStarted(self): elif showtitle: title, season, episode = utilities.regex_tvshow(False, showtitle) data['type'] = 'episode' - data['season'] = int(season) - data['episode'] = int(episode) - data['showtitle'] = title - data['title'] = title + data['season'] = season + data['episode'] = episode + data['title'] = data['showtitle'] = title logger.debug("[traktPlayer] onPlayBackStarted() - Title: %s, showtitle: %s, season: %d, episode: %d" % (title, showtitle, season, episode)) else: logger.debug("[traktPlayer] onPlayBackStarted() - Non-library file, not enough data for scrobbling, skipping.") diff --git a/syncMovies.py b/syncMovies.py index fc3bc104..317dae29 100644 --- a/syncMovies.py +++ b/syncMovies.py @@ -86,9 +86,11 @@ def __compareMovies(self, movies_col1, movies_col2, watched=False, restrict=Fals if 'collected' in movie_col1 and movie_col1['collected']: if watched and (movie_col1['watched'] == 1): movies.append(movie_col1) - elif not watched: + elif rating and movie_col1['rating'] <> 0: movies.append(movie_col1) + elif not watched and not rating: + movies.append(movie_col1) return movies @@ -343,9 +345,7 @@ def __syncMovieRatings(self, traktMovies, kodiMovies, fromPercent, toPercent): self.sync.UpdateProgress(fromPercent, line1='', line2=utilities.getString(32180) % len(traktMoviesToUpdate)) - moviesRatings = {'movies': []} - for movie in traktMoviesToUpdate: - moviesRatings['movies'].append(movie) + moviesRatings = {'movies': traktMoviesToUpdate} self.sync.traktapi.addRating(moviesRatings) diff --git a/utilities.py b/utilities.py index 2fb33869..40e16931 100644 --- a/utilities.py +++ b/utilities.py @@ -26,21 +26,6 @@ logger = logging.getLogger(__name__) -REGEX_EXPRESSIONS = ['[Ss]([0-9]+)[][._-]*[Ee]([0-9]+)([^\\\\/]*)$', - '[\._ \-]([0-9]+)x([0-9]+)([^\\/]*)', # foo.1x09 - '[\._ \-]([0-9]+)([0-9][0-9])([\._ \-][^\\/]*)', # foo.109 - '([0-9]+)([0-9][0-9])([\._ \-][^\\/]*)', - '[\\\\/\\._ -]([0-9]+)([0-9][0-9])[^\\/]*', - 'Season ([0-9]+) - Episode ([0-9]+)[^\\/]*', # Season 01 - Episode 02 - 'Season ([0-9]+) Episode ([0-9]+)[^\\/]*', # Season 01 Episode 02 - '[\\\\/\\._ -][0]*([0-9]+)x[0]*([0-9]+)[^\\/]*', - '[[Ss]([0-9]+)\]_\[[Ee]([0-9]+)([^\\/]*)', # foo_[s01]_[e01] - '[\._ \-][Ss]([0-9]+)[\.\-]?[Ee]([0-9]+)([^\\/]*)', # foo, s01e01, foo.s01.e01, foo.s01-e01 - 's([0-9]+)ep([0-9]+)[^\\/]*', # foo - s01ep03, foo - s1ep03 - '[Ss]([0-9]+)[][ ._-]*[Ee]([0-9]+)([^\\\\/]*)$', - '[\\\\/\\._ \\[\\(-]([0-9]+)x([0-9]+)([^\\\\/]*)$' - ] - REGEX_YEAR = '^(.+) \((\d{4})\)$' REGEX_URL = '(^https?://)(.+)' @@ -311,38 +296,26 @@ def findMediaObject(mediaObjectToMatch, listToSearch): result = __findInList(listToSearch, title=mediaObjectToMatch['title'], year=mediaObjectToMatch['year']) return result -def regex_tvshow(compare, file, sub=""): - tvshow = 0 - - for regex in REGEX_EXPRESSIONS: - response_file = re.findall(regex, file) - if len(response_file) > 0: - logger.debug("regex_tvshow(): Regex File Se: %s, Ep: %s," % (str(response_file[0][0]), str(response_file[0][1]),)) - tvshow = 1 - if not compare: - title = re.split(regex, file)[0] - for char in ['[', ']', '_', '(', ')', '.', '-']: - title = title.replace(char, ' ') - if title.endswith(" "): - title = title[:-1] - return title, response_file[0][0], response_file[0][1] - else: - break - - if tvshow == 1: - for regex in REGEX_EXPRESSIONS: - response_sub = re.findall(regex, sub) - if len(response_sub) > 0: - try: - if int(response_sub[0][1]) == int(response_file[0][1]): - return True - except: - pass - return False - if compare: - return True - else: - return "", "", "" +def regex_tvshow(label): + regexes = [ + '(.*?)[._ -]s([0-9]+)[._ -]*e([0-9]+)', # ShowTitle.S01E09; s01e09, s01.e09, s01-e09 + '(.*?)[._ -]([0-9]+)x([0-9]+)', # Showtitle.1x09 + '(.*?)[._ -]([0-9]+)([0-9][0-9])', # ShowTitle.109 + '(.*?)[._ -]?season[._ -]*([0-9]+)[._ -]*-?[._ -]*episode[._ -]*([0-9]+)', # ShowTitle.Season 01 - Episode 02, Season 01 Episode 02 + '(.*?)[._ -]\[s([0-9]+)\][._ -]*\[[e]([0-9]+)', # ShowTitle_[s01]_[e01] + '(.*?)[._ -]s([0-9]+)[._ -]*ep([0-9]+)'] # ShowTitle - s01ep03, ShowTitle - s1ep03 + + for regex in regexes: + match = re.search(regex, label, re.I) + if match: + show_title, season, episode = match.groups() + if show_title: + show_title = re.sub('[\[\]_\(\).-]', ' ', show_title) + show_title = re.sub('\s\s+', ' ', show_title) + show_title = show_title.strip() + return show_title, int(season), int(episode) + + return '', -1, -1 def regex_year(title): prog = re.compile(REGEX_YEAR) @@ -571,14 +544,14 @@ def getMediaType(): def best_id(ids): if 'trakt' in ids: - return ids['trakt'], 'trakt' + return ids['trakt'] elif 'imdb' in ids: - return ids['imdb'], 'imdb' + return ids['imdb'] elif 'tmdb' in ids: - return ids['tmdb'], 'tmdb' + return ids['tmdb'] elif 'tvdb' in ids: - return ids['tvdb'], 'tvdb' + return ids['tvdb'] elif 'tvrage' in ids: - return ids['tvrage'], 'tvrage' + return ids['tvrage'] elif 'slug' in ids: - return ids['slug'], 'slug' + return ids['slug']