Skip to content

Commit 7af431d

Browse files
committed
Fix script path detection for a stand-alone executable
1 parent 62c9d2f commit 7af431d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

imdb_backup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import re
5+
import sys
56
import time
67
import zipfile
78
from pathlib import Path
@@ -31,7 +32,9 @@ def slugify(s: str) -> str:
3132

3233

3334
def load_imdb_cookies():
34-
script_path = Path(__file__).resolve().parent
35+
"""Read an IMDb 'id' cookie from the folder containing the script or executable."""
36+
# https://pyinstaller.readthedocs.io/en/stable/runtime-information.html#using-sys-executable-and-sys-argv-0
37+
script_path = Path(sys.argv[0]).resolve().parent
3538
cookie_path = script_path / COOKIE_FNAME
3639

3740
if cookie_path.exists():

0 commit comments

Comments
 (0)