• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python log.info函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中svtplay_dl.log.log.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_media

def get_media(url, options):

    stream = service_handler(url)
    if not stream:
        url, stream = Generic().get(url)
    if not stream:
        log.error("That site is not supported. Make a ticket or send a message")
        sys.exit(2)

    if options.all_episodes:
        if options.output and os.path.isfile(options.output):
            log.error("Output must be a directory if used with --all-episodes")
            sys.exit(2)
        elif options.output and not os.path.exists(options.output):
            try:
                os.makedirs(options.output)
            except OSError as e:
                log.error("%s: %s" % (e.strerror,  e.filename))
                return

        episodes = stream.find_all_episodes(options)

        for idx, o in enumerate(episodes):
            if o == url:
                substream = stream
            else:
                substream = service_handler(o)

            log.info("Episode %d of %d", idx + 1, len(episodes))

            # get_one_media overwrites options.output...
            get_one_media(substream, copy.copy(options))
    else:
        get_one_media(stream, options)
开发者ID:magnusaberg,项目名称:svtplay-dl,代码行数:34,代码来源:__init__.py


示例2: output

def output(options, extension="mp4", openfd=True, mode="wb", **kwargs):
    subtitlefiles = ["srt", "smi", "tt","sami", "wrst"]

    ext = re.search(r"(\.\w{2,4})$", options.output)
    if not ext:
        options.output = "%s.%s" % (options.output, extension)
    if options.output_auto and ext:
        options.output = "%s.%s" % (options.output, extension)
    elif extension == "srt" and ext:
        options.output = "%s.srt" % options.output[:options.output.rfind(ext.group(1))]
    if ext and extension == "srt" and ext.group(1).split(".")[-1] in subtitlefiles:
        options.output = "%s.srt" % options.output[:options.output.rfind(ext.group(1))]
    log.info("Outfile: %s", options.output)
    if os.path.isfile(options.output) or \
            findexpisode(os.path.dirname(os.path.realpath(options.output)), options.service, os.path.basename(options.output)):
        if extension in subtitlefiles:
            if not options.force_subtitle:
                log.error("File (%s) already exists. Use --force-subtitle to overwrite" % options.output)
                return None
        else:
            if not options.force:
                log.error("File (%s) already exists. Use --force to overwrite" % options.output)
                return None
    if openfd:
        file_d = open(options.output, mode, **kwargs)
        return file_d
    return True
开发者ID:magic75,项目名称:svtplay-dl,代码行数:27,代码来源:output.py


示例3: remux

 def remux(self):
     if self.detect is None:
         log.error("Cant detect ffmpeg or avconv. Cant mux files without it.")
         return
     if self.stream.finished is False:
         return
     
     if self.stream.options.output.endswith('.mp4') is False:
         orig_filename = self.stream.options.output
         new_name = "{0}.mp4".format(os.path.splitext(self.stream.options.output)[0])
 
         log.info("Muxing %s into %s", orig_filename, new_name)
         tempfile = "{0}.temp".format(self.stream.options.output)
         name, ext = os.path.splitext(orig_filename)
         arguments = ["-c", "copy", "-copyts", "-f", "mp4"]
         if ext == ".ts":
             arguments += ["-bsf:a", "aac_adtstoasc"]
         arguments += ["-y", tempfile]
         cmd = [self.detect, "-i", orig_filename]
         cmd += arguments
         p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
         stdout, stderr = p.communicate()
         if p.returncode != 0:
             stderr = stderr.decode('utf-8', 'replace')
             msg = stderr.strip().split('\n')[-1]
             log.error("Something went wrong: %s", msg)
             return
         log.info("Muxing done, removing the old file.")
         os.remove(self.stream.options.output)
         os.rename(tempfile, new_name)
开发者ID:chenliang100,项目名称:svtplay-dl,代码行数:30,代码来源:__init__.py


