mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-30 19:54:16 -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):
|
async def identify(self, path: str):
|
||||||
try:
|
try:
|
||||||
await self.identify(path)
|
await self._identify(path)
|
||||||
await self._client.delete_issue(path)
|
await self._client.delete_issue(path)
|
||||||
except ProviderError as e:
|
except ProviderError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import asyncio
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from dataclasses_json import DataClassJsonMixin
|
from dataclasses_json import DataClassJsonMixin
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
@ -34,22 +35,23 @@ class Subscriber:
|
|||||||
|
|
||||||
async def listen(self, scanner: Matcher):
|
async def listen(self, scanner: Matcher):
|
||||||
async def on_message(message: AbstractIncomingMessage):
|
async def on_message(message: AbstractIncomingMessage):
|
||||||
async with message.process():
|
msg = Message.from_json(message.body)
|
||||||
msg = Message.from_json(message.body)
|
ack = False
|
||||||
ack = False
|
match msg.action:
|
||||||
match msg.action:
|
case "scan":
|
||||||
case "scan":
|
ack = await scanner.identify(msg.path)
|
||||||
ack = await scanner.identify(msg.path)
|
case "delete":
|
||||||
case "delete":
|
ack = await scanner.delete(msg.path)
|
||||||
ack = await scanner.delete(msg.path)
|
case _:
|
||||||
case _:
|
logger.error(f"Invalid action: {msg.action}")
|
||||||
logger.error(f"Invalid action: {msg.action}")
|
if ack:
|
||||||
if ack:
|
await message.ack()
|
||||||
await message.ack()
|
else:
|
||||||
else:
|
await message.reject()
|
||||||
await message.nack(requeue=False)
|
|
||||||
|
|
||||||
# Allow up to 20 scan requests to run in parallel on the same listener.
|
# 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.
|
# Since most work is calling API not doing that is a waste.
|
||||||
await self._channel.set_qos(prefetch_count=20)
|
await self._channel.set_qos(prefetch_count=20)
|
||||||
await self._queue.consume(on_message)
|
await self._queue.consume(on_message)
|
||||||
|
await asyncio.Future()
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ logger = getLogger(__name__)
|
|||||||
class TheMovieDatabase(Provider):
|
class TheMovieDatabase(Provider):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
languages,
|
languages: list[str],
|
||||||
client: ClientSession,
|
client: ClientSession,
|
||||||
api_key: str,
|
api_key: str,
|
||||||
xem: TheXem,
|
xem: TheXem,
|
||||||
|
@ -20,6 +20,7 @@ class Provider:
|
|||||||
if not languages:
|
if not languages:
|
||||||
print("Missing environment variable 'LIBRARY_LANGUAGES'.")
|
print("Missing environment variable 'LIBRARY_LANGUAGES'.")
|
||||||
exit(2)
|
exit(2)
|
||||||
|
languages = languages.split(",")
|
||||||
providers = []
|
providers = []
|
||||||
|
|
||||||
from providers.idmapper import IdMapper
|
from providers.idmapper import IdMapper
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import matcher
|
import scanner
|
||||||
|
|
||||||
asyncio.run(matcher.main())
|
asyncio.run(scanner.main())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user