diff --git a/app/DataStore.py b/app/DataStore.py index 0de83233..0c811f0b 100644 --- a/app/DataStore.py +++ b/app/DataStore.py @@ -4,7 +4,6 @@ from datetime import datetime, timezone from email.utils import formatdate import json from sqlite3 import Connection -from Utils import calcDownloadPath from Config import Config from Download import Download from ItemDTO import ItemDTO diff --git a/app/main.py b/app/main.py index 93f5e97e..65cc68f1 100644 --- a/app/main.py +++ b/app/main.py @@ -11,7 +11,6 @@ from Utils import ObjectSerializer, Notifier from aiohttp import web, client from aiohttp.web import Request, Response from Webhooks import Webhooks -from Download import Download from player.M3u8 import M3u8 from player.Segments import Segments import socketio @@ -416,11 +415,16 @@ class Main: if not file: raise web.HTTPBadRequest(reason='file is required.') - return web.Response( - text=await M3u8(url=f"{self.config.url_host}{self.config.url_prefix}").make_stream( + try: + text = await M3u8(url=f"{self.config.url_host}{self.config.url_prefix}").make_stream( download_path=self.config.download_path, file=file - ), + ) + except Exception as e: + return web.HTTPNotFound(reason=str(e)) + + return web.Response( + text=text, headers={ 'Content-Type': 'application/x-mpegURL', 'Cache-Control': 'no-cache', diff --git a/app/player/Segments.py b/app/player/Segments.py index f9f7243f..b89f781d 100644 --- a/app/player/Segments.py +++ b/app/player/Segments.py @@ -2,7 +2,6 @@ import asyncio import hashlib import logging import os -import subprocess import tempfile from Utils import calcDownloadPath diff --git a/app/player/ffprobe.py b/app/player/ffprobe.py index e40c7796..66e3da01 100644 --- a/app/player/ffprobe.py +++ b/app/player/ffprobe.py @@ -4,11 +4,8 @@ Python wrapper for ffprobe command line tool. ffprobe must exist in the path. import asyncio import functools import json -import logging import operator import os -import pipes -import subprocess class FFProbeError(Exception):