本文整理汇总了Python中spotify_ripper.progress.Progress类的典型用法代码示例。如果您正苦于以下问题:Python Progress类的具体用法?Python Progress怎么用?Python Progress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Progress类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, args):
threading.Thread.__init__(self)
# set to a daemon thread
self.daemon = True
# initalize progress meter
self.progress = Progress(args, self)
self.args = args
self.logged_in = threading.Event()
self.logged_out = threading.Event()
self.logged_out.set()
config = spotify.Config()
default_dir = default_settings_dir()
# application key location
if args.key is not None:
config.load_application_key_file(args.key[0])
else:
if not os.path.exists(default_dir):
os.makedirs(default_dir)
app_key_path = os.path.join(default_dir, "spotify_appkey.key")
if not os.path.exists(app_key_path):
print(
"\n"
+ Fore.YELLOW
+ "Please copy your spotify_appkey.key to "
+ default_dir
+ ", or use the --key|-k option"
+ Fore.RESET
)
sys.exit(1)
config.load_application_key_file(app_key_path)
# settings directory
if args.settings is not None:
settings_dir = norm_path(args.settings[0])
config.settings_location = settings_dir
config.cache_location = settings_dir
else:
config.settings_location = default_dir
config.cache_location = default_dir
self.session = spotify.Session(config=config)
bit_rates = dict([("160", BitRate.BITRATE_160K), ("320", BitRate.BITRATE_320K), ("96", BitRate.BITRATE_96K)])
self.session.preferred_bitrate(bit_rates[args.quality])
self.session.on(spotify.SessionEvent.CONNECTION_STATE_UPDATED, self.on_connection_state_changed)
self.session.on(spotify.SessionEvent.END_OF_TRACK, self.on_end_of_track)
self.session.on(spotify.SessionEvent.MUSIC_DELIVERY, self.on_music_delivery)
self.session.on(spotify.SessionEvent.PLAY_TOKEN_LOST, self.play_token_lost)
self.session.on(spotify.SessionEvent.LOGGED_IN, self.on_logged_in)
self.event_loop = spotify.EventLoop(self.session)
self.event_loop.start()
示例2: __init__
def __init__(self, args):
threading.Thread.__init__(self)
# initialize progress meter
self.progress = Progress(args, self)
self.args = args
# initially logged-out
self.logged_out.set()
config = spotify.Config()
default_dir = default_settings_dir()
self.post = PostActions(args, self)
# application key location
if args.key is not None:
config.load_application_key_file(args.key[0])
else:
if not os.path.exists(default_dir):
os.makedirs(default_dir)
app_key_path = os.path.join(default_dir, "spotify_appkey.key")
if not os.path.exists(app_key_path):
print("\n" + Fore.YELLOW +
"Please copy your spotify_appkey.key to " +
default_dir + ", or use the --key|-k option" +
Fore.RESET)
sys.exit(1)
config.load_application_key_file(app_key_path)
# settings directory
if args.settings is not None:
settings_dir = norm_path(args.settings[0])
config.settings_location = settings_dir
config.cache_location = settings_dir
else:
config.settings_location = default_dir
config.cache_location = default_dir
self.session = spotify.Session(config=config)
self.session.volume_normalization = args.normalize
# disable scrobbling
self.session.social.set_scrobbling(
spotify.SocialProvider.SPOTIFY,
spotify.ScrobblingState.LOCAL_DISABLED)
self.session.social.set_scrobbling(
spotify.SocialProvider.FACEBOOK,
spotify.ScrobblingState.LOCAL_DISABLED)
self.session.social.set_scrobbling(
spotify.SocialProvider.LASTFM,
spotify.ScrobblingState.LOCAL_DISABLED)
bit_rates = dict([
('160', BitRate.BITRATE_160K),
('320', BitRate.BITRATE_320K),
('96', BitRate.BITRATE_96K)])
self.session.preferred_bitrate(bit_rates[args.quality])
self.session.on(spotify.SessionEvent.CONNECTION_STATE_UPDATED,
self.on_connection_state_changed)
self.session.on(spotify.SessionEvent.END_OF_TRACK,
self.on_end_of_track)
self.session.on(spotify.SessionEvent.MUSIC_DELIVERY,
self.on_music_delivery)
self.session.on(spotify.SessionEvent.PLAY_TOKEN_LOST,
self.play_token_lost)
self.session.on(spotify.SessionEvent.LOGGED_IN,
self.on_logged_in)
self.event_loop = EventLoop(self.session, 0.1, self)
示例3: Ripper
class Ripper(threading.Thread):
name = 'SpotifyRipperThread'
audio_file = None
pcm_file = None
wav_file = None
rip_proc = None
pipe = None
current_playlist = None
current_album = None
idx_digits = 3
login_success = False
progress = None
sync = None
post = None
dev_null = None
rip_queue = queue.Queue()
# threading events
logged_in = threading.Event()
logged_out = threading.Event()
ripping = threading.Event()
end_of_track = threading.Event()
finished = threading.Event()
abort = threading.Event()
def __init__(self, args):
threading.Thread.__init__(self)
# initialize progress meter
self.progress = Progress(args, self)
self.args = args
# initially logged-out
self.logged_out.set()
config = spotify.Config()
default_dir = default_settings_dir()
self.post = PostActions(args, self)
# application key location
if args.key is not None:
config.load_application_key_file(args.key[0])
else:
if not os.path.exists(default_dir):
os.makedirs(default_dir)
app_key_path = os.path.join(default_dir, "spotify_appkey.key")
if not os.path.exists(app_key_path):
print("\n" + Fore.YELLOW +
"Please copy your spotify_appkey.key to " +
default_dir + ", or use the --key|-k option" +
Fore.RESET)
sys.exit(1)
config.load_application_key_file(app_key_path)
# settings directory
if args.settings is not None:
settings_dir = norm_path(args.settings[0])
config.settings_location = settings_dir
config.cache_location = settings_dir
else:
config.settings_location = default_dir
config.cache_location = default_dir
self.session = spotify.Session(config=config)
self.session.volume_normalization = args.normalize
# disable scrobbling
self.session.social.set_scrobbling(
spotify.SocialProvider.SPOTIFY,
spotify.ScrobblingState.LOCAL_DISABLED)
self.session.social.set_scrobbling(
spotify.SocialProvider.FACEBOOK,
spotify.ScrobblingState.LOCAL_DISABLED)
self.session.social.set_scrobbling(
spotify.SocialProvider.LASTFM,
spotify.ScrobblingState.LOCAL_DISABLED)
bit_rates = dict([
('160', BitRate.BITRATE_160K),
('320', BitRate.BITRATE_320K),
('96', BitRate.BITRATE_96K)])
self.session.preferred_bitrate(bit_rates[args.quality])
self.session.on(spotify.SessionEvent.CONNECTION_STATE_UPDATED,
self.on_connection_state_changed)
self.session.on(spotify.SessionEvent.END_OF_TRACK,
self.on_end_of_track)
self.session.on(spotify.SessionEvent.MUSIC_DELIVERY,
self.on_music_delivery)
self.session.on(spotify.SessionEvent.PLAY_TOKEN_LOST,
self.play_token_lost)
self.session.on(spotify.SessionEvent.LOGGED_IN,
self.on_logged_in)
#.........这里部分代码省略.........
示例4: Ripper
class Ripper(threading.Thread):
audio_file = None
pcm_file = None
rip_proc = None
pipe = None
ripping = False
finished = False
current_playlist = None
tracks_to_remove = []
end_of_track = threading.Event()
idx_digits = 3
login_success = False
progress = None
dev_null = None
def __init__(self, args):
threading.Thread.__init__(self)
# set to a daemon thread
self.daemon = True
# initalize progress meter
self.progress = Progress(args, self)
self.args = args
self.logged_in = threading.Event()
self.logged_out = threading.Event()
self.logged_out.set()
config = spotify.Config()
default_dir = default_settings_dir()
# application key location
if args.key is not None:
config.load_application_key_file(args.key[0])
else:
if not os.path.exists(default_dir):
os.makedirs(default_dir)
app_key_path = os.path.join(default_dir, "spotify_appkey.key")
if not os.path.exists(app_key_path):
print("\n" + Fore.YELLOW + "Please copy your spotify_appkey.key to " + default_dir +
", or use the --key|-k option" + Fore.RESET)
sys.exit(1)
config.load_application_key_file(app_key_path)
# settings directory
if args.settings is not None:
settings_dir = norm_path(args.settings[0])
config.settings_location = settings_dir
config.cache_location = settings_dir
else:
config.settings_location = default_dir
config.cache_location = default_dir
self.session = spotify.Session(config=config)
bit_rates = dict([
('160', BitRate.BITRATE_160K),
('320', BitRate.BITRATE_320K),
('96', BitRate.BITRATE_96K)])
self.session.preferred_bitrate(bit_rates[args.quality])
self.session.on(spotify.SessionEvent.CONNECTION_STATE_UPDATED,
self.on_connection_state_changed)
self.session.on(spotify.SessionEvent.END_OF_TRACK,
self.on_end_of_track)
self.session.on(spotify.SessionEvent.MUSIC_DELIVERY,
self.on_music_delivery)
self.session.on(spotify.SessionEvent.PLAY_TOKEN_LOST,
self.play_token_lost)
self.session.on(spotify.SessionEvent.LOGGED_IN,
self.on_logged_in)
self.event_loop = spotify.EventLoop(self.session)
self.event_loop.start()
def run(self):
args = self.args
# login
print("Logging in...")
if args.last:
self.login_as_last()
elif args.user != None and args.password == None:
password = getpass.getpass()
self.login(args.user[0], password)
else:
self.login(args.user[0], args.password[0])
if not self.login_success:
print(Fore.RED + "Encountered issue while logging into Spotify, aborting..." + Fore.RESET)
self.finished = True
return
# create track iterator
for uri in args.uri:
if os.path.exists(uri):
tracks = itertools.chain(*[self.load_link(line.strip()) for line in open(uri)])
#.........这里部分代码省略.........
示例5: Ripper
class Ripper(threading.Thread):
name = 'SpotifyRipperThread'
audio_file = None
pcm_file = None
wav_file = None
rip_proc = None
pipe = None
current_playlist = None
current_album = None
current_chart = None
login_success = False
progress = None
sync = None
post = None
web = None
dev_null = None
stop_time = None
track_path_cache = {}
rip_queue = queue.Queue()
# threading events
logged_in = threading.Event()
logged_out = threading.Event()
ripper_continue = threading.Event()
ripping = threading.Event()
end_of_track = threading.Event()
finished = threading.Event()
abort = threading.Event()
skip = threading.Event()
play_token_resume = threading.Event()
def __init__(self, args):
threading.Thread.__init__(self)
# initialize progress meter
self.progress = Progress(args, self)
self.args = args
# initially logged-out
self.logged_out.set()
config = spotify.Config()
default_dir = default_settings_dir()
self.post = PostActions(args, self)
self.web = WebAPI(args, self)
proxy = os.environ.get('http_proxy')
if proxy is not None:
config.proxy = proxy
# application key location
if args.key is not None:
config.load_application_key_file(args.key)
else:
if not path_exists(default_dir):
os.makedirs(enc_str(default_dir))
app_key_path = os.path.join(default_dir, "spotify_appkey.key")
if not path_exists(app_key_path):
print("\n" + Fore.YELLOW +
"Please copy your spotify_appkey.key to " +
default_dir + ", or use the --key|-k option" +
Fore.RESET)
sys.exit(1)
config.load_application_key_file(app_key_path)
# settings directory
if args.settings is not None:
settings_dir = norm_path(args.settings)
config.settings_location = settings_dir
config.cache_location = settings_dir
else:
config.settings_location = default_dir
config.cache_location = default_dir
self.session = spotify.Session(config=config)
self.session.volume_normalization = args.normalize
# disable scrobbling
self.session.social.set_scrobbling(
spotify.SocialProvider.SPOTIFY,
spotify.ScrobblingState.LOCAL_DISABLED)
self.session.social.set_scrobbling(
spotify.SocialProvider.FACEBOOK,
spotify.ScrobblingState.LOCAL_DISABLED)
self.session.social.set_scrobbling(
spotify.SocialProvider.LASTFM,
spotify.ScrobblingState.LOCAL_DISABLED)
bit_rates = dict([
('160', BitRate.BITRATE_160K),
('320', BitRate.BITRATE_320K),
('96', BitRate.BITRATE_96K)])
self.session.preferred_bitrate(bit_rates[args.quality])
#.........这里部分代码省略.........
示例6: Ripper
class Ripper(threading.Thread):
audio_file = None
pcm_file = None
wav_file = None
rip_proc = None
pipe = None
ripping = False
finished = False
current_playlist = None
current_album = None
tracks_to_remove = []
end_of_track = threading.Event()
idx_digits = 3
login_success = False
progress = None
sync = None
dev_null = None
fail_log_file = None
success_tracks = []
failure_tracks = []
def __init__(self, args):
threading.Thread.__init__(self)
# set to a daemon thread
self.daemon = True
# initialize progress meter
self.progress = Progress(args, self)
self.args = args
self.logged_in = threading.Event()
self.logged_out = threading.Event()
self.logged_out.set()
config = spotify.Config()
default_dir = default_settings_dir()
# create a log file for rip failures
if args.fail_log is not None:
_base_dir = base_dir(args)
if not os.path.exists(_base_dir):
os.makedirs(_base_dir)
self.fail_log_file = open(os.path.join(_base_dir, args.fail_log[0]), "w")
# application key location
if args.key is not None:
config.load_application_key_file(args.key[0])
else:
if not os.path.exists(default_dir):
os.makedirs(default_dir)
app_key_path = os.path.join(default_dir, "spotify_appkey.key")
if not os.path.exists(app_key_path):
print(
"\n"
+ Fore.YELLOW
+ "Please copy your spotify_appkey.key to "
+ default_dir
+ ", or use the --key|-k option"
+ Fore.RESET
)
sys.exit(1)
config.load_application_key_file(app_key_path)
# settings directory
if args.settings is not None:
settings_dir = norm_path(args.settings[0])
config.settings_location = settings_dir
config.cache_location = settings_dir
else:
config.settings_location = default_dir
config.cache_location = default_dir
self.session = spotify.Session(config=config)
self.session.volume_normalization = args.normalize
bit_rates = dict([("160", BitRate.BITRATE_160K), ("320", BitRate.BITRATE_320K), ("96", BitRate.BITRATE_96K)])
self.session.preferred_bitrate(bit_rates[args.quality])
self.session.on(spotify.SessionEvent.CONNECTION_STATE_UPDATED, self.on_connection_state_changed)
self.session.on(spotify.SessionEvent.END_OF_TRACK, self.on_end_of_track)
self.session.on(spotify.SessionEvent.MUSIC_DELIVERY, self.on_music_delivery)
self.session.on(spotify.SessionEvent.PLAY_TOKEN_LOST, self.play_token_lost)
self.session.on(spotify.SessionEvent.LOGGED_IN, self.on_logged_in)
self.event_loop = spotify.EventLoop(self.session)
self.event_loop.start()
def log_failure(self, track):
self.failure_tracks.append(track)
if self.fail_log_file is not None:
self.fail_log_file.write(track.link.uri + "\n")
def end_failure_log(self):
if self.fail_log_file is not None:
file_name = self.fail_log_file.name
self.fail_log_file.flush()
#.........这里部分代码省略.........