feat: raise CodecNotFoundException when could not find specified codec

pull/1/head
WorldObservationLog 6 months ago
parent 2f1aaa2106
commit 90b271b348
  1. 4
      src/exceptions.py
  2. 3
      src/mp4.py

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

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

Loading…
Cancel
Save