-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfetch_top_list.py
More file actions
58 lines (47 loc) · 1.77 KB
/
fetch_top_list.py
File metadata and controls
58 lines (47 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""CLI entrypoint for Autobrr Top List scraper."""
import time
from autobrr_top_list import (
ContentProcessor,
IMDBScraper,
OutputManager,
ScraperConfig,
)
def main() -> None:
config = ScraperConfig()
print("Starting content fetching process...")
print(
f"Configuration: max_movies={config.max_movies}, max_tv_shows={config.max_tv_shows}, max_total={config.max_total_items}"
)
filters_applied = []
if config.min_year is not None:
filters_applied.append(f"min_year={config.min_year}")
if config.max_year is not None:
filters_applied.append(f"max_year={config.max_year}")
if config.min_rating is not None:
filters_applied.append(f"min_rating={config.min_rating}")
if config.max_rating is not None:
filters_applied.append(f"max_rating={config.max_rating}")
if filters_applied:
print(f"Active filters: {', '.join(filters_applied)}")
print(f"Movies URL: {config.imdb_movies_url}")
print(f"TV Shows URL: {config.imdb_tv_url}")
else:
print("No filters applied - fetching all popular content")
scraper = IMDBScraper(config)
processor = ContentProcessor()
output_manager = OutputManager(config)
try:
movies = scraper.fetch_popular_movies()
time.sleep(config.request_delay)
tv_shows = scraper.fetch_popular_tv_shows()
print(f"Found {len(movies)} movies and {len(tv_shows)} TV shows")
combined_list = processor.combine_and_rank_lists(
movies, tv_shows, config.max_total_items
)
output_manager.save_outputs(combined_list)
except Exception as e:
print(f"Error during execution: {e}")
output_manager.save_outputs([])
if __name__ == "__main__":
main()