lukearran / tvtimetotrakt Goto Github PK
View Code? Open in Web Editor NEWA Python script to import TV Time data into Trakt.TV
License: MIT License
A Python script to import TV Time data into Trakt.TV
License: MIT License
Hello,
I am getting the following error message:
C:\Users\USERNAME\Downloads\TvTimeToTrakt-main>python TimeToTrakt.py
Traceback (most recent call last):
File "C:\Users\USERNAME\Downloads\TvTimeToTrakt-main\TimeToTrakt.py", line 65, in
config = get_configuration()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\USERNAME\Downloads\TvTimeToTrakt-main\TimeToTrakt.py", line 47, in get_configuration
data = json.load(f)
^^^^^^^^^^^^
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\json_init_.py", line 293, in load
return loads(fp.read(),
^^^^^^^^^^^^^^^^
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Invalid \escape: line 4 column 31 (char 206)
Hi,
I'm having the following error after executing the script:
Traceback (most recent call last):
File "/home/filipe/TvTimeToTrakt-main/TimeToTrakt.py", line 65, in <module>
config = getConfiguration()
File "/home/filipe/TvTimeToTrakt-main/TimeToTrakt.py", line 53, in getConfiguration
data = json.load(f)
File "/usr/lib/python3.9/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 5 column 23 (char 264)
Thank you
2023-07-07 16:41:04 [ INFO] :: Processing both watched shows and movies.
Traceback (most recent call last):
File "C:\TvTimeToTrakt-main\TimeToTrakt.py", line 164, in
start()
File "C:\TvTimeToTrakt-main\TimeToTrakt.py", line 157, in start
process_watched_shows()
File "C:\TvTimeToTrakt-main\TimeToTrakt.py", line 87, in process_watched_shows
total_rows = len(list(reader))
^^^^^^^^^^^^
File "C:\Users\prophamoon\AppData\Local\Programs\Python\Python311\Lib\csv.py", line 111, in next
row = next(self.reader)
^^^^^^^^^^^^^^^^^
File "C:\Users\prophamoon\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 2817: character maps to
Thank you for creating this useful tool. I tried using it and got this error:
What do you want to do?
1) Import Watch History from TV Time
Enter your menu selection: 1
Traceback (most recent call last):
File "/home/mr_4braham/transfer/TimeToTrakt.py", line 452, in
start()
File "/home/mr_4braham/transfer/TimeToTrakt.py", line 440, in start
processWatchedShows()
File "/home/mr_4braham/transfer/TimeToTrakt.py", line 330, in processWatchedShows
tvShowDateWatchedConverted = datetime.strptime(
File "/usr/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/lib/python3.9/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data 'episode_season_number' does not match format '%Y-%m-%d %H:%M:%S'
Hi, I get the error on run for line nine:
import trakt.core
Traceback (most recent call last):
File "c:\tvtimetotrakt\timetotrakt.py", line 9, in <module>
import trakt.core
ModuleNotFoundError: No module named 'trakt'
Any ideas?
I have the following error when I execute TimeToTrakt.py :
2024-03-09 23:13:11 [ INFO] :: Processing both watched shows and movies.
Traceback (most recent call last):
File "/Users/weezy/Desktop/TvTimeToTrakt-main/TimeToTrakt.py", line 164, in
start()
File "/Users/weezy/Desktop/TvTimeToTrakt-main/TimeToTrakt.py", line 157, in start
process_watched_shows()
File "/Users/weezy/Desktop/TvTimeToTrakt-main/TimeToTrakt.py", line 85, in process_watched_shows
with open(WATCHED_SHOWS_PATH, newline="") as csvfile:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/weezy/Desktop/tv-time-personal-data/seen_episode.csv'
None of the shows I had to choose the correct version was marked. Was that supposed to happen after it finished with everything? Is this error why that never happened?
...
2023-11-30 06:49:55 [ INFO] :: (99.92%) - Processing 'Twisted Metal' Season 1 / Episode 8
2023-11-30 06:49:55 [ INFO] :: 'Twisted Metal Season 1, Episode 8' marked as seen
2023-11-30 06:49:56 [ INFO] :: (99.95%) - Processing 'Twisted Metal' Season 1 / Episode 9
2023-11-30 06:49:57 [ INFO] :: 'Twisted Metal Season 1, Episode 9' marked as seen
2023-11-30 06:49:58 [ INFO] :: (99.97%) - Processing 'Twisted Metal' Season 1 / Episode 10
2023-11-30 06:49:59 [ INFO] :: 'Twisted Metal Season 1, Episode 10' marked as seen
Traceback (most recent call last):
File "C:\Users\u\Downloads\tvtime import\TvTimeToTrakt-main\TvTimeToTrakt-main\TimeToTrakt.py", line 164, in <module>
start()
File "C:\Users\u\Downloads\tvtime import\TvTimeToTrakt-main\TvTimeToTrakt-main\TimeToTrakt.py", line 158, in start
process_watched_movies()
File "C:\Users\u\Downloads\tvtime import\TvTimeToTrakt-main\TvTimeToTrakt-main\TimeToTrakt.py", line 100, in process_watched_movies
watched_list = [row["movie_name"] for row in reader if row["type"] == "watch"]
File "C:\Users\u\Downloads\tvtime import\TvTimeToTrakt-main\TvTimeToTrakt-main\TimeToTrakt.py", line 100, in <listcomp>
watched_list = [row["movie_name"] for row in reader if row["type"] == "watch"]
File "C:\Users\u\AppData\Local\Programs\Python\Python310\lib\csv.py", line 111, in __next__
row = next(self.reader)
File "C:\Users\u\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 5008: character maps to <undefined>
Sorry for the request, but I never used python or runned a python script.
Can you please add some detail about what to exactly? Like I installed python 3.12 from the ms store, but then how can I install the script?
A video would be perfect, but even a more detailed instruction would be perfect.
First off, thanks so much for this project! It was a lifesaver!
When importing movies from Tv Time, such as John Wick Chapter 5, which have no release date as of yet or Extraction (which was curiously left blank even though it came out almost 3 years ago), the data in tracking-prod-records.csv
column release_date
is left blank which results in the following error
Traceback (most recent call last):
File "C:\Users\noahv\Documents\TvTimeToTrakt\TimeToTrakt.py", line 164, in <module>
start()
File "C:\Users\noahv\Documents\TvTimeToTrakt\TimeToTrakt.py", line 154, in start
process_watched_movies()
File "C:\Users\noahv\Documents\TvTimeToTrakt\TimeToTrakt.py", line 108, in process_watched_movies
File "C:\Users\noahv\Documents\TvTimeToTrakt\searcher.py", line 147, in __init__
release_date = datetime.strptime(
^^^^^^^^^^^^^^^^^^
File "C:\Users\noahv\AppData\Local\Programs\Python\Python311\Lib\_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\noahv\AppData\Local\Programs\Python\Python311\Lib\_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '' does not match format '%Y-%m-%d %H:%M:%S'
Adding a release date to that column resolves the issue, as well as removing the entry all together and adding it manually into Trakt
Hi mate,
First, thanks for the work, definitely useful.
I have an issue with pytrakt.json :
FileNotFoundError: [Errno 2] No such file or directory: 'pytrakt.json'
I look at the py code, and indeed, line 39 you're calling it : with open(f"{Path.home()}/.pytrakt.json") as f:
I tried to create it manually, but I don't know what to put in.
I also put my config.json inside pytrakt.json, but nothing better.
Any ideas please ?
I am importing around 10,000 episodes, and have to frequently check back to see the status of the import, and it's literally taken me 48 hours and I'm at 5000 because I can't always be checking the terminal. Is it possible to make it so that the decisions for which show corresponds with the one in TV Time are delayed until the end. Any show that requires manual input to solve, skip, and once everything else is done, do the last 200 or whatever that require manual complex sorting.
I'm not sure if this repo is even active, but if this feature isn't taken up by a developer, I'll probably submit a pr myself for this.
Hello,
After running the script command, I got that:
line 4, in
from trakt import *
ModuleNotFoundError: No module named 'trakt'
C:\Users\Administrator\Desktop\TvTimeToTrakt-main>python TimeToTrakt.py
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\TvTimeToTrakt-main\TimeToTrakt.py", line 65, in <module>
config = getConfiguration()
File "C:\Users\Administrator\Desktop\TvTimeToTrakt-main\TimeToTrakt.py", line 53, in getConfiguration
data = json.load(f)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 293, in load
return loads(fp.read(),
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 4 column 31 (char 206)
C:\Users\Administrator\Desktop\TvTimeToTrakt-main>
I noticed this issue where the script seems to be lagging since it's not outputting anything. After a while it started to log again but it jumped quite in the percentage so I assumed something went wrong. Checked my TV Time csv and looked on the rows where it "lagged" and it turns out it was always on the shows I had to manually input which one to import.
I dug a bit in the code and it seems there is an error in searcher.py
line 204
. It checks if skip_show is None
instead of False
. I'm not sure if this is because of my python version (I'm using 3.9.5) and if in newer version False is considered None (I know C++ does this, but don't recall python having it like this). skip_show
is False
for those shows so I'm presumming this is a coding error. I changed it on my side and now all my show synced with no problem.
Thanks for making this script you've saved me!
I'm getting the following error when I run TimeToTrackt.py
Traceback (most recent call last):
File "C:\Users\....\TvTimeToTrakt-main\TimeToTrakt.py", line 10, in <module>
from trakt import init
ImportError: cannot import name 'init' from 'trakt' (C:\Users\....\Python\Python310\lib\site-packages\trakt\__init__.py)
the following error happened:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '' does not match format '%Y-%m-%d %H:%M:%S'
I suggest editing the TimeToTrakt.py as follows:
# Get the TV Time Episode Id
tvShowEpisodeId = row[2]
# Get the TV Time Season Number
tvShowSeasonNo = row[4]
# Get the TV Time Episode Number
tvShowEpisodeNo = row[5]
# Get the date which the show was marked 'watched' in TV Time
tvShowDateWatched = row[6]
# Parse the watched date value into a Python type
tvShowDateWatchedConverted = datetime.strptime(
tvShowDateWatched, '%Y-%m-%d %H:%M:%S')
It is possible for this script to automatically infer which TV show it is, by filtering out TV shows which have less seasons than the number of seasons watched
I'm having the following error after executing the script, but just for the movies import:
2023-04-18 23:56:44 [ INFO] :: Processing movies.
Traceback (most recent call last):
File "C:\Lhi\TvTimeToTrakt-main\TimeToTrakt.py", line 164, in <module>
start()
File "C:\Lhi\TvTimeToTrakt-main\TimeToTrakt.py", line 154, in start
process_watched_movies()
File "C:\Lhi\TvTimeToTrakt-main\TimeToTrakt.py", line 100, in process_watched_movies
watched_list = [row["movie_name"] for row in reader if row["type"] == "watch"]
File "C:\Lhi\TvTimeToTrakt-main\TimeToTrakt.py", line 100, in <listcomp>
watched_list = [row["movie_name"] for row in reader if row["type"] == "watch"]
File "C:\Users\billy\AppData\Local\Programs\Python\Python310\lib\csv.py", line 111, in __next__
row = next(self.reader)
File "C:\Users\billy\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 7616: character maps to <undefined>
Does someone know a workaround? Thank you!
Traceback (most recent call last):
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/TimeToTrakt.py", line 166, in <module>
start()
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/TimeToTrakt.py", line 156, in start
process_watched_movies()
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/TimeToTrakt.py", line 110, in process_watched_movies
movie = TVTimeMovie(row)
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/searcher.py", line 147, in __init__
release_date = datetime.strptime(
File "/usr/lib/python3.10/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/lib/python3.10/_strptime.py", line 534, in _strptime
julian = datetime_date(year, month, day).toordinal() - \
ValueError: year 0 is out of range
record that's triggering the exception
,08c1f0a2-581f-476c-bbd8-643a7426635f,follow,follow-08c1f0a2-581f-476c-bbd8-643a7426635f-0,3.695118e+07,,2020-01-18 01:16:12,2020-01-18 01:16:12,,,movie,,Avengers: Endgame,,0000-12-31 20:06:12,,,0,,,,,,,,,,,,
There're multiple entries like this, it would be great if you can replace the 0 with current date time or something
Because the dependency trakt3.4.0 is not anymore maintained by its original owner it's not anymore working and a new repository and a new module have been made and is currently maintained by a new owner.
Unmaintained dependency: https://pypi.org/project/trakt/
New maintained dependency: https://pypi.org/project/pytrakt/
For reference: moogar0880/PyTrakt#199
This happens on Peacemaker and Hawkeye (afaik). Here's the terminal output.
>> What do you want to do?
1) Import Watch History from TV Time
Enter your menu selection: 1
INFO - MANUAL INPUT REQUIRED: The TV Time data for Show 'Peacemaker' (Season 1, Episode 1) has 4 matching Trakt shows with the same name.
(1) Peacemaker - 2022 - 1 Season(s) - More Info: https://trakt.tv/shows/peacemaker-2022
(2) Peacemaker - 2020 - 1 Season(s) - More Info: https://trakt.tv/shows/peacemaker-2020
(3) Peacemakers - 2003 - 1 Season(s) - More Info: https://trakt.tv/shows/peacemakers
(4) Peacemakers - 2017 - 1 Season(s) - More Info: https://trakt.tv/shows/peacemakers-2017
Please make a selection from above (or enter SKIP):1
2022-09-16 15:08:18 [ INFO] :: (1/8) - Processing 'Peacemaker' Season 1 / Episode 1
2022-09-16 15:08:21 [ INFO] :: (2/8) - Processing 'Peacemaker' Season 1 / Episode 2
2022-09-16 15:08:23 [ INFO] :: (3/8) - Processing 'Peacemaker' Season 1 / Episode 3
2022-09-16 15:08:25 [ INFO] :: (4/8) - Processing 'Peacemaker' Season 1 / Episode 4
2022-09-16 15:08:27 [ INFO] :: (5/8) - Processing 'Peacemaker' Season 1 / Episode 5
2022-09-16 15:08:30 [ INFO] :: (6/8) - Processing 'Peacemaker' Season 1 / Episode 6
2022-09-16 15:08:32 [ INFO] :: (7/8) - Processing 'Peacemaker' Season 1 / Episode 7
2022-09-16 15:08:34 [ INFO] :: (8/8) - Processing 'Peacemaker' Season 1 / Episode 8
The result is
And for Hawkeye, it says processing 2021 but...
>> What do you want to do?
1) Import Watch History from TV Time
Enter your menu selection: 1
2022-09-16 15:19:31 [ INFO] :: (1/6) - Processing 'Hawkeye (2021)' Season 1 / Episode 1
2022-09-16 15:19:38 [ INFO] :: (2/6) - Processing 'Hawkeye (2021)' Season 1 / Episode 2
2022-09-16 15:19:41 [ INFO] :: (3/6) - Processing 'Hawkeye (2021)' Season 1 / Episode 3
2022-09-16 15:19:45 [ INFO] :: (4/6) - Processing 'Hawkeye (2021)' Season 1 / Episode 4
2022-09-16 15:19:48 [ INFO] :: (5/6) - Processing 'Hawkeye (2021)' Season 1 / Episode 5
2022-09-16 15:19:51 [ INFO] :: (6/6) - Processing 'Hawkeye (2021)' Season 1 / Episode 6
Hello,
I am getting the following error:
2024-02-02 12:28:29 [ INFO] :: Processing both watched shows and movies.
2024-02-02 12:28:31 [WARNING] :: (0.00%) - A JSON decode error occurred whilst processing TVSHOWNAMEISHERE This might occur when the server is down and has produced a HTML document instead of JSON. The script will wait 60 seconds before trying again.
Please advise?
Hi is there any way to import movies too? I just see TV shows importing
Hello,
I am getting the error: Failed to resolve 'api-v2launch.trakt.tv' ([Errno 11001] getaddrinfo failed)"))
The link ''https://api-v2launch.trakt.tv" does not work. When I manually enter "https://trakt.tv" with the rest of the link, it does work.
I can't find where to update this link? I checked all the .py files.
Does anyone know how to get this working?
Script worked great for most of my episodes and I'd like to thank all the contributors very much.
But for the other I've run into a weird problem where the script tells me an episode does not exist in Trakt.tv and provides a valid link for that episode.
I've modified a logging setup to log all those warnings into a file and this is what I got, maybe you'll manage to find a connection, if there is one.
trakt.log
2024-04-16 09:00:17 [INFO] :: Processing both watched shows and movies.
Traceback (most recent call last):
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/TimeToTrakt.py", line 166, in <module>
start()
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/TimeToTrakt.py", line 159, in start
process_watched_shows()
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/TimeToTrakt.py", line 87, in process_watched_shows
with open(WATCHED_SHOWS_PATH, newline="", encoding="UTF-8") as csvfile:
FileNotFoundError: [Errno 2] No such file or directory: '../tv-time-personal-data/seen_episode.csv'
I dont have that file, but user_tv_show_data is there, which contains similar data. Is there any chance they changed the file name?
I thought so, and replaced the file name. then this happened
2024-04-16 09:02:28 [INFO] :: Processing watched shows.
Traceback (most recent call last):
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/TimeToTrakt.py", line 166, in <module>
start()
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/TimeToTrakt.py", line 152, in start
process_watched_shows()
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/TimeToTrakt.py", line 95, in process_watched_shows
tv_time_show = TVTimeTVShow(row)
File "/mnt/c/users/sanjeev/desktop/trakt/TvTimeToTrakt/searcher.py", line 108, in __init__
super().__init__(row["tv_show_name"], row["updated_at"])
KeyError: 'updated_at'
which is already an open issue #48
Hi, Thanks for this amazing script! Just to let you know that TV Time probably changed the order of the columns in which the watched episodes are saved. I noticed when I got a date parsing error for the Tweet ID column.
Now the correct row number should be as following in line 317:
`
tvShowName = row[6]
# Ignore the header row
if tvShowName != "tv_show_name":
# Get the TV Time Episode Id
tvShowEpisodeId = row[1]
# Get the TV Time Season Number
tvShowSeasonNo = row[7]
# Get the TV Time Episode Number
tvShowEpisodeNo = row[8]
# Get the date which the show was marked 'watched' in TV Time
tvShowDateWatched = row[4]
# Parse the watched date value into a Python type
tvShowDateWatchedConverted = datetime.strptime(
tvShowDateWatched, '%Y-%m-%d %H:%M:%S')`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.