-
Notifications
You must be signed in to change notification settings - Fork 149
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
Support rewatch feature #631
base: main
Are you sure you want to change the base?
Conversation
@@ -777,3 +777,11 @@ msgstr "" | |||
#~ msgctxt "#32161" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do I generate the correct po files and add the missing translations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base translation file is en_gb
so you should only be editing that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm noticing errors in git due to there being a en_US
and en_us
language folder for example.
warning: the following paths have collided (e.g. case-sensitive paths
on a case-insensitive filesystem) and only one from the same
colliding group is in the working tree:
'resources/language/resource.language.es_AR/strings.po'
'resources/language/resource.language.es_ar/strings.po'
'resources/language/resource.language.es_MX/strings.po'
'resources/language/resource.language.es_mx/strings.po'
'resources/language/resource.language.nb_NO/strings.po'
'resources/language/resource.language.nb_no/strings.po'
'resources/language/resource.language.pt_BR/strings.po'
'resources/language/resource.language.pt_br/strings.po'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's probably a windows thing
resources/lib/kodiUtilities.py
Outdated
@@ -165,11 +165,13 @@ def kodiRpcToTraktMediaObject(type, data, mode='collected'): | |||
data['ids'] = utilities.guessBestTraktId(id, type)[0] | |||
|
|||
if 'lastplayed' in data: | |||
episode['watched_at'] = utilities.convertDateTimeToUTC( | |||
data['lastplayed']) | |||
episode['last_watched_at'] = utilities.to_iso8601_datetime( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key watched_at
was inconsistent with Trakt's last_watched_at
so I updated it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kodi's timestamps were in a different format from those the Trakt.py library provides so this was updated.
resources/lib/syncEpisodes.py
Outdated
show_dict = show.to_dict() | ||
# reset_at is not included when calling `.to_dict()` | ||
# but needed for watched shows to know whether to reset the watched state | ||
show_dict['reset_at'] = utilities.to_iso8601_datetime(show.reset_at) if hasattr(show, 'reset_at') else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reset_at
is now needed on a show, and while Show
extends Media
in the trakt.py library, it is not included when calling to_dict()
on a show.
resources/lib/utilities.py
Outdated
@@ -412,6 +422,13 @@ def compareEpisodes(shows_col1, shows_col2, matchByTitleAndYear, watched=False, | |||
if season in season_col2: | |||
b = season_col2[season] | |||
diff = list(set(a).difference(set(b))) | |||
for key in a: | |||
# update lastplayed in KODI if they don't match trakt | |||
if not key in b or a[key]['last_watched_at'] != b[key]['last_watched_at']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a 100% sure is this is the correct solution. This will update any out of date timestamps not just ones to be removed.
return local.strftime(dateFormat) | ||
else: | ||
return toConvert | ||
def to_datetime(value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced the existing datetime transformation methods with these 4 new ones, the iso8601 methods come from the trakt.py library.
A current limitation is that if Kodi doesn't properly scrobble a play on a rewatch, the play is removed from Kodi on next sync. |
@razzeee Do you have any ideas on how to overcome my mentioned limitation? So we can get this PR merged. |
99113f1
to
dd8d70b
Compare
This PR adds support for Trakt's rewatch feature. When enabled, the plugin will reset the
lastplayed
andplays
in Kodi's database when the value is lower than thereset_at
on the show provided by the Trakt API.This is achieved by iterating through the episode and settings the
last_watched_at
toNone
when thereset_at
is greater than thelast_watched_at
. This allows most logic of the plugin to remain unchanged.Fixes #292