StegSchreck / RatS

Movie Ratings Synchronization with Python
GNU Affero General Public License v3.0
270 stars 31 forks source link

Transfer from Trakt to IMDB fails #222

Closed lead0r closed 6 months ago

lead0r commented 1 year ago

python3 transfer_ratings.py --source trakt --destination imdb

results in:

`===== Trakt: Parsing 2 pages with 115 movies in total 100% (115 of 115) |####################################################################################################################################################################################################################| Elapsed Time: 0:15:34 Time: 0:15:34

===== Trakt: saved 115 parsed movies to /RatS/RatS/exports/20221202123720_Trakt.json ===== IMDB: posting 115 movies

ERROR: There was an exception inside IMDB (see below). Skipping insertion.

===== ABORTING ===== Traceback (most recent call last): File "transfer_ratings.py", line 267, in insert_movie_ratings inserter.insert(movies, source) File "/RatS/RatS/base/base_ratings_inserter.py", line 51, in insert self._post_movie_rating(movie.site_data[source].my_rating) File "/RatS/RatS/base/base_ratings_inserter.py", line 155, in _post_movie_rating raise e File "/RatS/RatS/base/base_ratings_inserter.py", line 146, in _post_movie_rating self._click_rating(my_rating) File "/RatS/RatS/imdb/imdb_ratings_inserter.py", line 43, in _click_rating user_rating_button = self.site.browser.find_element( File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 861, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 444, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/errorhandler.py", line 249, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //div[@data-testid='hero-rating-bar__user-rating']/button`

Stacktrace:

RemoteError@chrome://remote/content/shared/RemoteError.jsm:12:1 WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:192:5 NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:404:5 element.find/</<@chrome://remote/content/marionette/element.js:291:16

System: MacOS with Docker image

intropedro commented 7 months ago

Same error:

❯ podman run --rm --name rats \
    -v /FOLDER/credentials.cfg:/RatS/RatS/credentials.cfg -v /EXPORTS:/RatS/RatS/exports \
    ghcr.io/stegschreck/rats/rats:latest \
    python3 transfer_ratings.py \
    --source Trakt \
    --destination Imdb --file /RatS/RatS/exports/20240406132442_Trakt.json
Exception managing firefox: Unable to discover proper geckodriver version in offline mode
===== Trakt: performing login
===== loaded 1234 movies from /RatS/RatS/exports//RatS/RatS/exports/20240406132442_Trakt.json
Exception managing firefox: Unable to discover proper geckodriver version in offline mode
===== IMDB: posting 1234 movies                     
  0% (0 of 1234) |                       | Elapsed Time: 0:00:00 ETA:  --:--:--
  0% (2 of 1234) |                       | Elapsed Time: 0:00:05 ETA:   0:56:54
  0% (3 of 1234) |                       | Elapsed Time: 0:00:11 ETA:   1:16:42
  0% (4 of 1234) |                       | Elapsed Time: 0:00:15 ETA:   1:20:51
  0% (5 of 1234) |                       | Elapsed Time: 0:00:21 ETA:   1:27:04
  0% (6 of 1234) |                       | Elapsed Time: 0:00:26 ETA:   1:29:42
  0% (7 of 1234) |                       | Elapsed Time: 0:00:31 ETA:   1:31:23
  0% (8 of 1234) |                       | Elapsed Time: 0:00:36 ETA:   1:33:27
  0% (9 of 1234) |                       | Elapsed Time: 0:00:42 ETA:   1:37:23
  0% (10 of 1234) |                      | Elapsed Time: 0:00:48 ETA:   1:38:36
  0% (11 of 1234) |                      | Elapsed Time: 0:00:53 ETA:   1:39:16
  0% (12 of 1234) |                      | Elapsed Time: 0:00:58 ETA:   1:39:35
  1% (13 of 1234) |                      | Elapsed Time: 0:01:03 ETA:   1:39:46
  1% (14 of 1234) |                      | Elapsed Time: 0:01:09 ETA:   1:41:07
  1% (15 of 1234) |                      | Elapsed Time: 0:01:14 ETA:   1:40:26
  1% (16 of 1234) |                      | Elapsed Time: 0:01:19 ETA:   1:40:38
  1% (17 of 1234) |                      | Elapsed Time: 0:01:24 ETA:   1:41:23
  1% (18 of 1234) |                      | Elapsed Time: 0:01:30 ETA:   1:41:52
  1% (19 of 1234) |                      | Elapsed Time: 0:01:35 ETA:   1:42:07
  1% (20 of 1234) |                      | Elapsed Time: 0:01:41 ETA:   1:42:20

ERROR: There was an exception inside IMDB (see below). Skipping insertion.
Traceback (most recent call last):
  File "/RatS/transfer_ratings.py", line 267, in insert_movie_ratings
    inserter.insert(movies, source)
  File "/RatS/RatS/base/base_ratings_inserter.py", line 51, in insert
    self._post_movie_rating(movie.site_data[source].my_rating)
  File "/RatS/RatS/base/base_ratings_inserter.py", line 155, in _post_movie_rating
    raise e
  File "/RatS/RatS/base/base_ratings_inserter.py", line 146, in _post_movie_rating
    self._click_rating(my_rating)
  File "/RatS/RatS/imdb/imdb_ratings_inserter.py", line 43, in _click_rating
    user_rating_button = self.site.browser.find_element(
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 741, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //div[@data-testid='hero-rating-bar__user-rating']/button; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8
WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:192:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:510:5
dom.find/</<@chrome://remote/content/shared/DOM.sys.mjs:136:16
intropedro commented 7 months ago

The mistake always happens in the same movie. Is there a way to tell it to skip it?

intropedro commented 7 months ago

The problem was that I had a film that hasn't been released on Trakt. This must have been a problem with the program that tells me the films and keeps the ratings for me in Trakt.

Eliminating that valuation has allowed me to do the migration.

You can see which movie fails with this command:

jq '.[INDEX]' FILE.json
StegSchreck commented 6 months ago

becomes obsolete with #306