Skip to content

Commit

Permalink
Update required cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
monk-time committed May 5, 2020
1 parent 57597e7 commit 2bf1037
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A simple tool to backup all your lists from IMDb including your watchlist and ra

## Installation:

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.
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.

Otherwise you can run it from the source code:

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

3. Download `imdb_backup.py` from the repo.

## How to run:

1. Copy your IMDb `id` and `sid` cookies from your browser:
1. Copy your IMDb `at-main`, `ubid-main` and `uu` cookies from your browser:
1. Open any page on IMDb.
2. Open Developer tools in your browser:
- Firefox: ≡ → Web Developer → Storage Inspector<br><br>
![Firefox](images/firefox.png)
- Chrome: ⫶ → More tools → Developer tools → Application tab<br><br>
![Chrome](images/chrome.png)
3. Expand "Cookies" in the left panel and select `http://www.imdb.com`.
4. Find rows named "id" and "sid", double click on their cells in the "Value" column and copy them.
4. Find rows named `at-main`, `ubid-main` and `uu`, double click on their cells in the "Value" column and copy them.

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:
```json
{
"id": "...",
"sid": "..."
"at-main": "...",
"ubid-main": "...",
"uu": "..."
}
```
```

3. Use any of the following steps to run the tool (depending on which file you've downloaded):
- Executable (`imdb_backup.exe`):
- double click on the file
- or type `imdb_backup.exe --nopause` in the command line
- Script (`imdb_backup.py`):
- double click on the file
- double click on the file
- or type `python imdb_backup.py --nopause` in the command line

4. After the tool has finished running, `imdb_exported_lists.zip` should appear in your working directory.
Expand Down
6 changes: 4 additions & 2 deletions imdb_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import unidecode
from bs4 import BeautifulSoup

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

0 comments on commit 2bf1037

Please sign in to comment.