示例4: merge

    def merge(self):
        if self.detect is None:
            log.error("Cant detect ffmpeg or avconv. Cant mux files without it.")
            return

        if self.stream.finished is False:
            return
        orig_filename = self.stream.options.output
        log.info("Merge audio and video into %s", orig_filename)
        tempfile = "{0}.temp".format(self.stream.options.output)
        audio_filename = "{0}.m4a".format(os.path.splitext(self.stream.options.output)[0])
        arguments = ["-c:v", "copy", "-c:a", "copy", "-f", "mp4", "-y", tempfile]
        cmd = [self.detect, "-i", orig_filename, "-i", audio_filename]
        cmd += arguments
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
        stdout, stderr = p.communicate()
        if p.returncode != 0:
            stderr = stderr.decode('utf-8', 'replace')
            msg = stderr.strip().split('\n')[-1]
            log.error("Something went wrong: %s", msg)
            return
        log.info("Merging done, removing old files.")
        os.remove(self.stream.options.output)
        os.remove(audio_filename)
        os.rename(tempfile, self.stream.options.output)
开发者ID:chenliang100,项目名称:svtplay-dl,代码行数:25,代码来源:__init__.py


示例5: output

def output(options, extention="mp4", openfd=True, mode="wb", **kwargs):
    if is_py2:
        file_d = file
    else:
        file_d = io.IOBase

    if options.output != "-":
        ext = re.search(r"(\.\w{2,3})$", options.output)
        if not ext:
            options.output = "%s.%s" % (options.output, extention)
        if options.output_auto and ext:
            options.output = "%s.%s" % (options.output, extention)
        if extention == "srt" and ext:
            options.output = "%s.srt" % options.output[:options.output.rfind(ext.group(1))]
        log.info("Outfile: %s", options.output)
        if os.path.isfile(options.output) or \
                findexpisode(os.path.dirname(os.path.realpath(options.output)), options.service, os.path.basename(options.output)):
            if extention == "srt":
                if not options.force_subtitle:
                    log.error("File (%s) already exists. Use --force-subtitle to overwrite" % options.output)
                    return None
            else:
                if not options.force:
                    log.error("File (%s) already exists. Use --force to overwrite" % options.output)
                    return None
        if openfd:
            file_d = open(options.output, mode, **kwargs)
    else:
        if openfd:
            if is_py2:
                file_d = sys.stdout
            else:
                file_d = sys.stdout.buffer

    return file_d
开发者ID:chenliang100,项目名称:svtplay-dl,代码行数:35,代码来源:output.py


示例6: get_all_episodes

def get_all_episodes(stream, options, url):
    if options.output and os.path.isfile(options.output):
        log.error("Output must be a directory if used with --all-episodes")
        sys.exit(2)
    elif options.output and not os.path.exists(options.output):
        try:
            os.makedirs(options.output)
        except OSError as e:
            log.error("%s: %s", e.strerror, e.filename)
            return

    episodes = stream.find_all_episodes(options)
    if episodes is None:
        return
    for idx, o in enumerate(episodes):
        if o == url:
            substream = stream
        else:
            substream = service_handler(sites, copy.copy(options), o)

        log.info("Episode %d of %d", idx + 1, len(episodes))
        log.info("Url: %s",o) 

        # get_one_media overwrites options.output...
        get_one_media(substream, copy.copy(options))
开发者ID:magic75,项目名称:svtplay-dl,代码行数:25,代码来源:__init__.py


示例7: download_rtmp

def download_rtmp(options, url):
    """ Get the stream from RTMP """
    args = []
    if options.live:
        args.append("-v")

    if options.resume:
        args.append("-e")

    extension = re.search("(\.[a-z0-9]+)$", url)
    if options.output != "-":
        if not extension:
            extension = re.search("-y (.+):[-_a-z0-9\/]", options.other)
            if not extension:
                options.output = "%s.flv" % options.output
            else:
                options.output = "%s.%s" % (options.output, extension.group(1))
        else:
            options.output = options.output + extension.group(1)
        log.info("Outfile: %s", options.output)
        args += ["-o", options.output]
    if options.silent or options.output == "-":
        args.append("-q")
    if options.other:
        if sys.version_info < (3, 0):
            args += shlex.split(options.other.encode("utf-8"))
        else:
            args += shlex.split(options.other)
    command = ["rtmpdump", "-r", url] + args
    try:
        subprocess.call(command)
    except OSError as e:
        log.error("Could not execute rtmpdump: " + e.strerror)
