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