Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,10 @@
- Adding test cases to validate the new cookie generation and caching logic

## v0.8.3
Fix bug in movie.year parsing
Fix bug person.knownfor parsing
- Fix bug in movie.year parsing
- Fix bug person.knownfor parsing

## v0.8.4
- Updated README
- feat: add debug script for WAF solver with detailed error logging
- Fix WAF challenge extraction and cookie generation logic to handle edge cases and improve reliability
70 changes: 36 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,42 @@ for cat in pg.categories:
print(f" - {txt.text} (SPOILER: {txt.is_spoiler})")
```

#### Awards

The package groups award-related counts in the `MovieDetail.awards` object (an `AwardInfo` instance). The model currently exposes:

- `wins` — number of award wins
- `nominations` — number of nominations (excluding wins)
- `prestigious_award` — optional dict containing details of a prestigious award (may include `wins` and `nominations` keys)

Example showing how to safely read `MovieDetail.awards` using the current model shape:

```python
from imdbinfo import get_movie

movie = get_movie("tt0133093") # The Matrix
aw = movie.awards
if not aw:
print("No award information available for this title")
else:
# basic counts
print("wins:", aw.wins)
print("nominations:", aw.nominations)

# prestigious award (may be None or a dict)
if aw.prestigious_award:
pa = aw.prestigious_award
print("prestigious wins:", pa.get("wins"))
print("prestigious nominations:", pa.get("nominations"))
else:
print("No prestigious award summary available")
```

Notes:
- The JSON parser maps page data into `movie.awards` (a dict turned into an `AwardInfo` instance). Depending on the source data, `prestigious_award` can be None or a dict with `wins` and `nominations`.
- Use `if movie.awards:` to check presence before reading attributes.


### Localized results in multiple languages (set globally or per request)

Added support for locales in `search_movie`, `get_movie`, `get_episodes`, `get_all_episodes`, `get_name`
Expand Down Expand Up @@ -305,37 +341,3 @@ Please read our [Contributing Guidelines](CONTRIBUTING.md) and [Code of Conduct]
imdbinfo is released under the MIT License.
See the [LICENSE](LICENSE) file for details.

#### Awards

The package groups award-related counts in the `MovieDetail.awards` object (an `AwardInfo` instance). The model currently exposes:

- `wins` — number of award wins
- `nominations` — number of nominations (excluding wins)
- `prestigious_award` — optional dict containing details of a prestigious award (may include `wins` and `nominations` keys)

Example showing how to safely read `MovieDetail.awards` using the current model shape:

```python
from imdbinfo import get_movie

movie = get_movie("tt0133093") # The Matrix
aw = movie.awards
if not aw:
print("No award information available for this title")
else:
# basic counts
print("wins:", aw.wins)
print("nominations:", aw.nominations)

# prestigious award (may be None or a dict)
if aw.prestigious_award:
pa = aw.prestigious_award
print("prestigious wins:", pa.get("wins"))
print("prestigious nominations:", pa.get("nominations"))
else:
print("No prestigious award summary available")
```

Notes:
- The JSON parser maps page data into `movie.awards` (a dict turned into an `AwardInfo` instance). Depending on the source data, `prestigious_award` can be None or a dict with `wins` and `nominations`.
- Use `if movie.awards:` to check presence before reading attributes.
92 changes: 92 additions & 0 deletions examples/usage_example_waf_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python
"""Debug script to test WAF solver and see actual errors."""

import sys
import logging
import traceback

# Enable detailed logging
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s:%(name)s:%(message)s")

# Patch the request_handler to show WAF solver errors
import imdbinfo.services as services
from imdbinfo.aws import AwsSolver

original_get_cookies = services.get_cookies


def patched_get_cookies(text, user_agent, force=False):
"""Patched version that shows full error details."""
try:
print("\n" + "=" * 80)
print("DEBUG: WAF solver starting...")
print("=" * 80)
print(f"Response HTML length: {len(text)}")
print(f"First 500 chars:\n{text[:500]}")
print("=" * 80)

solver = AwsSolver(user_agent=user_agent, domain="www.imdb.com")

# Try extract first
print("\nDEBUG: Attempting to extract goku and host...")
try:
goku, host = solver.extract(text)
print(
f"SUCCESS: Extracted goku (keys: {list(goku.keys()) if isinstance(goku, dict) else 'not a dict'}) and host: {host}"
)
except Exception as e:
print(f"ERROR in extract(): {e}")
traceback.print_exc()
raise

# Try get final values
print(f"\nDEBUG: Attempting to get final values from {host}...")
try:
values = solver._get_final_values(host)
print(f"SUCCESS: Got final values: {values}")
except Exception as e:
print(f"ERROR in _get_final_values(): {e}")
traceback.print_exc()
raise

# Try build payload
print("\nDEBUG: Attempting to build payload...")
try:
payload = solver._build_payload(values, goku)
print(f"SUCCESS: Built payload (keys: {list(payload.keys())})")
except Exception as e:
print(f"ERROR in _build_payload(): {e}")
traceback.print_exc()
raise

# Try post payload
print(f"\nDEBUG: Attempting to post payload to {host}...")
try:
temp = solver.post_payload(payload, host)
print(f"SUCCESS: Got response: {temp}")
return {"aws-waf-token": temp["token"]}
except Exception as e:
print(f"ERROR in post_payload(): {e}")
traceback.print_exc()
raise

except Exception as e:
print(f"\nERROR: WAF solver failed: {e}")
traceback.print_exc()
raise


# Monkey-patch
services.get_cookies = patched_get_cookies

# Now try to fetch a movie
from imdbinfo import get_movie

print("\nAttempting to fetch movie tt2112570...")
try:
movie = get_movie("tt2112570")
print(f"SUCCESS: {movie.title}")
except Exception as e:
print(f"FINAL ERROR: {e}")
traceback.print_exc()
sys.exit(1)
Loading