diff --git a/setup.cfg b/setup.cfg index 304c1bc..cb72544 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = syncMyMoodle -version = 0.2.1 +version = 0.2.2 author = Nils Kattenbeck author_email = nilskemail+pypi@gmail.com description = Synchronization client for RWTH Moodle diff --git a/syncmymoodle/__main__.py b/syncmymoodle/__main__.py index dadebc6..ecd4f61 100755 --- a/syncmymoodle/__main__.py +++ b/syncmymoodle/__main__.py @@ -961,17 +961,26 @@ def getOpenCastRealURL(self, additional_info, url): episodejson = f"https://engage.streaming.rwth-aachen.de/search/episode.json?id={linkid.groups()[0]}" episodejson = json.loads(self.session.get(episodejson).text) - tracks = episodejson["search-results"]["result"]["mediapackage"]["media"][ - "track" + # Collect tracks from all mediapackages + mediapackages = [ + track["mediapackage"]["media"]["track"] for track in episodejson["result"] ] + + # TODO, handle multiple mediapackages (videos? could be seperate presenter and screencap) + tracks = mediapackages[0] + + # Filter and sort tracks by resolution (width) tracks = sorted( [ (t["url"], t["video"]["resolution"]) for t in tracks - if t["mimetype"] == "video/mp4" and "transport" not in t + if t["mimetype"] == "video/mp4" + and "transport" not in t + and "video" in t ], - key=(lambda x: int(x[1].split("x")[0])), + key=lambda x: int(x[1].split("x")[0]), # Sort by width (e.g., "1920x1080") ) + # only choose mp4s provided with plain https (no transport key), and use the one with the highest resolution (sorted by width) (could also use bitrate) finaltrack = tracks[-1]