Add optional advanced flag to guess.py for debugging

This commit is contained in:
Zoe Roux 2024-04-28 13:00:17 +02:00
parent 283ba04f5e
commit 67cbf674b1
No known key found for this signature in database
2 changed files with 10 additions and 5 deletions

View File

@ -7,7 +7,7 @@ if __name__ == "__main__":
sys.path.append(str(Path(f"{__file__}/../../..").resolve())) sys.path.append(str(Path(f"{__file__}/../../..").resolve()))
from guessit.api import default_api from guessit.api import default_api
from typing import cast, List from typing import cast, List, Any
from rebulk import Rebulk from rebulk import Rebulk
try: try:
@ -20,14 +20,15 @@ rblk = cast(Rebulk, default_api.rebulk)
rblk.rules(rules) rblk.rules(rules)
def guessit(name: str, *, xem_titles: List[str] = []): def guessit(name: str, *, xem_titles: List[str] = [], extra_flags: dict[str, Any] = {}):
return default_api.guessit( return default_api.guessit(
name, name,
{ {
"episode_prefer_number": True, "episode_prefer_number": True,
"excludes": "language", "excludes": "language",
"xem_titles": xem_titles, "xem_titles": xem_titles,
}, }
| extra_flags,
) )
@ -44,7 +45,11 @@ if __name__ == "__main__":
async with ClientSession() as client: async with ClientSession() as client:
xem = TheXemClient(client) xem = TheXemClient(client)
ret = guessit(sys.argv[1], xem_titles=await xem.get_expected_titles()) ret = guessit(
sys.argv[1],
xem_titles=await xem.get_expected_titles(),
# extra_flags={"advanced": True},
)
print(json.dumps(ret, cls=GuessitEncoder, indent=4)) print(json.dumps(ret, cls=GuessitEncoder, indent=4))
asyncio.run(main()) asyncio.run(main())

View File

@ -1,5 +1,5 @@
{pkgs ? import <nixpkgs> {}}: let {pkgs ? import <nixpkgs> {}}: let
python = pkgs.python311.withPackages (ps: python = pkgs.python312.withPackages (ps:
with ps; [ with ps; [
guessit guessit
aiohttp aiohttp