开发者ID:drtobbe,项目名称:svtplay-dl,代码行数:33,代码来源:rtmp.py


示例8: output

def output(options, filename, extention="mp4", openfd=True):
    if is_py3:
        file_d = io.IOBase
    else:
        file_d = file

    if options.output != "-":
        ext = re.search(r"(\.[a-z0-9]+)$", filename)
        if not ext:
            options.output = "%s.%s" % (options.output, extention)
        log.info("Outfile: %s", options.output)
        if (os.path.isfile(options.output) or \
            findexpisode(os.path.dirname(os.path.realpath(options.output)), options.service, os.path.basename(options.output))) and \
            not options.force:
            log.error("File already exists. Use --force to overwrite")
            return None
        if openfd:
            file_d = open(options.output, "wb")
    else:
        if openfd:
            if is_py3:
                file_d = sys.stdout.buffer
            else:
                file_d = sys.stdout

    return file_d
开发者ID:TetragrammatonHermit,项目名称:svtplay-dl,代码行数:26,代码来源:output.py


示例9: get_one_media

def get_one_media(stream, options):
    if not options.output or os.path.isdir(options.output):
        data = stream.get_urldata()
        match = re.search(r"(?i)<title[^>]*>\s*(.*?)\s*</title>", data, re.S)
        if match:
            options.output_auto = True
            title_tag = decode_html_entities(match.group(1))
            if not options.output:
                options.output = filenamify(title_tag)
            else:
                # output is a directory
                options.output = os.path.join(options.output, filenamify(title_tag))

    if platform.system() == "Windows":
        # ugly hack. replace \ with / or add extra \ because c:\test\kalle.flv will add c:_tab_est\kalle.flv
        if options.output.find("\\") > 0:
            options.output = options.output.replace("\\", "/")

    videos = []
    subs = []
    streams = stream.get(options)
    for i in streams:
        if isinstance(i, VideoRetriever):
            if options.preferred:
                if options.preferred == i.name():
                    videos.append(i)
            else:
                videos.append(i)
        if isinstance(i, subtitle):
            subs.append(i)

    if options.subtitle and options.output != "-":
        if subs:
            subs[0].download(copy.copy(options))
        if options.force_subtitle:
            return

    if len(videos) == 0:
        log.error("Can't find any streams for that url")
    else:
        stream = select_quality(options, videos)
        log.info("Selected to download %s, bitrate: %s",
            stream.name(), stream.bitrate)
        try:
            stream.download()
        except UIException as e:
            if options.verbose:
                raise e
            log.error(e.message)
            sys.exit(2)

        if options.thumbnail and hasattr(stream, "get_thumbnail"):
            if options.output != "-":
                log.info("Getting thumbnail")
                stream.get_thumbnail(options)
            else:
                log.warning("Can not get thumbnail when fetching to stdout")
开发者ID:julveson,项目名称:svtplay-dl,代码行数:57,代码来源:__init__.py


