本文整理汇总了Python中lib.util.Util.get_mp3_path方法的典型用法代码示例。如果您正苦于以下问题:Python Util.get_mp3_path方法的具体用法?Python Util.get_mp3_path怎么用?Python Util.get_mp3_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.util.Util
的用法示例。
在下文中一共展示了Util.get_mp3_path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Ripper
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import get_mp3_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
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)
self._end_of_track.set()
def rip_init(self, session, track):
mp3_path = self._util.get_mp3_path(track, escaped = False)
print ''
print colored.yellow(str(Link.from_track(track)))
with indent(3, quote = colored.white(' > ')):
if self._json_queue.is_downloaded(Link.from_track(track)) \
or os.path.isfile(mp3_path):
try:
puts('Skipping %s' % mp3_path)
except UnicodeEncodeError:
# Non-ASCII characters
sys.stdout.write(' > Skipping %s\n' % mp3_path)
return False
else:
try:
puts('Downloading %s' % mp3_path)
except UnicodeEncodeError:
# Non-ASCII characters
sys.stdout.write(' > Downloading %s\n' % mp3_path)
album = track.album().name()
title = track.name()
number = str(track.index()).zfill(2)
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:
#.........这里部分代码省略.........