This commit is contained in:
Dantenerosas 2023-09-25 17:43:24 +03:00 committed by nikili0n
parent cdacb1c77a
commit 229d1d4db7
3 changed files with 21 additions and 3 deletions

View File

@ -28,6 +28,23 @@ app.add_middleware(
)
'''
await self.app(scope, receive, send)
File "/home/admin/video_downloader_service/.venv/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/home/admin/video_downloader_service/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 273, in app
raw_response = await run_endpoint_function(
File "/home/admin/video_downloader_service/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
return await dependant.call(**values)
File "/home/admin/video_downloader_service/src/web/main.py", line 81, in get_url_for_download_video
task_done = await is_task_already_done_or_exist(red, data.link)
File "/home/admin/video_downloader_service/src/web/main.py", line 34, in is_task_already_done_or_exist
tasks = [
File "/home/admin/video_downloader_service/src/web/main.py", line 36, in <listcomp>
if literal_eval(message.decode('utf-8'))["link"] == link
TypeError: string indices must be integers
'''
async def is_task_already_done_or_exist(redis: RedisClient, link: str):
# TODO: добавить real_link? пример - https://yandex.ru/video/preview/398425296752711999 будет грузить https://youtu.be/EjhRS4HUSJc
messages = await redis.get_task_done_queue()
@ -172,5 +189,4 @@ async def download_video(request: Request, link: str):
print(ex)
if __name__ == '__main__':
uvicorn.run("src.web.main:app", host="0.0.0.0", log_level="info")
uvicorn.run("src.web.main:app", host="0.0.0.0", log_level="info")

View File

@ -39,6 +39,7 @@ class MergeOutputFormatEnum(Enum):
@dataclass
class SubmitIn:
#TODO: дефолтный значения
link: str = Form(...)
video_format: VideoFormatEnum = Form(...)
audio_format: AudioFormatEnum = Form(...)

View File

@ -92,10 +92,11 @@
document.forms.download.querySelector('.submit-spinner').classList.remove('submit-spinner_hide');
const link = document.getElementById("link").value
const xhr2 = new XMLHttpRequest();
// TODO: скорректировать ссылку, она должна быть относительной
xhr2.open('GET', 'http://0.0.0.0:8000/check/?link=' + link);
xhr2.responseType = 'json';
xhr2.onload = function() {
// TODO: добавить обработку исключений и всех возможных кодов в ответе
if (xhr2.status !== 200) {
if ('response' in xhr2 && xhr2.response !== null) {
console.log(xhr2.response)