RileyXX / IMDB-Trakt-Syncer

A python script that syncs user watchlist, ratings and reviews for Movies, TV Shows and Episodes both ways between Trakt and IMDB.
MIT License
88 stars 2 forks source link

Unable to fetch IMDB watchlist data. #102

Open iPaulis opened 2 months ago

iPaulis commented 2 months ago

Is there already an issue for your problem?

Bug Description

I just run the script and this is what I get. My settings: "sync_watchlist": false, "sync_ratings": true, "remove_watched_from_watchlists": false, "sync_reviews": false

Besides, I don't understand why the script needs to fetch the watchlist, if I've already answered I'm not interested in that. Anyway, it gives the following error:

PS C:\Users\user> IMDBTraktSyncer Starting IMDBTraktSyncer.... Your settings are saved at: C:\Python312\Lib\site-packages\IMDBTraktSyncer Starting webdriver...

DevTools listening on ws://127.0.0.1:58817/devtools/browser/2245d918-1465-4cd0-96df-e92a8370f2f7 Successfully signed in to IMDB Processing Trakt Data Processing Trakt Data Complete Processing IMDB Data Unable to fetch IMDB watchlist data.

--- ERROR --- An error occurred while running the script. Please submit the error to GitHub with the following information:

Traceback (most recent call last): File "C:\Python312\Lib\site-packages\IMDBTraktSyncer\imdbData.py", line 121, in getImdbData raise FileNotFoundError("Watchlist data not found. No CSV files found in the directory") FileNotFoundError: Watchlist data not found. No CSV files found in the directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Python312\Lib\site-packages\IMDBTraktSyncer\IMDBTraktSyncer.py", line 128, in main imdb_watchlist, imdb_ratings, imdb_reviews, errors_found_getting_imdb_reviews = imdbData.getImdbData(imdb_username, imdb_password, driver, directory, wait) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\IMDBTraktSyncer\imdbData.py", line 163, in getImdbData print(f"Error: {error_message}", exc_info=True) ^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'error_message' where it is not associated with a value


Submit the error here: https://github.com/RileyXX/IMDB-Trakt-Syncer/issues/new?template=bug_report.yml

Environment

Win 10 Pip install

Screenshots

No response

iPaulis commented 2 months ago

I notice that the imdb export file for my watchlist is created almost instantly on imdb, but my ratings take a while, like a couple of minutes. The script gives me error #101 if I try to manually download and save my ratings in the script folder. However, if I manually save my watchlist csv, even though I'm not interested in it, it does this:

PS C:\Users\user> IMDBTraktSyncer Starting IMDBTraktSyncer.... Your settings are saved at: C:\Python312\Lib\site-packages\IMDBTraktSyncer Starting webdriver...

DevTools listening on ws://127.0.0.1:57426/devtools/browser/15e0ded0-3c25-49ae-8e5c-3819803ebbaa Successfully signed in to IMDB Processing Trakt Data Processing Trakt Data Complete Processing IMDB Data Unable to fetch IMDB watchlist data. Processing IMDB Data Complete No Trakt Ratings To Set Setting IMDB Ratings

So I guess it does not manage to download my ratings csv and says there is nothing to sync into trakt, which is not true, there are almost 2000 titles to sync. Then it tries to sync from trakt into imdb, which also fails.

iPaulis commented 2 months ago

OK, everything seems to be a language issue. My system language is Spanish, so my chrome loads the pages in spanish by default and the script was trying to find certain texts in english to navigate through the buttons and such, and it would have never worked. I partially fixed it in the code like in the line 54 in imdbData.py and some other instances: if "in progress" in item.text.lower() or "en curso" in item.text.lower():

But eventually I realized it would not be enough with a few fixes for spanish, because even the imdb export csv files are also in spanish, with the "Title type" column with values in spanish, and so on.

In the end I switched imdb into english, re-run everything with new exports and it fixed all the issues. Now everything seems to work fine.

You might want to consider adding a warning about setting imdb in english as a requirement, or ideally test if you can force webdriver chrome, or whatever part working in the background, to load the page always in english, regardless of the system language.

RileyXX commented 2 months ago

Thank you very much for reporting this. I see the issue you're having.

In a recent release the IMDB csv data structure changed and went unnoticed until a user noticed and reported it. A fix was implemented and part of the fix was some checks to try and prevent this from happening again in the future. This fix had to do with checking the colum names specifically to verify the correct format however alternate languages weren't taken into consideration. I'll look into this soon and figure out the best possible solution.