feat: raise CodecNotFoundException when could not find specified codec

This commit is contained in:
WorldObservationLog
2024-05-04 22:53:47 +08:00
parent 2f1aaa2106
commit 90b271b348
2 changed files with 7 additions and 0 deletions

View File

@@ -20,3 +20,7 @@ class DecryptException(Exception):
class NotTimeSyncedLyricsException(Exception):
...
class CodecNotFoundException(Exception):
...

View File

@@ -9,6 +9,7 @@ import m3u8
import regex
from bs4 import BeautifulSoup
from src.exceptions import CodecNotFoundException
from src.metadata import SongMetadata
from src.types import *
from src.utils import find_best_codec
@@ -17,6 +18,8 @@ from src.utils import find_best_codec
async def extract_media(m3u8_url: str, codec: str) -> Tuple[str, list[str], str]:
parsed_m3u8 = m3u8.load(m3u8_url)
specifyPlaylist = find_best_codec(parsed_m3u8, codec)
if not specifyPlaylist:
raise CodecNotFoundException
selected_codec = specifyPlaylist.media[0].group_id
if not specifyPlaylist:
raise