Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Oct 16, 2024
1 parent d5633de commit 4db8cea
Showing 1 changed file with 18 additions and 30 deletions.
48 changes: 18 additions & 30 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,35 +742,21 @@ def _extract_mpd(self, url):
{"quiet": True, "no_warnings": True, "allow_unplayable_formats": True, "enable_file_urls": True}
)
results = ytdl.extract_info(mpd_path.as_uri(), download=False, force_generic_extractor=True)
seen = set()
formats = results.get("formats")

format_id = results.get("format_id")
best_audio_format_id = format_id.split("+")[1]
for f in formats:
if "video" in f.get("format_note"):
# is a video stream
format_id = f.get("format_id")
extension = f.get("ext")
height = f.get("height")
width = f.get("width")

if height and height not in seen:
seen.add(height)
_temp.append(
{
"type": "dash",
"height": str(height),
"width": str(width),
"format_id": f"{format_id},{best_audio_format_id}",
"extension": extension,
"download_url": f.get("manifest_url"),
}
)
else:
# unknown format type
# logger.debug(f"Unknown format type : {f}")
continue
extension = results.get("ext")
height = results.get("height")
width = results.get("width")

_temp.append(
{
"type": "dash",
"height": str(height),
"width": str(width),
"format_id": format_id.replace("+", ","),
"extension": extension,
"download_url": mpd_path.as_uri(),
}
)
except Exception:
logger.exception(f"Error fetching MPD streams")

Expand Down Expand Up @@ -998,8 +984,7 @@ def _parse_lecture(self, lecture: dict):
if asset_type == "article":
retVal.extend(self._extract_article(asset, index))
elif asset_type == "video":
if isinstance(supp_assets, list) and len(supp_assets) > 0:
retVal.extend(self._extract_supplementary_assets(supp_assets, index))
pass
elif asset_type == "e-book":
retVal.extend(self._extract_ebook(asset, index))
elif asset_type == "file":
Expand All @@ -1011,6 +996,9 @@ def _parse_lecture(self, lecture: dict):
else:
logger.warning(f"Unknown asset type: {asset_type}")

if isinstance(supp_assets, list) and len(supp_assets) > 0:
retVal.extend(self._extract_supplementary_assets(supp_assets, index))

if asset != None:
stream_urls = asset.get("stream_urls")
if stream_urls != None:
Expand Down

0 comments on commit 4db8cea

Please sign in to comment.