Skip to content

Commit 2bf1037

Browse files
committed
Update required cookies
1 parent 57597e7 commit 2bf1037

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A simple tool to backup all your lists from IMDb including your watchlist and ra
44

55
## Installation:
66

7-
The easiest way to run this tool on Windows is to download a portable executable from the [Releases](https://github.com/monk-time/imdb-backup-lists/releases) tab. The executable is created with PyInstaller but is *not* an installer.
7+
The easiest way to run this tool on Windows is to download a portable executable from the [Releases](https://github.com/monk-time/imdb-backup-lists/releases) tab. The executable is created with PyInstaller but is *not* an installer.
88

99
Otherwise you can run it from the source code:
1010

@@ -22,33 +22,34 @@ Otherwise you can run it from the source code:
2222
```
2323

2424
3. Download `imdb_backup.py` from the repo.
25-
25+
2626
## How to run:
2727

28-
1. Copy your IMDb `id` and `sid` cookies from your browser:
28+
1. Copy your IMDb `at-main`, `ubid-main` and `uu` cookies from your browser:
2929
1. Open any page on IMDb.
3030
2. Open Developer tools in your browser:
3131
- Firefox: ≡ → Web Developer → Storage Inspector<br><br>
3232
![Firefox](images/firefox.png)
3333
- Chrome: ⫶ → More tools → Developer tools → Application tab<br><br>
3434
![Chrome](images/chrome.png)
3535
3. Expand "Cookies" in the left panel and select `http://www.imdb.com`.
36-
4. Find rows named "id" and "sid", double click on their cells in the "Value" column and copy them.
37-
36+
4. Find rows named `at-main`, `ubid-main` and `uu`, double click on their cells in the "Value" column and copy them.
37+
3838
2. Create a new file `imdb_cookie.json` in the script directory and paste the following data into it, replacing ellipses with your cookies from the previous step:
3939
```json
4040
{
41-
"id": "...",
42-
"sid": "..."
41+
"at-main": "...",
42+
"ubid-main": "...",
43+
"uu": "..."
4344
}
44-
```
45+
```
4546

4647
3. Use any of the following steps to run the tool (depending on which file you've downloaded):
4748
- Executable (`imdb_backup.exe`):
4849
- double click on the file
4950
- or type `imdb_backup.exe --nopause` in the command line
5051
- Script (`imdb_backup.py`):
51-
- double click on the file
52+
- double click on the file
5253
- or type `python imdb_backup.py --nopause` in the command line
5354

5455
4. After the tool has finished running, `imdb_exported_lists.zip` should appear in your working directory.

imdb_backup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import unidecode
1313
from bs4 import BeautifulSoup
1414

15+
REQUIRED_COOKIES = {'at-main', 'ubid-main', 'uu'}
1516
COOKIE_FNAME = 'imdb_cookie.json'
1617
ZIP_FNAME = 'imdb_exported_lists.zip'
1718
README_REF = 'For more info check README.md.\n' \
@@ -36,8 +37,9 @@ def load_imdb_cookies(cookie_path):
3637
# https://pyinstaller.readthedocs.io/en/stable/runtime-information.html#using-sys-executable-and-sys-argv-0
3738
if cookie_path.exists():
3839
cookies = json.loads(cookie_path.read_text())
39-
if not ('id' in cookies and 'sid' in cookies):
40-
raise ValueError(f'\n\n{COOKIE_FNAME} must contain both "id" and "sid" cookies.')
40+
if not REQUIRED_COOKIES <= set(cookies):
41+
raise ValueError(f'\n\n{COOKIE_FNAME} must contain the following cookies: '
42+
f'{", ".join(REQUIRED_COOKIES)}.')
4143
return cookies
4244
else:
4345
raise FileNotFoundError(f'\n\nCreate a file "{COOKIE_FNAME}" in the script directory\n'

0 commit comments

Comments
 (0)