minor fixes, added web serer

This commit is contained in:
2023-09-20 14:43:59 +03:00
committed by nikili0n
parent 46eae5b68a
commit 1faeb9c37b
8 changed files with 252 additions and 23 deletions

View File

@ -48,7 +48,7 @@ class MasterService:
)
result = await download_task
await redis.del_task_from_tasks_and_add_to_task_done(task=video_params)
await redis.del_task_from_tasks_and_add_to_task_done(task={"link": video_params["link"], "result": result})
# TODO process result
self.queue.task_done()
@ -76,8 +76,8 @@ class MasterService:
@staticmethod
def video_processing_executor(video_params: dict):
try:
MasterService.video_download(video_params=video_params)
return Result(result_type=ResultTypeEnum.DONE)
result = MasterService.video_download(video_params=video_params)
return result
except Exception as ex:
return Result(result_type=ResultTypeEnum.EXCEPTION, value=ex)
# TODO upload to server

View File

@ -18,8 +18,8 @@ class RedisClient:
async def _set_task_done(self, task: dict) -> int:
async with self.connection as connection:
res = await connection.set(
f'{self.TASKS_DONE_NAME}:1:{task["link"]}',
res = await connection.sadd(
f'{self.TASKS_DONE_NAME}:1',
json.dumps(task, indent=4).encode('utf-8')
)
return res
@ -53,3 +53,19 @@ class RedisClient:
await self._del_task(task)
return await self._set_task_done(task)
async def get_task_done_queue(self) -> set:
async with self.connection as connection:
res = await connection.smembers(self.TASKS_DONE_NAME + f":1")
return res
async def del_task_from_task_done_queue(self, task) -> int:
async with self.connection as connection:
res = await connection.srem(self.TASKS_DONE_NAME + f":1", json.dumps(task, indent=4).encode('utf-8'))
return res
async def get_tasks_queue(self) -> set:
async with self.connection as connection:
res = await connection.json().get(self.TASKS_NAME)
return res

View File

@ -15,7 +15,7 @@ def main():
if not found:
client.make_bucket("clean-internet-oculus-integration-dev")
else:
print("Bucket 'asiatrip' already exists")
print("Bucket 'clean-internet-oculus-integration-dev' already exists")
# Upload '/home/user/Photos/asiaphotos.zip' as object name
# 'asiaphotos-2015.zip' to bucket 'asiatrip'.
@ -23,8 +23,8 @@ def main():
"clean-internet-oculus-integration-dev", "4uv2GNc_ybc_1080p.mp4", "/Users/garickbadalov/PycharmProjects/video_downloader_service/downloads/Youtube/4uv2GNc_ybc_1080p.mp4",
)
print(
"'/home/user/Photos/asiaphotos.zip' is successfully uploaded as "
"object 'asiaphotos-2015.zip' to bucket 'asiatrip'."
"'/Users/garickbadalov/PycharmProjects/video_downloader_service/downloads/Youtube/4uv2GNc_ybc_1080p.mp4' is successfully uploaded as "
"object '4uv2GNc_ybc_1080p.mp4' to bucket 'clean-internet-oculus-integration-dev'."
)