| … | … | @@ -253,6 +253,14 @@ def list_stremio_catalogs(menu_type="", sub_menu_type=""): |
| 253 | 253 | continue |
| 254 | 254 | |
| 255 | 255 | search_capabilities = any(extra.get("name") == "search" for extra in catalog.extra) |
| 256 | # A catalog whose search extra is REQUIRED has nothing to list without |
| 257 | # a query, so the plain browse row below can only ever come back empty. |
| 258 | # Upstream adds it unconditionally, which is where the dead second |
| 259 | # "Titles" row came from. |
| 260 | search_required = any( |
| 261 | extra.get("name") == "search" and extra.get("isRequired") |
| 262 | for extra in catalog.extra |
| 263 | ) |
| 256 | 264 | |
| 257 | 265 | if search_capabilities: |
| 258 | 266 | listitem = make_list_item(label=f"{translation(90006)} {catalog_name}") |
| … | … | @@ -276,7 +284,7 @@ def list_stremio_catalogs(menu_type="", sub_menu_type=""): |
| 276 | 284 | ) |
| 277 | 285 | ) |
| 278 | 286 | |
| 279 | | if catalog_name or catalog_id: |
| 287 | if not search_required and (catalog_name or catalog_id): |
| 280 | 288 | if addon.manifest.name == "Cinemeta": |
| 281 | 289 | label = f"{addon_name} - {catalog_name or catalog_id}" |
| 282 | 290 | else: |
| … | … | @@ -285,10 +293,16 @@ def list_stremio_catalogs(menu_type="", sub_menu_type=""): |
| 285 | 293 | listitem = make_list_item(label=label) |
| 286 | 294 | listitem.setArt({"icon": addon.manifest.logo}) |
| 287 | 295 | |
| 296 | # A catalog advertising genre options opens a picker first; |
| 297 | # entering it directly would filter by nothing. |
| 288 | 298 | directory_items.append( |
| 289 | 299 | ( |
| 290 | 300 | build_url( |
| 291 | | action="list_catalog", |
| 301 | action=( |
| 302 | "list_catalog_genres" |
| 303 | if getattr(catalog, "genres", None) |
| 304 | else "list_catalog" |
| 305 | ), |
| 292 | 306 | addon_url=addon.url(), |
| 293 | 307 | menu_type=menu_type, |
| 294 | 308 | sub_menu_type=sub_menu_type, |
| … | … | @@ -323,6 +337,46 @@ def _catalog_supports_extra(addon_url, catalog_type, catalog_id, extra_name): |
| 323 | 337 | return any(extra.get("name") == extra_name for extra in (catalog.extra or [])) |
| 324 | 338 | |
| 325 | 339 | |
| 340 | def list_catalog_genres(params): |
| 341 | """Render a catalog's declared genre options as a picker. |
| 342 | |
| 343 | Stremio addons advertise genres as `extra: [{name: "genre", options: [...]}]`, |
| 344 | and addon_manager parses them onto Catalog.genres -- but nothing ever offered |
| 345 | them to the user, so a genre-filtered catalog was unreachable: list_catalog |
| 346 | forwards a `genre` param that no menu ever set. Each entry here re-enters |
| 347 | list_catalog with the genre chosen. |
| 348 | """ |
| 349 | catalog = _get_manifest_catalog( |
| 350 | params["addon_url"], params["catalog_type"], params["catalog_id"] |
| 351 | ) |
| 352 | genres = getattr(catalog, "genres", None) or [] |
| 353 | if not genres: |
| 354 | notification(translation(90516)) |
| 355 | end_of_directory() |
| 356 | return |
| 357 | |
| 358 | directory_items = [] |
| 359 | for genre in genres: |
| 360 | listitem = make_list_item(label=genre) |
| 361 | directory_items.append( |
| 362 | ( |
| 363 | build_url( |
| 364 | "list_catalog", |
| 365 | addon_url=params["addon_url"], |
| 366 | menu_type=params["menu_type"], |
| 367 | sub_menu_type=params.get("sub_menu_type", ""), |
| 368 | catalog_type=params["catalog_type"], |
| 369 | catalog_id=params["catalog_id"], |
| 370 | genre=genre, |
| 371 | ), |
| 372 | listitem, |
| 373 | True, |
| 374 | ) |
| 375 | ) |
| 376 | add_directory_items_batch(directory_items) |
| 377 | end_of_directory() |
| 378 | |
| 379 | |
| 326 | 380 | def list_catalog(params): |
| 327 | 381 | content_type = "movies" if params["menu_type"] == "movie" else "tvshows" |
| 328 | 382 | setContent(ADDON_HANDLE, content_type) |