示例10: download

    def download(self):
        if self.options.live and not self.options.force:
            raise LiveHLSException(self.url)

        m3u8 = get_http_data(self.url)
        globaldata, files = parsem3u(m3u8)
        encrypted = False
        key = None
        try:
            keydata = globaldata["KEY"]
            encrypted = True
        except KeyError:
            pass

        if encrypted:
            try:
                from Crypto.Cipher import AES
            except ImportError:
                log.error("You need to install pycrypto to download encrypted HLS streams")
                sys.exit(2)

            match = re.search(r'URI="(https?://.*?)"', keydata)
            key = get_http_data(match.group(1))
            rand = os.urandom(16)
            decryptor = AES.new(key, AES.MODE_CBC, rand)
        if self.options.output != "-":
            extension = re.search(r"(\.[a-z0-9]+)$", self.options.output)
            if not extension:
                self.options.output = "%s.ts" % self.options.output
            log.info("Outfile: %s", self.options.output)
            if os.path.isfile(self.options.output) and not self.options.force:
                log.info("File already exists. use --force to overwrite")
                return
            file_d = open(self.options.output, "wb")
        else:
            file_d = sys.stdout

        n = 0
        eta = ETA(len(files))
        for i in files:
            item = _get_full_url(i[0], self.url)

            if self.options.output != "-":
                eta.increment()
                progressbar(len(files), n, ''.join(['ETA: ', str(eta)]))
                n += 1

            data = get_http_data(item)
            if encrypted:
                data = decryptor.decrypt(data)
            file_d.write(data)

        if self.options.output != "-":
            file_d.close()
            progress_stream.write('\n')
开发者ID:antoneliasson,项目名称:svtplay-dl,代码行数:55,代码来源:hls.py


示例11: save

def save(options, data):
    filename = re.search(r"(.*)\.[a-z0-9]{2,3}$", options.output)
    if filename:
        options.output = "%s.srt" % filename.group(1)
    else:
        options.output = "%s.srt" % options.output

    log.info("Subtitle: %s", options.output)
    fd = open(options.output, "w")
    fd.write(data)
    fd.close()
开发者ID:antoneliasson,项目名称:svtplay-dl,代码行数:11,代码来源:__init__.py


示例12: get_one_media

def get_one_media(stream, options):
    # Make an automagic filename
    if not filename(options, stream):
        return

    videos = []
    subs = []
    streams = stream.get(options)
    for i in streams:
        if isinstance(i, VideoRetriever):
            if options.preferred:
                if options.preferred.lower() == i.name():
                    videos.append(i)
            else:
                videos.append(i)
        if isinstance(i, subtitle):
            subs.append(i)

    if options.subtitle and options.output != "-":
        if subs:
            subs[0].download()
        if options.force_subtitle:
            return

    if len(videos) == 0:
        log.error("Can't find any streams for that url")
    else:
        if options.list_quality:
            list_quality(videos)
            return
        stream = select_quality(options, videos)
        log.info("Selected to download %s, bitrate: %s",
                 stream.name(), stream.bitrate)
        if options.get_url:
            print(stream.url)
            return
        try:
            stream.download()
        except UIException as e:
            if options.verbose:
                raise e
            log.error(e.message)
            sys.exit(2)

        if options.thumbnail and hasattr(stream, "get_thumbnail"):
            if options.output != "-":
                log.info("Getting thumbnail")
                stream.get_thumbnail(options)
            else:
                log.warning("Can not get thumbnail when fetching to stdout")
开发者ID:persundstrom,项目名称:svtplay-dl,代码行数:50,代码来源:__init__.py


示例13: save

def save(options, data):
    filename = re.search(r"(.*)\.[a-z0-9]{2,3}$", options.output)
    if filename:
        options.output = "%s.srt" % filename.group(1)
    else:
        options.output = "%s.srt" % options.output

    log.info("Subtitle: %s", options.output)
    if os.path.isfile(options.output) and not options.force:
        log.info("File already exists. use --force to overwrite")
        return
    fd = open(options.output, "w")
    fd.write(data)
    fd.close()
开发者ID:julveson,项目名称:svtplay-dl,代码行数:14,代码来源:__init__.py


