本文整理汇总了Python中pylast.md5方法的典型用法代码示例。如果您正苦于以下问题:Python pylast.md5方法的具体用法?Python pylast.md5怎么用?Python pylast.md5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylast
的用法示例。
在下文中一共展示了pylast.md5方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_network
# 需要导入模块: import pylast [as 别名]
# 或者: from pylast import md5 [as 别名]
def setup_network(self):
api_key = self.settings.get('APIKEY')
api_secret = self.settings.get('APISECRET')
username = self.settings.get('USERNAME')
password = pylast.md5(self.settings.get('PASSWORD'))
net = pylast.LastFMNetwork(api_key=api_key, api_secret=api_secret,
username=username, password_hash=password)
return net
示例2: __init__
# 需要导入模块: import pylast [as 别名]
# 或者: from pylast import md5 [as 别名]
def __init__(self, config, cast_name, available_devices=None):
self.cast_name = cast_name
self.cast_config = config.get('chromecast', {})
self.app_whitelist = self.cast_config.get('app_whitelist', APP_WHITELIST)
self.last_scrobbled = {}
self.current_track = {}
self.current_time = 0
self.last_poll = time.time()
self._connect_chromecast(available_devices)
if not self.cast:
raise ChromecastNotFoundException()
self.scrobblers = []
if 'lastfm' in config:
self.scrobblers.append(pylast.LastFMNetwork(
api_key=config['lastfm']['api_key'],
api_secret=config['lastfm']['api_secret'],
username=config['lastfm']['user_name'],
password_hash=pylast.md5(config['lastfm']['password'])))
if 'librefm' in config:
self.scrobblers.append(pylast.LibreFMNetwork(
session_key=config['librefm']['session_key'],
username=config['librefm']['user_name'],
password_hash=pylast.md5(config['librefm']['password'])
))
self.estimate_spotify_timestamp = self.cast_config.get(
'estimate_spotify_timestamp', True)
示例3: __init__
# 需要导入模块: import pylast [as 别名]
# 或者: from pylast import md5 [as 别名]
def __init__(self, api_key, api_secret, username, password):
"""
:param api_key: Last.FM API key, see https://www.last.fm/api
:type api_key: str
:param api_secret: Last.FM API secret, see https://www.last.fm/api
:type api_key: str
:param username: Last.FM username
:type api_key: str
:param password: Last.FM password, used to sign the requests
:type api_key: str
"""
import pylast
super().__init__()
self.api_key = api_key
self.api_secret = api_secret
self.username = username
self.password = password
self.lastfm = pylast.LastFMNetwork(
api_key = self.api_key,
api_secret = self.api_secret,
username = self.username,
password_hash = pylast.md5(self.password))
示例4: retry_queue
# 需要导入模块: import pylast [as 别名]
# 或者: from pylast import md5 [as 别名]
def retry_queue(self):
self.logger.info('Retrying scrobble cache.')
for key in self.cache:
# do submissions retry
try:
self.cache[key][2] += 1
lastfm = pylast.LastFMNetwork(
api_key=self.api_key,
api_secret=self.api_secret,
username=self.user_name,
password_hash=pylast.md5(self.password))
lastfm.scrobble(self.cache[key][0],
self.cache[key][1],
timestamp=int(time.time()),
album=self.cache[key][3])
except:
self.logger.warning('Failed to resubmit artist={artist}, title={title}, album={album}, age={age}'.format(
artist=self.cache[key][0],
title=self.cache[key][1],
album=self.cache[key][3],
age=self.cache[key][2]))
if self.cache[key][2] >= ScrobbleCache.MAX_CACHE_AGE:
self.logger.info('MAX_CACHE_AGE for {key} : {artist} - {title}'.format(key=key, artist=self.cache[key][0], title=self.cache[key][1]))
self.remove(key)
continue
# successful send to last.fm, remove from cache
self.logger.info('cache resubmit of artist={artist}, title={title}, album={album} age={age}. Removing.'.format(
artist=self.cache[key][0],
title=self.cache[key][1],
album=self.cache[key][3],
age=self.cache[key][2]))
self.remove(key)
self.sync()
示例5: __init__
# 需要导入模块: import pylast [as 别名]
# 或者: from pylast import md5 [as 别名]
def __init__(self):
self.credentials = dict({
'username': None,
'password': None,
'api_key': None,
'api_secret': None
})
if args.lastfm_credentials:
with open(args.lastfm_credentials) as f:
self.credentials.update(
{k: v.encode('utf-8') if isinstance(v, unicode) else v
for (k, v)
in json.loads(f.read()).iteritems()})
if args.lastfm_username:
self.credentials['username'] = args.lastfm_username
if args.lastfm_password:
self.credentials['password'] = args.lastfm_password
if args.lastfm_api_key:
self.credentials['api_key'] = args.lastfm_api_key
if args.lastfm_api_secret:
self.credentials['api_secret'] = args.lastfm_api_secret
if not (self.credentials['username'] and
self.credentials['password'] and
self.credentials['api_key'] and
self.credentials['api_secret']):
self.on = False
print 'Last.fm: incomplete credentials, not launched'
return
self.on = True
self.lastfm_network = pylast.LastFMNetwork(
api_key=self.credentials['api_key'],
api_secret=self.credentials['api_secret'],
username=self.credentials['username'],
password_hash=pylast.md5(self.credentials['password'])
)
self.metadata = None
self.timestamp = None
self.playing = bool(lib.SpPlaybackIsPlaying())
self.play_cumul = 0
self.play_beg = time.time()
# This two functions are used to count the playing time of each song