本文整理汇总了Python中lib.util.Util.get_output_path方法的典型用法代码示例。如果您正苦于以下问题:Python Util.get_output_path方法的具体用法?Python Util.get_output_path怎么用?Python Util.get_output_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.util.Util
的用法示例。
在下文中一共展示了Util.get_output_path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Ripper
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import get_output_path [as 别名]
class Ripper(Jukebox):
_all_processes = [ ]
_dot_count = 0
_downloaded = 0.0
_duration = 0
_end_of_track = None
_pipe = None
_json_queue = None
_ripper_thread = None
_ripping = False
_util = None
_meta = {}
def __init__(self, *a, **kw):
Jukebox.__init__(self, *a, **kw)
self._json_queue = JsonQueue()
self._util = Util(self._json_queue)
self._ripper_thread = RipperThread(self, self._json_queue)
self._end_of_track = self._ripper_thread.get_end_of_track()
self.set_ui_thread(self._ripper_thread)
self.session.set_preferred_bitrate(1) # 320 kbps (ostensibly)
def music_delivery_safe(self, \
session, \
frames, \
frame_size, \
num_frames, \
sample_type, \
sample_rate, \
channels):
self.rip(
session,
frames,
frame_size,
num_frames,
sample_type,
sample_rate,
channels)
return num_frames
def end_of_track(self, session):
Jukebox.end_of_track(self, session)
os.rename(self._meta["out_path"] + ".raw.tmp",self._meta["out_path"] + ".raw")
self._end_of_track.set()
def get_encoders(self):
rv = []
for enc,args in self._util.get_encoders().iteritems():
if not enc in ENCODERS:
print colored.red("can't find encoder %s" %enc)
continue
e = ENCODERS[enc]()
e.args = args
rv.append(e)
return rv
def rip_init(self, session, track):
output_path = self._util.get_output_path(track, escaped = False)
print ''
print colored.yellow(str(Link.from_track(track)))
required = False
if self._util.config.download_missing:
for enc in self.get_encoders():
if not os.path.exists("%s.%s" %(output_path, enc.suffix)):
required = True
if not self._json_queue.is_downloaded(Link.from_track(track)):
required = True
# or os.path.isfile(output_path):
with indent(3, quote = colored.white(' > ')):
if not required:
try:
puts('Skipping %s' % output_path)
except UnicodeEncodeError:
# Non-ASCII characters
sys.stdout.write(' > Skipping %s\n' % output_path)
return False
else:
try:
puts('Downloading %s' % output_path)
except UnicodeEncodeError:
# Non-ASCII characters
sys.stdout.write(' > Downloading %s\n' % output_path)
meta = self._meta = self.prepare_meta(session, track)
puts('Track URI: %s' % Link.from_track(track))
try:
puts('Album: %s (%i)' % (meta["album"], meta["year"]))
except UnicodeEncodeError:
sys.stdout.write(' > Album: %s (%i)\n' % (meta["album"], meta["year"]))
try:
puts('Artist(s): %s' % meta["artist"])
#.........这里部分代码省略.........