up fix to sitenotimplementedexception
This commit is contained in:
parent
d8c915d22f
commit
da9cf5dbcb
@ -78,6 +78,7 @@ class MasterService:
|
||||
parser_mapping = {
|
||||
"my.mail.ru": MyMailParser(params),
|
||||
"www.youtube.com": BaseParser(params),
|
||||
"youtu.be": BaseParser(params),
|
||||
"vk.com": BaseParser(params),
|
||||
"ok.ru": BaseParser(params),
|
||||
"likee.video": BaseParser(params),
|
||||
@ -98,13 +99,18 @@ class MasterService:
|
||||
"status": "done"
|
||||
})
|
||||
except FileAlreadyExistException as ex:
|
||||
# TODO: сделать так, чтобы грузился обычный, нам не нужно записывать что-то в редис
|
||||
return Result(result_type=ResultTypeEnum.EXIST, value={
|
||||
"link": video_params["link"],
|
||||
"result": ex.message,
|
||||
"status": "exist"
|
||||
})
|
||||
except SiteNotImplementedException as ex:
|
||||
return Result(result_type=ResultTypeEnum.EXCEPTION, value=ex.default_message)
|
||||
return Result(result_type=ResultTypeEnum.EXCEPTION, value={
|
||||
"link": video_params["link"],
|
||||
"result": ex.default_message,
|
||||
"status": "error"
|
||||
})
|
||||
# TODO upload to server
|
||||
|
||||
|
||||
|
@ -7,6 +7,8 @@ class RedisClient:
|
||||
SET_NAME = "queue"
|
||||
TASKS_NAME = "tasks_working"
|
||||
TASKS_DONE_NAME = "tasks_done"
|
||||
|
||||
# TODO: переписать всё вазимодействие редиса обратно на ключ-значение
|
||||
|
||||
def __init__(self):
|
||||
self.connection = redis.Redis(host="localhost", port=6379, db=0)
|
||||
|
@ -45,13 +45,29 @@ app.add_middleware(
|
||||
TypeError: string indices must be integers
|
||||
'''
|
||||
|
||||
'''
|
||||
queue_name -> [
|
||||
"{link...}",
|
||||
"{link2...}",
|
||||
"{link3..}"
|
||||
]
|
||||
|
||||
queue_name -> {
|
||||
"link1" -> {vars},
|
||||
"link2" -> {vars},
|
||||
"link3" -> {vars},
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
async def is_task_already_done_or_exist(redis: RedisClient, link: str):
|
||||
messages = await redis.get_task_done_queue()
|
||||
|
||||
temp = [json.loads(msg) for msg in messages]
|
||||
print(temp)
|
||||
tasks = [
|
||||
literal_eval(message.decode('utf-8')) for message in messages
|
||||
if literal_eval(message.decode('utf-8'))["link"] == link
|
||||
and literal_eval(message.decode('utf-8'))["status"] in ["done", "exist"]
|
||||
msg for msg in temp
|
||||
if msg["link"] == link
|
||||
and msg["status"] in ["done", "exist"]
|
||||
]
|
||||
|
||||
if len(tasks) > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user