up
This commit is contained in:
parent
67ea636db0
commit
8423e732c4
@ -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):
|
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
|
# TODO: добавить real_link? пример - https://yandex.ru/video/preview/398425296752711999 будет грузить https://youtu.be/EjhRS4HUSJc
|
||||||
messages = await redis.get_task_done_queue()
|
messages = await redis.get_task_done_queue()
|
||||||
@ -172,5 +189,4 @@ async def download_video(request: Request, link: str):
|
|||||||
print(ex)
|
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")
|
|
||||||
|
@ -39,6 +39,7 @@ class MergeOutputFormatEnum(Enum):
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class SubmitIn:
|
class SubmitIn:
|
||||||
|
#TODO: дефолтный значения
|
||||||
link: str = Form(...)
|
link: str = Form(...)
|
||||||
video_format: VideoFormatEnum = Form(...)
|
video_format: VideoFormatEnum = Form(...)
|
||||||
audio_format: AudioFormatEnum = Form(...)
|
audio_format: AudioFormatEnum = Form(...)
|
||||||
|
@ -92,10 +92,11 @@
|
|||||||
document.forms.download.querySelector('.submit-spinner').classList.remove('submit-spinner_hide');
|
document.forms.download.querySelector('.submit-spinner').classList.remove('submit-spinner_hide');
|
||||||
const link = document.getElementById("link").value
|
const link = document.getElementById("link").value
|
||||||
const xhr2 = new XMLHttpRequest();
|
const xhr2 = new XMLHttpRequest();
|
||||||
|
// TODO: скорректировать ссылку, она должна быть относительной
|
||||||
xhr2.open('GET', 'http://0.0.0.0:8000/check/?link=' + link);
|
xhr2.open('GET', 'http://0.0.0.0:8000/check/?link=' + link);
|
||||||
xhr2.responseType = 'json';
|
xhr2.responseType = 'json';
|
||||||
xhr2.onload = function() {
|
xhr2.onload = function() {
|
||||||
|
// TODO: добавить обработку исключений и всех возможных кодов в ответе
|
||||||
if (xhr2.status !== 200) {
|
if (xhr2.status !== 200) {
|
||||||
if ('response' in xhr2 && xhr2.response !== null) {
|
if ('response' in xhr2 && xhr2.response !== null) {
|
||||||
console.log(xhr2.response)
|
console.log(xhr2.response)
|
||||||
|
Loading…
Reference in New Issue
Block a user