|
23 | 23 | from pygments import highlight |
24 | 24 | from pygments.formatters import TerminalFormatter |
25 | 25 | from pygments.lexers import PythonTracebackLexer |
26 | | -from urllib3.util.retry import Retry |
27 | 26 |
|
28 | 27 | # Add parent directory so shared can be imported |
29 | 28 | sys.path.append(os.path.join(os.path.dirname(__file__), "..")) |
@@ -64,24 +63,6 @@ def parse_arguments(): |
64 | 63 | return args |
65 | 64 |
|
66 | 65 |
|
67 | | -def get_archive_session(): |
68 | | - retry_strategy = Retry( |
69 | | - total=5, |
70 | | - backoff_factor=10, |
71 | | - status_forcelist=shared.STATUS_FORCELIST, |
72 | | - allowed_methods=["GET", "POST"], |
73 | | - raise_on_status=False, |
74 | | - ) |
75 | | - adapter_kwargs = { |
76 | | - "max_retries": retry_strategy, |
77 | | - } |
78 | | - session = ArchiveSession(http_adapter_kwargs=adapter_kwargs) |
79 | | - session.headers.update( |
80 | | - {"User-Agent": shared.USER_AGENT, "Accept": "application/json"} |
81 | | - ) |
82 | | - return session |
83 | | - |
84 | | - |
85 | 66 | def load_license_mapping(): |
86 | 67 | """Loads and normalizes the license mapping from CSV.""" |
87 | 68 | license_mapping = {} |
@@ -174,7 +155,7 @@ def iso639_lookup(term): |
174 | 155 |
|
175 | 156 |
|
176 | 157 | # strip common noise like "subtitles", "subtitle", |
177 | | -# "(English)", "english patch", "handwritten", etc |
| 158 | +# "(English)", "english patch", "handwritten", etc. |
178 | 159 | def strip_noise(s): |
179 | 160 | # Helper to find words with flexible boundaries |
180 | 161 | def word_regex(word): |
@@ -330,7 +311,9 @@ def query_internet_archive(args): |
330 | 311 | total_processed = 0 |
331 | 312 | max_retries = 3 |
332 | 313 |
|
333 | | - session = get_archive_session() |
| 314 | + session = shared.get_session( |
| 315 | + accept_header="application/json", session=ArchiveSession() |
| 316 | + ) |
334 | 317 | while True: |
335 | 318 | # Loop until no more results are returned by the API |
336 | 319 | LOGGER.info(f"Fetching {rows} items starting at {total_rows}...") |
|
0 commit comments