コード例 #1
0
ファイル: __init__.py プロジェクト: wirretheman/svtplay-dl
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)
コード例 #2
0
ファイル: formatname.py プロジェクト: olof/debian-svtplay-dl
 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])
コード例 #3
0
ファイル: test_formatname.py プロジェクト: toran4/svtplay-dl
 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]
コード例 #4
0
 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"]
コード例 #5
0
ファイル: __init__.py プロジェクト: wirretheman/svtplay-dl
    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()))
コード例 #6
0
ファイル: test_formatname.py プロジェクト: toran4/svtplay-dl
 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"
コード例 #7
0
ファイル: test_formatname.py プロジェクト: toran4/svtplay-dl
 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"
コード例 #8
0
ファイル: test_dash.py プロジェクト: UWTD/svtplay-dl
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)
コード例 #9
0
 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"])
コード例 #10
0
ファイル: test_formatname.py プロジェクト: toran4/svtplay-dl
 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"
コード例 #11
0
ファイル: test_formatname.py プロジェクト: toran4/svtplay-dl
 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"
コード例 #12
0
 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),
             ],
         )
     ])
コード例 #13
0
ファイル: __init__.py プロジェクト: olof/debian-svtplay-dl
    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()))
コード例 #14
0
ファイル: test_text.py プロジェクト: wirretheman/svtplay-dl
 def test_exlude_default(self):
     config = setup_defaults()
     assert not exclude(config, "hoppsan")
コード例 #15
0
ファイル: service.py プロジェクト: olof/debian-svtplay-dl
 def test_service_handler(self):
     config = setup_defaults()
     self.assertIsNone(service_handler(sites, config, "localhost"))
コード例 #16
0
ファイル: test_text.py プロジェクト: wirretheman/svtplay-dl
 def test_exclude_true(self):
     config = setup_defaults()
     config.set("exclude", "hej")
     assert exclude(config, "hejsanhoppsan")
コード例 #17
0
ファイル: test_text.py プロジェクト: wirretheman/svtplay-dl
 def test_exclude_false(self):
     config = setup_defaults()
     config.set("exclude", "hej")
     assert not exclude(config, "hoppsan")
コード例 #18
0
 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)
コード例 #19
0
ファイル: dash.py プロジェクト: olof/debian-svtplay-dl
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)
コード例 #20
0
 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)
コード例 #21
0
 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)
コード例 #22
0
 def test_service_handler(self):
     config = setup_defaults()
     assert isinstance(
         service_handler(sites, config, "https://www.svtplay.se"), Service)
コード例 #23
0
 def test_nothing(self):
     config = setup_defaults()
     generic = Generic(config, "http://example.com")
     data = "hejsan"
     assert generic._match(data, sites) == ("http://example.com", None)
コード例 #24
0
 def test_service_handler(self):
     config = setup_defaults()
     assert not service_handler(sites, config, "localhost")
コード例 #25
0
ファイル: test_formatname.py プロジェクト: toran4/svtplay-dl
 def test_formatnameEmpty(self):
     config = setup_defaults()
     service = Service(config, "http://localhost")
     assert formatname(service.output, config) == "-service.mp4"
コード例 #26
0
ファイル: service.py プロジェクト: olof/debian-svtplay-dl
 def test_service_handler(self):
     config = setup_defaults()
     self.assertIsInstance(service_handler(sites, config, "https://www.svtplay.se"), Service)
コード例 #27
0
ファイル: test_formatname.py プロジェクト: toran4/svtplay-dl
 def test_formatnameBasedir(self):
     config = setup_defaults()
     service = Service(config, "http://localhost")
     service.output["basedir"] = True
     assert formatname(service.output, config) == "-service.mp4"
コード例 #28
0
ファイル: service.py プロジェクト: uncoldice/svtplay-dl
 def test_service_handler(self):
     config = setup_defaults()
     self.assertIsNone(service_handler(sites, config, "localhost"))