import subprocess import re import os.path import os from module.utils import save_join, save_path from module.plugins.Hoster import Hoster # Requires rtmpdump # by Roland Beermann class RTMP: # TODO: Port to some RTMP-library like rtmpy or similar # TODO?: Integrate properly into the API of pyLoad command = "rtmpdump" @classmethod def download_rtmp_stream(cls, url, output_file, playpath=None): opts = [ "-r", url, "-o", output_file, ] if playpath: opts.append("--playpath") opts.append(playpath) cls._invoke_rtmpdump(opts) @classmethod def _invoke_rtmpdump(cls, opts): args = [ cls.command ] args.extend(opts) return subprocess.check_call(args) class ARD(Hoster): __name__ = "ARD Mediathek" __version__ = "0.11" __pattern__ = r"http://www\.ardmediathek\.de/.*" __config__ = [] def process(self, pyfile): site = self.load(pyfile.url) avail_videos = re.findall( r'mediaCollection.addMediaStream\(0, ([0-9]*), "([^\"]*)", "([^\"]*)", "[^\"]*"\);', site) avail_videos.sort(key=lambda videodesc: int(videodesc[0]), reverse=True) # The higher the number, the better the quality quality, url, playpath = avail_videos[0] pyfile.name = re.search(r"