示例14: remux

    def remux(self):
        if self.detect is None:
            log.error("Cant detect ffmpeg or avconv. Cant mux files without it.")
            return
        if self.stream.finished is False:
            return

        if formatname(self.stream.output, self.config, self.stream.output_extention).endswith('.mp4') is False:
            orig_filename = formatname(self.stream.output, self.config, self.stream.output_extention)
            name, ext = os.path.splitext(orig_filename)
            new_name = u"{0}.mp4".format(name)

            cmd = [self.detect, "-i", orig_filename]
            _, stdout, stderr = run_program(cmd, False)  # return 1 is good here.
            videotrack, audiotrack = self._checktracks(stderr)

            if self.config.get("merge_subtitle"):
                log.info(u"Muxing {0} and merging its subtitle into {1}".format(orig_filename, new_name))
            else:
                log.info(u"Muxing {0} into {1}".format(orig_filename, new_name))

            tempfile = u"{0}.temp".format(orig_filename)
            arguments = ["-map", "0:{}".format(videotrack), "-map", "0:{}".format(audiotrack), "-c", "copy", "-f", "mp4"]
            if ext == ".ts":
                arguments += ["-bsf:a", "aac_adtstoasc"]

            if self.config.get("merge_subtitle"):
                langs = self.sublanguage()
                for stream_num, language in enumerate(langs):
                    arguments += ["-map", str(stream_num + 1), "-c:s:" + str(stream_num), "mov_text",
                                  "-metadata:s:s:" + str(stream_num), "language=" + language]
                if self.subfixes and len(self.subfixes) >= 2:
                    for subfix in self.subfixes:
                        subfile = "{0}.srt".format(name + subfix)
                        cmd += ["-i", subfile]
                else:
                    subfile = "{0}.srt".format(name)
                    cmd += ["-i", subfile]

            arguments += ["-y", tempfile]
            cmd += arguments
            returncode, stdout, stderr = run_program(cmd)
            if returncode != 0:
                return

            if self.config.get("merge_subtitle") and not self.config.get("subtitle"):
                log.info("Muxing done, removing the old files.")
                if self.subfixes and len(self.subfixes) >= 2:
                    for subfix in self.subfixes:
                        subfile = "{0}.srt".format(name + subfix)
                        os.remove(subfile)
                else:
                    os.remove(subfile)
            else:
                log.info("Muxing done, removing the old file.")
            os.remove(orig_filename)
            os.rename(tempfile, new_name)
开发者ID:olof,项目名称:debian-svtplay-dl,代码行数:57,代码来源:__init__.py


示例15: download

    def download(self):
        """ Get the stream from HTTP """
        request = Request(self.url)
        request.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
        try:
            response = urlopen(request)
        except HTTPError as e:
            log.error("Something wrong with that url")
            log.error("Error code: %s", e.code)
            sys.exit(5)
        try:
            total_size = response.info()['Content-Length']
        except KeyError:
            total_size = 0
        total_size = int(total_size)
        bytes_so_far = 0
        if self.options.output != "-":
            extension = re.search(r"(\.[a-z0-9]+)$", self.url)
            if extension:
                self.options.output = self.options.output + extension.group(1)
            else:
                self.options.output = "%s.mp4" % self.options.output
            log.info("Outfile: %s", self.options.output)
            if os.path.isfile(self.options.output) and not self.options.force:
                log.info("File already exists. use --force to overwrite")
                return
            file_d = open(self.options.output, "wb")
        else:
            file_d = sys.stdout

        lastprogress = 0
        while 1:
            chunk = response.read(8192)
            bytes_so_far += len(chunk)

            if not chunk:
                break

            file_d.write(chunk)
            if self.options.output != "-":
                now = time.time()
                if lastprogress + 1 < now:
                    lastprogress = now
                    progress(bytes_so_far, total_size)

        if self.options.output != "-":
            file_d.close()
开发者ID:antoneliasson,项目名称:svtplay-dl,代码行数:47,代码来源:http.py


