Right now, the script syncs ratings into trakt, but does not mark them as watched. It would be nice to have that option.
If a rating is synced into trakt and there is no play count, it should be quite safe to assume the show should have been watched at least once to rate it, and it makes sense that the date when it was rated should not be too far apart from the real watching date most of the times.
However, as trakt allows for multiple play counts, and it behaves differently for movies or tv shows, the best idea might be to give those options to the user and save them in the settings. Some users may be interested in adding a play count to a movie, even also to individual episodes, but not to a whole tv show, which could mess with their progress in trakt.
Alternatives you've considered
I adapted part of the code in "IMDBTraktSyncer.py" to add the functionality by default when syncing ratings, because that is what I needed for my use case, and it works. It tries to add the date when it was rated as the watch date, and if there is none is found, it adds today's date.
You may use it if it helps:
# Set Trakt Ratings
if trakt_ratings_to_set:
print('Setting Trakt Ratings')
# Set the API endpoints
rate_url = "https://api.trakt.tv/sync/ratings"
watched_url = "https://api.trakt.tv/sync/history"
# Count the total number of items
num_items = len(trakt_ratings_to_set)
item_count = 0
# Loop through your data table and rate each item on Trakt
for item in trakt_ratings_to_set:
item_count += 1
data = None
watched_data = None
if item["Type"] == "show":
# This is a TV show
data = {
"shows": [{
"ids": {
"imdb": item["IMDB_ID"]
},
"rating": item["Rating"]
}]
}
watched_data = {
"shows": [{
"ids": {
"imdb": item["IMDB_ID"]
},
"watched_at": item.get("Date_Added", datetime.now().isoformat() + "Z")
}]
}
print(f" - Rating TV show ({item_count} of {num_items}): {item['Title']} ({item['Year']}): {item['Rating']}/10 on Trakt")
elif item["Type"] == "movie":
# This is a movie
data = {
"movies": [{
"ids": {
"imdb": item["IMDB_ID"]
},
"rating": item["Rating"]
}]
}
watched_data = {
"movies": [{
"ids": {
"imdb": item["IMDB_ID"]
},
"watched_at": item.get("Date_Added", datetime.now().isoformat() + "Z")
}]
}
print(f" - Rating movie ({item_count} of {num_items}): {item['Title']} ({item['Year']}): {item['Rating']}/10 on Trakt")
elif item["Type"] == "episode":
# This is an episode
data = {
"episodes": [{
"ids": {
"imdb": item["IMDB_ID"]
},
"rating": item["Rating"]
}]
}
watched_data = {
"episodes": [{
"ids": {
"imdb": item["IMDB_ID"]
},
"watched_at": item.get("Date_Added", datetime.now().isoformat() + "Z")
}]
}
print(f" - Rating episode ({item_count} of {num_items}): {item['Title']} ({item['Year']}): {item['Rating']}/10 on Trakt")
else:
print(f" - Skipping unknown type ({item_count} of {num_items}): {item['Title']} ({item['Year']})")
continue
if data:
# Make the API call to rate the item
response = EH.make_trakt_request(rate_url, payload=data)
if response is None:
error_message = f"Failed rating {item['Type']} ({item_count} of {num_items}): {item['Title']} ({item['Year']}): {item['Rating']}/10 on Trakt. IMDB ID not found: {item['IMDB_ID']}"
print(f" - {error_message}")
EL.logger.error(error_message)
if watched_data:
# Make the API call to mark item as watched
response = EH.make_trakt_request(watched_url, payload=watched_data)
if response is None:
error_message = f"Failed marking {item['Type']} as watched ({item_count} of {num_items}): {item['Title']} ({item['Year']}) on Trakt. IMDB ID not found: {item['IMDB_ID']}"
print(f" - {error_message}")
EL.logger.error(error_message)
print('Setting Trakt Ratings Complete')
else:
print('No Trakt Ratings To Set')
Is there already a request for your feature?
Feature Request
Right now, the script syncs ratings into trakt, but does not mark them as watched. It would be nice to have that option.
If a rating is synced into trakt and there is no play count, it should be quite safe to assume the show should have been watched at least once to rate it, and it makes sense that the date when it was rated should not be too far apart from the real watching date most of the times. However, as trakt allows for multiple play counts, and it behaves differently for movies or tv shows, the best idea might be to give those options to the user and save them in the settings. Some users may be interested in adding a play count to a movie, even also to individual episodes, but not to a whole tv show, which could mess with their progress in trakt.
Alternatives you've considered
I adapted part of the code in "IMDBTraktSyncer.py" to add the functionality by default when syncing ratings, because that is what I needed for my use case, and it works. It tries to add the date when it was rated as the watch date, and if there is none is found, it adds today's date. You may use it if it helps: