本文整理汇总了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