def try_parse(cls: "ContentType", string: str) -> "ContentType":
"""Try to parse ContentType from (url)string/extension."""
tempstr = string.lower()
- if "." in tempstr:
- tempstr = tempstr.split(".")[-1]
- if "," in tempstr:
- for val in tempstr.split(","):
- try:
- return cls(val.strip())
- except ValueError:
- pass
+ if "audio/" in tempstr:
+ tempstr = tempstr.split("/")[1]
+ for splitter in (".", ","):
+ if splitter in tempstr:
+ for val in tempstr.split(splitter):
+ try:
+ return cls(val.strip())
+ except ValueError:
+ pass
tempstr = tempstr.split("?")[0]
tempstr = tempstr.split("&")[0]
+ tempstr = tempstr.split(";")[0]
+ tempstr = tempstr.replace("mp4", "m4a")
try:
return cls(tempstr)
except ValueError:
stream_format = await self._parse_stream_format(track_obj)
url = await self._parse_stream_url(stream_format=stream_format, item_id=item_id)
return StreamDetails(
- provider=self.type, item_id=item_id, data=url, content_type=ContentType.M4A
+ provider=self.type,
+ item_id=item_id,
+ data=url,
+ content_type=ContentType.try_parse(stream_format["mimeType"]),
)
async def get_audio_stream(