示例16: remux

    def remux(self):
        if self.detect is None:
            log.error("Cant detect ffmpeg or avconv. Cant mux files without it.")
            return
        if self.stream.finished is False:
            return

        if self.stream.options.output.endswith('.mp4') is False:
            orig_filename = self.stream.options.output
            name, ext = os.path.splitext(orig_filename)
            new_name = u"{0}.mp4".format(name)

            if self.merge_subtitle:
                log.info(u"Muxing %s and merging its subtitle into %s", orig_filename, new_name)
            else:
                log.info(u"Muxing %s into %s".format(orig_filename, new_name))

            tempfile = u"{0}.temp".format(orig_filename)
            arguments = ["-map", "0:v", "-map", "0:a", "-c", "copy", "-copyts", "-f", "mp4"]
            if ext == ".ts":
                arguments += ["-bsf:a", "aac_adtstoasc"]
            cmd = [self.detect, "-i", orig_filename]

            if self.merge_subtitle:
                langs = self.sublanguage()
                for stream_num, language in enumerate(langs):
                    arguments += ["-map", str(stream_num + 1), "-c:s:" + str(stream_num), "mov_text", "-metadata:s:s:" + str(stream_num), "language=" + language]
                if len(self.subfixes) >= 2:
                    for subfix in self.subfixes:
                        subfile = "{0}.srt".format(name + subfix)
                        cmd += ["-i", subfile]
                else:
                    subfile = "{0}.srt".format(name)
                    cmd += ["-i", subfile]

            arguments += ["-y", tempfile]
            cmd += arguments
            p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
            stdout, stderr = p.communicate()
            if p.returncode != 0:
                stderr = stderr.decode('utf-8', 'replace')
                msg = stderr.strip().split('\n')[-1]
                log.error("Something went wrong: %s", msg)
                return

            if self.merge_subtitle and not self.external_subtitle:
                log.info("Muxing done, removing the old files.")
                if len(self.subfixes) >= 2:
                    for subfix in self.subfixes:
                        subfile = "{0}.srt".format(name + subfix)
                        os.remove(subfile)
                else: os.remove(subfile)
            else: log.info("Muxing done, removing the old file.")
            os.remove(orig_filename)
            os.rename(tempfile, new_name)
开发者ID:qnorsten,项目名称:svtplay-dl,代码行数:55,代码来源:__init__.py


示例17: find_all_episodes

    def find_all_episodes(self, options):
        match = re.search(r'<link rel="alternate" type="application/rss\+xml" [^>]*href="([^"]+)"', self.get_urldata())
        if match is None:
            log.info("Couldn't retrieve episode list as rss, trying to scrape")
            return self.scrape_episodes(options)

        url = "http://urplay.se%s" % match.group(1).replace("&amp;", "&")
        xml = ET.XML(self.http.request("get", url).content)

        episodes = [x.text for x in xml.findall(".//item/link")]
        episodes_new = []
        n = 0
        for i in episodes:
            if n == options.all_last:
                break
            if i not in episodes_new:
                episodes_new.append(i)
            n += 1
        return episodes_new
开发者ID:deadbeef84,项目名称:svtplay-dl,代码行数:19,代码来源:urplay.py


示例18: get_media

def get_media(url, options):
    if "http" not in url[:4]:
        url = "http://%s" % url

    stream = service_handler(sites, options, url)
    if not stream:
        generic = Generic(options, url)
        url, stream = generic.get(sites)
    if not stream:
        if url.find(".f4m") > 0 or url.find(".m3u8") > 0:
            stream = Raw(options, url)
        if not stream:
            log.error("That site is not supported. Make a ticket or send a message")
            sys.exit(2)

    if options.all_episodes:
        if options.output and os.path.isfile(options.output):
            log.error("Output must be a directory if used with --all-episodes")
            sys.exit(2)
        elif options.output and not os.path.exists(options.output):
            try:
                os.makedirs(options.output)
            except OSError as e:
                log.error("%s: %s" % (e.strerror, e.filename))
                return

        episodes = stream.find_all_episodes(options)
        if episodes is None:
            return
        for idx, o in enumerate(episodes):
            if o == url:
                substream = stream
            else:
                substream = service_handler(sites, options, o)

            log.info("Episode %d of %d", idx + 1, len(episodes))

            # get_one_media overwrites options.output...
            get_one_media(substream, copy.copy(options))
    else:
        get_one_media(stream, options)
