2222from fll_sim .assets .mats import get_mat_for_season # noqa: E402
2323from fll_sim .environment .game_map import GameMap # noqa: E402
2424from fll_sim .scripts .fetch_mat import fetch_mat_image # noqa: E402
25+ from fll_sim .scripts .fetch_mat import fetch_mat_pdf
2526from fll_sim .visualization .simulator_view import SimulatorView # noqa: E402
2627
2728
@@ -77,6 +78,36 @@ def parse_args() -> argparse.Namespace:
7778 "assets/mats/<season>/mat.png"
7879 ),
7980 )
81+ p .add_argument (
82+ "--mat-pdf-url" ,
83+ default = None ,
84+ help = (
85+ "Remote URL to mat PDF. Rasterizes to PNG and caches under "
86+ "assets/mats/<season>/mat.png"
87+ ),
88+ )
89+ p .add_argument (
90+ "--mat-pdf-page" ,
91+ type = int ,
92+ default = 0 ,
93+ help = "PDF page index to rasterize (default 0)" ,
94+ )
95+ p .add_argument (
96+ "--mat-pdf-page-label" ,
97+ default = None ,
98+ help = "PDF page label to select (overrides index if found)" ,
99+ )
100+ p .add_argument (
101+ "--mat-pdf-toc-title" ,
102+ default = None ,
103+ help = "PDF TOC title to select (overrides index if found)" ,
104+ )
105+ p .add_argument (
106+ "--mat-pdf-dpi" ,
107+ type = int ,
108+ default = 300 ,
109+ help = "DPI for PDF rasterization (default 300)" ,
110+ )
80111 p .add_argument (
81112 "--px-per-mm" ,
82113 type = float ,
@@ -115,7 +146,7 @@ def main() -> None:
115146 # Resolve mat image
116147 mat_arg : Optional [str ] = args .mat_path
117148 mat_path = Path (mat_arg ) if mat_arg else None
118- if not mat_path and args .mat_url :
149+ if not mat_path and ( args .mat_url or args . mat_pdf_url ) :
119150 # Cache under assets/mats/<season>/mat.png
120151 cache_dir = (
121152 project_root
@@ -126,8 +157,22 @@ def main() -> None:
126157 cache_dir .mkdir (parents = True , exist_ok = True )
127158 mat_path = cache_dir / "mat.png"
128159 try :
129- print (f"Downloading mat from { args .mat_url } ..." )
130- fetch_mat_image (url = args .mat_url , out_path = mat_path )
160+ if args .mat_pdf_url :
161+ print (
162+ f"Downloading mat PDF from { args .mat_pdf_url } "
163+ f"(page={ args .mat_pdf_page } , dpi={ args .mat_pdf_dpi } )..."
164+ )
165+ fetch_mat_pdf (
166+ url = args .mat_pdf_url ,
167+ out_path = mat_path ,
168+ page = args .mat_pdf_page ,
169+ dpi = args .mat_pdf_dpi ,
170+ page_label = args .mat_pdf_page_label ,
171+ toc_title = args .mat_pdf_toc_title ,
172+ )
173+ else :
174+ print (f"Downloading mat from { args .mat_url } ..." )
175+ fetch_mat_image (url = args .mat_url , out_path = mat_path )
131176 print (f"Mat cached to { mat_path } " )
132177 except Exception as e : # noqa: BLE001
133178 print (f"Warning: Failed to download mat: { e } " )
0 commit comments