def main(): """ Main program """ parse, options = parser(__version__) if options.flexibleq and not options.quality: logging.error("flexible-quality requires a quality") if len(options.urls) == 0: parse.print_help() sys.exit(0) urls = options.urls config = parsertoconfig(setup_defaults(), options) if len(urls) < 1: parse.error("Incorrect number of arguments") setup_log(config.get("silent"), config.get("verbose")) if options.cmoreoperatorlist: config = parsertoconfig(setup_defaults(), options) c = Cmore(config, urls) c.operatorlist() sys.exit(0) try: if len(urls) == 1: get_media(urls[0], config, __version__) else: get_multiple_media(urls, config) except KeyboardInterrupt: print("") except (yaml.YAMLError, yaml.MarkedYAMLError) as e: logging.error( "Your settings file(s) contain invalid YAML syntax! Please fix and restart!, {}" .format(str(e))) sys.exit(2)
def test_formatname(self): for item in self.all_combo: config = setup_defaults() config.set("filename", item[0]) service = Service(config, "localhost") service.output.update(item[1]) self.assertEqual(_formatname(service.output, config, "mp4"), item[2])
def test_formatname(self): for item in self.all_combo: config = setup_defaults() config.set("filename", item[0]) service = Service(config, "localhost") service.output.update(item[1]) assert _formatname(service.output, config, "mp4") == item[2]
def test_sublang(self): config = setup_defaults() config.set("output", os.path.join(os.path.dirname(os.path.realpath(__file__)), "postprocess/textfile-service")) service = Service(config, "http://exmaple.com") service.output["title"] = "textfile" stream = VideoRetriever(config, "http://example.com", 0, output=service.output) assert _sublanguage(stream, config, None) == ["swe"]
def __init__(self, config, _url, http=None): self._url = _url self._urldata = None self._error = False self.subtitle = None self.cookies = {} self.auto_name = None self.output = { "title": None, "season": None, "episode": None, "episodename": None, "id": None, "service": self.__class__.__name__.lower(), "tvshow": None, "title_nice": None, "showdescription": None, "episodedescription": None, "showthumbnailurl": None, "episodethumbnailurl": None, "publishing_datetime": None, } if not http: self.http = HTTP(config) else: self.http = http # Config if config.get("configfile") and os.path.isfile(config.get("configfile")): self.config = merge( readconfig(setup_defaults(), config.get("configfile"), service=self.__class__.__name__.lower()).get_variable(), config.get_variable() ) else: self.config = config logging.debug("service: {}".format(self.__class__.__name__.lower()))
def test_formatnameTvshow(self): config = setup_defaults() service = Service(config, "http://localhost") service.output["tvshow"] = True service.output["title"] = "kalle" service.output["season"] = 2 service.output["episode"] = 2 assert formatname(service.output, config) == "kalle.s02e02-service.mp4"
def test_formatnameOutput(self): config = setup_defaults() config.set("output", "/tmp") service = Service(config, "http://localhost") if platform.system() == "Windows": assert formatname(service.output, config) == "/tmp.mp4" else: assert formatname(service.output, config) == "/tmp/-service.mp4"
def parse(playlist): with open( os.path.join(os.path.dirname(os.path.realpath(__file__)), "dash-manifests", playlist)) as fd: manifest = fd.read() return _dashparse(setup_defaults(), manifest, "http://localhost", None, None)
def test_sublang3(self, req): config = setup_defaults() self.setup_mock(req, "smj") config.set("output", os.path.join(os.path.dirname(os.path.realpath(__file__)), "postprocess/textfile-service")) config.set("get_all_subtitles", True) service = Service(config, "http://exmaple.com") service.output["title"] = "textfile" stream = VideoRetriever(config, "http://example.com", 0, output=service.output) self.assertEqual(_sublanguage(stream, config, ["lulesamiska"]), ["smj"])
def test_formatnameTvshowSubfolderMovie(self): config = setup_defaults() config.set("subfolder", True) service = Service(config, "http://localhost") service.output["tvshow"] = False service.output["title"] = "kalle" service.output["season"] = 2 service.output["episode"] = 2 if platform.system() == "Windows": assert formatname(service.output, config) == r"movies\kalle.s02e02-service.mp4" else: assert formatname(service.output, config) == "movies/kalle.s02e02-service.mp4"
def test_formatnameTvshowPath(self): config = setup_defaults() if platform.system() == "Windows": config.set("path", "c:") else: config.set("path", "/tmp") service = Service(config, "http://localhost") service.output["title"] = "kalle" service.output["season"] = 2 service.output["episode"] = 2 if platform.system() == "Windows": assert formatname(service.output, config) == r"c:kalle.s02e02-service.mp4" else: assert formatname(service.output, config) == "/tmp/kalle.s02e02-service.mp4"
def test_sort(self): data = [ DASH(setup_defaults(), "http://example.com", 3000, None), HLS(setup_defaults(), "http://example.com", 2000, None), HTTP(setup_defaults(), "http://example.com", 3001, None), ] assert all([ a[0] == b.bitrate for a, b in zip( sort_quality(data), [ HTTP(setup_defaults(), "http://example.com", 3001, None), DASH(setup_defaults(), "http://example.com", 3000, None), HLS(setup_defaults(), "http://example.com", 2000, None), ], ) ])
def __init__(self, config, _url, http=None): self._url = _url self._urldata = None self._error = False self.subtitle = None self.cookies = {} self.auto_name = None self.output = {"title": None, "season": None, "episode": None, "episodename": None, "id": None, "service": self.__class__.__name__.lower(), "tvshow": None, "title_nice": None, "showdescription": None, "episodedescription": None, "showthumbnailurl": None, "episodethumbnailurl": None, "publishing_datetime": None} if not http: self.http = HTTP(config) else: self.http = http # Config if os.path.isfile(config.get("configfile")): self.config = merge(readconfig(setup_defaults(), config.get("configfile"), service=self.__class__.__name__.lower()).get_variable(), config.get_variable()) else: self.config = config logging.debug("service: {}".format(self.__class__.__name__.lower()))
def test_exlude_default(self): config = setup_defaults() assert not exclude(config, "hoppsan")
def test_service_handler(self): config = setup_defaults() self.assertIsNone(service_handler(sites, config, "localhost"))
def test_exclude_true(self): config = setup_defaults() config.set("exclude", "hej") assert exclude(config, "hejsanhoppsan")
def test_exclude_false(self): config = setup_defaults() config.set("exclude", "hej") assert not exclude(config, "hoppsan")
def test_vimeo(self): config = setup_defaults() generic = Generic(config, "http://example.com") data = 'src="https://player.vimeo.com/video/359281775" ' assert isinstance(generic._match(data, sites)[1], Service)
def parse(playlist): with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "dash-manifests", playlist)) as fd: manifest = fd.read() return _dashparse(setup_defaults(), manifest, "http://localhost", None, None)
def test_hls(self): config = setup_defaults() generic = Generic(config, "http://example.com") data = 'source src="http://example.com/hls.m3u8" type="application/x-mpegURL"' assert isinstance(generic._match(data, sites)[1], Service)
def test_tv4(self): config = setup_defaults() generic = Generic(config, "http://example.com") data = "rc=https://www.tv4play.se/iframe/video/12499319 " assert isinstance(generic._match(data, sites)[1], Service)
def test_service_handler(self): config = setup_defaults() assert isinstance( service_handler(sites, config, "https://www.svtplay.se"), Service)
def test_nothing(self): config = setup_defaults() generic = Generic(config, "http://example.com") data = "hejsan" assert generic._match(data, sites) == ("http://example.com", None)
def test_service_handler(self): config = setup_defaults() assert not service_handler(sites, config, "localhost")
def test_formatnameEmpty(self): config = setup_defaults() service = Service(config, "http://localhost") assert formatname(service.output, config) == "-service.mp4"
def test_service_handler(self): config = setup_defaults() self.assertIsInstance(service_handler(sites, config, "https://www.svtplay.se"), Service)
def test_formatnameBasedir(self): config = setup_defaults() service = Service(config, "http://localhost") service.output["basedir"] = True assert formatname(service.output, config) == "-service.mp4"