开发者ID:gusseleet,项目名称:svtplay-dl,代码行数:41,代码来源:__init__.py


示例19: merge

    def merge(self):
        if self.detect is None:
            log.error("Cant detect ffmpeg or avconv. Cant mux files without it.")
            return
        if self.stream.finished is False:
            return

        orig_filename = self.stream.options.output

        cmd = [self.detect, "-i", orig_filename]
        _, stdout, stderr = run_program(cmd, False)  # return 1 is good here.
        videotrack, audiotrack = self._checktracks(stderr)

        if self.merge_subtitle:
            log.info("Merge audio, video and subtitle into {0}".format(orig_filename))
        else:
            log.info("Merge audio and video into {0}".format(orig_filename))

        tempfile = u"{0}.temp".format(orig_filename)
        name, ext = os.path.splitext(orig_filename)
        arguments = ["-c:v", "copy", "-c:a", "copy", "-f", "mp4"]
        if ext == ".ts":
            audio_filename = u"{0}.audio.ts".format(name)
            arguments += ["-bsf:a", "aac_adtstoasc"]
        else:
            audio_filename = u"{0}.m4a".format(name)
        cmd = [self.detect, "-i", orig_filename, "-i", audio_filename]

        if self.merge_subtitle:
            langs = self.sublanguage()
            for stream_num, language in enumerate(langs, start=audiotrack + 1):
                arguments += ["-map", "{}".format(videotrack), "-map", "{}".format(audiotrack), "-map", str(stream_num), "-c:s:" + str(stream_num - 2), "mov_text",
                              "-metadata:s:s:" + str(stream_num - 2), "language=" + language]
            if len(self.subfixes) >= 2:
                for subfix in self.subfixes:
                    subfile = "{0}.srt".format(name + subfix)
                    cmd += ["-i", subfile]
            else:
                subfile = "{0}.srt".format(name)
                cmd += ["-i", subfile]

        arguments += ["-y", tempfile]
        cmd += arguments
        returncode, stdout, stderr = run_program(cmd)
        if returncode != 1:
            return

        log.info("Merging done, removing old files.")
        os.remove(orig_filename)
        os.remove(audio_filename)
        if self.merge_subtitle and not self.external_subtitle:
            if len(self.subfixes) >= 2:
                for subfix in self.subfixes:
                    subfile = "{0}.srt".format(name + subfix)
                    os.remove(subfile)
            else:
                os.remove(subfile)
        os.rename(tempfile, orig_filename)
开发者ID:olof,项目名称:svtplay-dl,代码行数:58,代码来源:__init__.py


示例20: download

    def download(self):
        """ Get the stream from RTMP """
        args = []
        if self.options.live:
            args.append("-v")

        if self.options.resume:
            args.append("-e")

        extension = re.search(r"(\.[a-z0-9]+)$", self.url)
        if self.options.output != "-":
            if not extension:
                self.options.output = "%s.flv" % self.options.output
            else:
                self.options.output = self.options.output + extension.group(1)
            log.info("Outfile: %s", self.options.output)
            if os.path.isfile(self.options.output) and not self.options.force:
                log.info("File already exists. use --force to overwrite")
                return
            args += ["-o", self.options.output]
        if self.options.silent or self.options.output == "-":
            args.append("-q")
        if self.options.other:
            if is_py2:
                args += shlex.split(self.options.other.encode("utf-8"))
            else:
                args += shlex.split(self.options.other)

        if self.options.verbose:
            args.append("-V")

        command = ["rtmpdump", "-r", self.url] + args
        log.debug("Running: %s", " ".join(command))
        try:
            subprocess.call(command)
        except OSError as e:
            log.error("Could not execute rtmpdump: " + e.strerror)
开发者ID:antoneliasson,项目名称:svtplay-dl,代码行数:37,代码来源:rtmp.py



注:本文中的svtplay_dl.log.log.info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python subtitle.subtitle函数代码示例发布时间:2022-05-27
下一篇:
Python log.error函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap