当前位置: 首页>>代码示例>>Python>>正文


Python Util.shell方法代码示例

本文整理汇总了Python中lib.util.Util.shell方法的典型用法代码示例。如果您正苦于以下问题:Python Util.shell方法的具体用法?Python Util.shell怎么用?Python Util.shell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.util.Util的用法示例。


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

示例1: Ripper

# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import shell [as 别名]

#.........这里部分代码省略.........
            disc    = str(track.disc()).zfill(2)
            year    = track.album().year()
            artists = ''

            for artist in track.artists():
                while not artist.is_loaded():
                    time.sleep(0.1)

                artists += artist.name()+' / '

            artists = artists.strip().rstrip('/').rstrip()

            puts('Track URI:    %s'        % Link.from_track(track))

            try:
                puts('Album:        %s (%i)'   % (album, year))
            except UnicodeEncodeError:
                sys.stdout.write(' > Album:        %s (%i)\n' % (album, year))

            try:
                puts('Artist(s):    %s'        % artists)
            except UnicodeEncodeError:
                sys.stdout.write(' > Artist(s):    %s\n' % artists)

            puts('Album artist: %s'        % track.album().artist().name())

            try:
                puts('Track:        %s-%s. %s' % (disc, number, title))
            except UnicodeEncodeError:
                sys.stdout.write(' > Track:        %s-%s. %s \n' \
                        % (disc, number, title))

        command = 'lame -b 320 -h -r --silent - temp.mp3'
        p = Popen(command, stdin=PIPE, shell=True)
        self._all_processes.append(p)

        self._pipe       = p.stdin
        self._ripping    = True
        self._dotCount   = 0
        self._downloaded = 0.0
        self._duration   = track.duration()

        return True

    def rip_terminate(self, session, track):
        if self._pipe is not None:
            self._pipe.close()
        self._ripping = False

    def rip(self,
            session,     # the current session
            frames,      # the audio data
            frame_size,  # bytes per frame
            num_frames,  # number of frames in this delivery
            sample_type, # currently this is always 0, which means 16-bit
                         # signed native endian integer samples
            sample_rate, # audio sample rate, in samples per second
            channels):   # number of audio channels, currently 1 or 2

        self._downloaded += float(frame_size) * float(num_frames)

        if self._ripping:
            # 320 kilobits per second
            # 40 kilobytes per second
            # duration in milliseconds
            # 40 bytes per millisecond
开发者ID:lovek323,项目名称:spotify-ripper,代码行数:70,代码来源:ripper.py


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