monk-time / imdb-backup-lists

A simple tool to backup all your lists from IMDb including your watchlist and ratings.
MIT License
3 stars 1 forks source link

403 Client Error: Forbidden for url: https://www.imdb.com/user/ur123456789/lists #3

Open Kovah opened 4 days ago

Kovah commented 4 days ago

Hi, thanks for taking the time to create this little script. I was just searching for an easy way to export my data and found this. I followed the guide and everything went smoothly, but the script failed with the following error:

$ python imdb_backup.py --nopause

Successfully logged in as user ur123456789
Traceback (most recent call last):
  File "/Users/myuser/imdb-backup-lists-main/imdb_backup.py", line 214, in <module>
    pause_before_exit_unless_run_with_flag()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/myuser/imdb-backup-lists-main/imdb_backup.py", line 210, in pause_before_exit_unless_run_with_flag
    backup(cookie_path=args.path)
    ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/myuser/imdb-backup-lists-main/imdb_backup.py", line 170, in backup
    zip_all(export(ml, cookies) for ml in mlists)
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/myuser/imdb-backup-lists-main/imdb_backup.py", line 153, in zip_all
    for ml in mlists:
              ^^^^^^
  File "/Users/myuser/imdb-backup-lists-main/imdb_backup.py", line 170, in <genexpr>
    zip_all(export(ml, cookies) for ml in mlists)
                                          ^^^^^^
  File "/Users/myuser/imdb-backup-lists-main/imdb_backup.py", line 100, in fetch_lists_info
    r.raise_for_status()
    ~~~~~~~~~~~~~~~~~~^^
  File "/Users/myuser/imdb-backup-lists-main/venv/lib/python3.13/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://www.imdb.com/user/ur123456789/lists

(I replaced my user ID with ur123456789 for privacy reasons, but I can confirm that the ID is correct and the same as in the browser.)

I also tried to login again in another browser, it seems that only at-main was changing. However, the error persists. I would like to ask if there's something wrong with the script, or if that's caused by some account setting?

monk-time commented 4 days ago

Hi! The most likely explanation is that the script broke a few months ago when IMDb changed the way lists are exported. To quote AltoRetrato, another script author whose list-related script also broke:

Basically, before today (or whenever IMDb changed the list export system), there was a single URL to export each of your IMDb lists, and the script downloaded and used the data from them. Now, those URLs don't exist anymore, rendering the script unusable as it is. Exporting IMDb lists is now more complex and, most importantly, seems to be slower. So, even if I manage to use the new export system, the script could become almost unusable, especially for users with many large lists. Additionally, there could be other limits implemented in the new export system (e.g., a max total number of lists being exported at once or per day / week / month) that would only become apparent after spending time implementing the required changes.

Exporting a list on IMDb now places it in a queue that has to be accessed separately at imdb.com/exports/. Exported lists do seem to appear there instantly but it's no longer as simple as having a static URL to receive a file - now clicking the "Ready" button executes client-side JS that generates a link to AWS.

I think simulating all that in a script is possible but would require using heavier dependencies such as Selenium to emulate a web browser. The logic (placing an 'export order' and then waiting for a result to appear in the queue) would also become a bit more complex.

There are also potential obstacles that AltoRetrato mentions - if IMDb bothered to rework the exporting system it's quite likely they have put some limits in place that the script would have to take into account. Hopefully the limits are not too harsh - something like 5 exports per day means all I can do is export 5 lists, record what has been exported and then display a disappointing message "That's all I can do today, run me again tomorrow for the next 5!"

So overall it would take quite some effort to fix this and there's a risk that I won't succeed. If I find some time to investigate this further I'll post an update here, but in the meanwhile I suggest searching for alternative exporters that have been written/updated in the last six months. If you find any you're more than welcome to post a link here!

Kovah commented 4 days ago

Thank you so much for the detailed explanation. I manually exported the lists now.