mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix matcher/scanner issues
This commit is contained in:
parent
8d8e984669
commit
e4403cc17c
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
|
@ -26,7 +26,7 @@ logger = getLogger(__name__)
|
||||
class TheMovieDatabase(Provider):
|
||||
def __init__(
|
||||
self,
|
||||
languages,
|
||||
languages: list[str],
|
||||
client: ClientSession,
|
||||
api_key: str,
|
||||
xem: TheXem,
|
||||
|
@ -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
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import asyncio
|
||||
import matcher
|
||||
import scanner
|
||||
|
||||
asyncio.run(matcher.main())
|
||||
asyncio.run(scanner.main())
|
||||
|
Loading…
x
Reference in New Issue
Block a user