diff --git a/scanner/matcher/matcher.py b/scanner/matcher/matcher.py index b8149b77..d09a4b80 100644 --- a/scanner/matcher/matcher.py +++ b/scanner/matcher/matcher.py @@ -34,7 +34,7 @@ class Matcher: async def identify(self, path: str): try: - await self.identify(path) + await self._identify(path) await self._client.delete_issue(path) except ProviderError as e: logger.error(e) diff --git a/scanner/matcher/subscriber.py b/scanner/matcher/subscriber.py index 035c09ee..126307c7 100644 --- a/scanner/matcher/subscriber.py +++ b/scanner/matcher/subscriber.py @@ -1,3 +1,4 @@ +import asyncio from dataclasses import dataclass from dataclasses_json import DataClassJsonMixin from typing import Literal @@ -34,22 +35,23 @@ class Subscriber: async def listen(self, scanner: Matcher): async def on_message(message: AbstractIncomingMessage): - async with message.process(): - msg = Message.from_json(message.body) - ack = False - match msg.action: - case "scan": - ack = await scanner.identify(msg.path) - case "delete": - ack = await scanner.delete(msg.path) - case _: - logger.error(f"Invalid action: {msg.action}") - if ack: - await message.ack() - else: - await message.nack(requeue=False) + msg = Message.from_json(message.body) + ack = False + match msg.action: + case "scan": + ack = await scanner.identify(msg.path) + case "delete": + ack = await scanner.delete(msg.path) + case _: + logger.error(f"Invalid action: {msg.action}") + if ack: + await message.ack() + else: + await message.reject() # Allow up to 20 scan requests to run in parallel on the same listener. # Since most work is calling API not doing that is a waste. await self._channel.set_qos(prefetch_count=20) await self._queue.consume(on_message) + await asyncio.Future() + diff --git a/scanner/providers/implementations/themoviedatabase.py b/scanner/providers/implementations/themoviedatabase.py index b3866da4..3f1c861e 100644 --- a/scanner/providers/implementations/themoviedatabase.py +++ b/scanner/providers/implementations/themoviedatabase.py @@ -26,7 +26,7 @@ logger = getLogger(__name__) class TheMovieDatabase(Provider): def __init__( self, - languages, + languages: list[str], client: ClientSession, api_key: str, xem: TheXem, diff --git a/scanner/providers/provider.py b/scanner/providers/provider.py index 545e2d21..5f5e7f53 100644 --- a/scanner/providers/provider.py +++ b/scanner/providers/provider.py @@ -20,6 +20,7 @@ class Provider: if not languages: print("Missing environment variable 'LIBRARY_LANGUAGES'.") exit(2) + languages = languages.split(",") providers = [] from providers.idmapper import IdMapper diff --git a/scanner/scanner/__main__.py b/scanner/scanner/__main__.py index 670779da..ac4e42e3 100644 --- a/scanner/scanner/__main__.py +++ b/scanner/scanner/__main__.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import asyncio -import matcher +import scanner -asyncio.run(matcher.main()) +asyncio.run(scanner.main())