• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pylast.md5函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pylast.md5函数的典型用法代码示例。如果您正苦于以下问题:Python md5函数的具体用法?Python md5怎么用?Python md5使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了md5函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    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)
开发者ID:erik,项目名称:lastcast,代码行数:33,代码来源:__init__.py


示例2: main

def main():

    event = sys.argv[1]
    lines = sys.stdin.readlines()
    fields = dict([line.strip().split("=", 1) for line in lines])

    # fields: title, artist, album, songDuration, songPlayed, rating, stationName, pRet, pRetStr, wRet, wRetStr, rating
    artist = fields["artist"]
    title = fields["title"]
    song_duration = int(fields["songDuration"])
    song_played = int(fields["songPlayed"])
    rating = int(fields["rating"])

    # events: songstart, songfinish, ???
    import pylast

    if (
        event == "songfinish"
        and song_duration > 1000 * MIN_DURATION
        and (100.0 * song_played / song_duration > THRESHOLD or song_played > 1000 * PLAYED_ENOUGH)
    ):
        song_started = int(time.time() - song_played / 1000.0)
        network = pylast.LastFMNetwork(
            api_key=API_KEY, api_secret=API_SECRET, username=USERNAME, password_hash=pylast.md5(PASSWORD)
        )
        network.scrobble(artist=artist, title=title, timestamp=song_started)
    if event == "songfinish" and rating > 0:
        network = pylast.LastFMNetwork(
            api_key=API_KEY, api_secret=API_SECRET, username=USERNAME, password_hash=pylast.md5(PASSWORD)
        )
        track = network.get_track(artist, title)
        if rating == 1:
            track.love()
        elif rating == 2:
            track.ban()
开发者ID:kv35,项目名称:pianobarfly,代码行数:35,代码来源:scrobble.py


示例3: main

def main():
    """run the main loop of the vinyl-fm scrobbler"""
    username = raw_input('Last.fm username: ')
    password_hash = pylast.md5(getpass.getpass())
    last_song = ('', '')
    last_songtitle = ('', '')
    last_artisttitle = ('', '')
    
    network = pylast.LastFMNetwork(api_key = LASTFM_API_KEY, api_secret = 
        LASTFM_SECRET_KEY, username = username, password_hash = password_hash)
    
    
    print "Listening... (control-C to exit)"
    
    while True:
        audio_reader.record(35, 'tmpVFM.wav')
        current_song = identify.match_song(30, 'tmpVFM.wav')

        if current_song == (None, None):
            print 'No Match Detected!'
            continue
	#if current_song.artist != last_song.artist and current_song.title != last_song.title:
           # network.scrobble(current_song.artist, 
            #                 current_song.title,
             #                int(time.time()))
         #   print "%s - %s" % (current_song.artist, current_song.title)
            
	if current_song.title != last_songtitle and current_song.artist != last_artisttitle:
	     network.scrobble(current_song.artist,
                              current_song.title,
                              int(time.time()))
             print "%s - %s" % (current_song.artist, current_song.title)
	     last_songtitle = current_song.title
	     last_artisttitle = current_song.artist
	     current_song = last_song
开发者ID:porkloin,项目名称:vinyl-fm,代码行数:35,代码来源:vinylfm.py


示例4: ScrobbleTrack

    def ScrobbleTrack(self, track):
        try:
            lastfm_username = os.environ.get('LASTFM_USERNAME')
            lastfm_password = pylast.md5(os.environ.get('LASTFM_PASSWORD'))
            lastfm_apikey = os.environ.get('LASTFM_APIKEY')
            lastfm_apisecret = os.environ.get('LASTFM_APISECRET')

            lastfm = pylast.LastFMNetwork(api_key=lastfm_apikey,
                                          api_secret=lastfm_apisecret,
                                          username=lastfm_username,
                                          password_hash=lastfm_password)

            # Get last modified time of track (which seems to be last played)
            # Divide by 1,000,000 to get unix timestamp in seconds
            time_played = (int(track['lastModifiedTimestamp']) / 1000000)
            print 'Scrobbling track:', \
                track['artist'], '-', \
                track['title'], '-', \
                datetime.fromtimestamp(float(time_played))

            lastfm.scrobble(artist=track['artist'],
                            title=track['title'],
                            timestamp=time_played)

            time.sleep(0.5)
        except:
            print "There was a problem scrobbling the track."
开发者ID:reeves122,项目名称:google-music-automation,代码行数:27,代码来源:googlemusic_util.py


示例5: _main

    def _main(self):
        """
        get's automatically called from Memacs class
        """

        options = {
            'api_secret': self._get_config_option('api_secret'),
            'api_key': self._get_config_option('api_key'),
            'password_hash': pylast.md5(self._get_config_option('password')),
            'username': self._get_config_option('username')
        }

        try:

            if 'lastfm' in self._get_config_option('network'):
                network = pylast.LastFMNetwork(**options)

            if 'librefm' in self._get_config_option('network'):
                network = pylast.LibreFMNetwork(**options)

            user = network.get_user(options['username'])

            self._handle_recent_tracks(user.get_recent_tracks(limit=100))

        except pylast.WSError as e:
            logging.error('an issue with the network web service occured: %s' % e)
            sys.exit(1)
开发者ID:novoid,项目名称:Memacs,代码行数:27,代码来源:lastfm.py


示例6: __connect

 def __connect(self, username, password, populate_loved=False):
     """
         Connect lastfm
         @param username as str
         @param password as str
         @thread safe
     """
     self.__username = username
     if self.__goa is not None or (password != '' and username != ''):
         self.__is_auth = True
     else:
         self.__is_auth = False
     try:
         self.session_key = ""
         self.__check_for_proxy()
         if self.__goa is not None:
             self.session_key = self.__goa.call_get_access_token_sync(
                                                                   None)[0]
         else:
             skg = SessionKeyGenerator(self)
             self.session_key = skg.get_session_key(
                                               username=self.__username,
                                               password_hash=md5(password))
         if populate_loved:
             self.__populate_loved_tracks()
     except Exception as e:
         debug("Lastfm::__connect(): %s" % e)
         self.__is_auth = False
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:28,代码来源:lastfm.py


示例7: set_prop

def set_prop (word, word_eol, userdata):
    if len(word) < 3:
        print("Wrong syntax.")
        print(cmd_help["set"])
        return
    
    if word[1] == "username":
        username = word[2]
        hexchat.set_pluginpref("lfm_username", username)
    elif word[1] == "password":
        password = pylast.md5(word[2])
        hexchat.set_pluginpref("lfm_password", password)
    elif word[1] == "api_key":
        api_key = word[2]
        hexchat.set_pluginpref("lfm_api_key", api_key)
    elif word[1] == "api_sec":
        api_sec = word[2]
        hexchat.set_pluginpref("lfm_api_sec", api_sec)
    else:
        print("List of available parameters:")
        print("username"); print("password")
        print("api_key"); print("api_sec")
        return
    
    update_network()
    print("{} updated successfully.".format(word[1]))
    
    return hexchat.EAT_ALL
开发者ID:Dhs92,项目名称:hexchat-addons,代码行数:28,代码来源:lastfm.py


示例8: similar_search

def similar_search(artist, song):
  '''USAGE : similar_search('rihanna', 'umbrella')
  OUTPUT is a LIST passed to thread-pool manager
  which will decide the rate of download, assign download_music threads etc'''
  # You have to have your own unique two values for API_KEY and API_SECRET
  # Obtain yours from http://www.last.fm/api/account for Last.fm
  API_KEY = "e3d64479d574074eac7058d08de0dda7" # this is a sample key
  API_SECRET = "063d322566d3a8bcbd48ac160aa5097a"

  # In order to perform a write operation you need to authenticate yourself
  username = "mayuroks"
  password_hash = pylast.md5("hydrofuran")

  network = pylast.LastFMNetwork(api_key = API_KEY, api_secret = API_SECRET, username = username, password_hash = password_hash)

  ######### define a track ######
  #track = network.get_track("rihanna", "umbrella")
  track = network.get_track(artist, song)

  print(track.get_name)

  ########### MY CODE ###########
  my_list = track.get_similar()
  song_list = [(my_list[i][1], str(my_list[i][0])) for i in range(len(my_list))]
  song_list = sorted(song_list, reverse=True)
  #print(song_list[:10][8][1])
  print(song_list[:10])
  result = []
  [result.append(i[1]) for i in song_list]
  print('RESULT SNAP : ', result[:20])
  return result
开发者ID:mayuroks,项目名称:practice-python,代码行数:31,代码来源:sim.py


示例9: __init__

 def __init__(self, key, shared_secret, username, password):
     self.album_art = ''
     password_hash = pylast.md5(password)
     self.network = pylast.LastFMNetwork(api_key=key,
                                         api_secret=shared_secret,
                                         username=username,
                                         password_hash=password_hash)
开发者ID:dnappier,项目名称:SonosExperience,代码行数:7,代码来源:albummanager.py


示例10: lastfm

def lastfm(inp, reply=None, say=None, nick=''):
   API_KEY = "30cabd8b57c765a42f78e8f5d329fdc0"
   API_SECRET = "0ab2d0a46763e71d1ed8877b4ea209cf"
   username = "elgruntox"
   password_hash = pylast.md5("justpurple")
   network = pylast.get_lastfm_network(api_key = API_KEY, api_secret = API_SECRET, username = username, password_hash = password_hash)
   try:   
      if inp == '':
         user = network.get_user(nick)
      else: 
         user = network.get_user(inp)
         nick = inp
   except WSError:
      say("This user doesn't exist.")
   try:
      tracks = user.get_recent_tracks()
   except pylast.WSError:
       if inp == '':
          return("It seems like your current nickname does not have a lastFM account. Try '.lastfm username' instead.")  
       else: 
          return("The user '%s' does not exist. Maybe you misspelled it?" % inp)
   recent = tracks[0][0]
   artist = recent.get_artist().get_name()
   title = recent.get_title()
   url = recent.get_url()
   bitlyURL = bitly_api.shorten(url) 

   finalise = "\x02%s\x0F's last track - \x02%s\x0f :: Artist - \x02%s\x0f :: Link to Song - \x02%s\x0F" % (nick, title, artist, bitlyURL)
   say(finalise)
开发者ID:limnick,项目名称:siri,代码行数:29,代码来源:lastfm.py


示例11: main

def main():
  import os, os.path
  basedir = os.getcwd()

  # Collect metalmittwoch data so far
  print "Collecting local data..."
  datadir = os.path.join(basedir, 'metalmittwoch')
  data = collect_data(datadir)

  # Read last.fm config
  print "Reading last.fm config..."
  configfile = os.path.join(basedir, 'etc', 'last.fm')
  config = get_config(configfile)

  # Generate playlists from local data
  print "Generating local playlists..."
  local_lists = generate_playlists(data)

  # Ok, connect to last.fm
  print "Connecting to last.fm..."
  import pylast
  network  = pylast.LastFMNetwork(api_key = config['api_key'],
      api_secret = config['api_secret'],
      username = config['username'],
      password_hash = pylast.md5(config['password']))

  user = network.get_user(config['username'])

  # Export playlists to last.fm
  print "Exporting playlists..."
  export_playlists(network, user, local_lists)
开发者ID:jfinkhaeuser,项目名称:metalmittwoch,代码行数:31,代码来源:lastfm.py


示例12: authenticate

	def authenticate(self):
		'''
		authenticate using this linkedopendata account
		'''
		username = "linkedopendata"
		md5_pwd = pylast.md5("nopassword")
		self.session_key = pylast.SessionKeyGenerator(API_KEY, API_SECRET).get_session_key(username, md5_pwd)
开发者ID:apassant,项目名称:motools,代码行数:7,代码来源:artistlookup.py


示例13: initNetwork

    def initNetwork():
        BDD.network_is_connected = threading.Event()
        BDD.network_cache = []
        try:
            f = open(os.path.join(xdg.get_data_home(), "network_cache.txt"), "r")
            queue = f.readlines()
            f.close()
            for e in queue:
                BDD.network_cache.append(eval(e))
        except IOError:
            logger.debug("No network cache file")
        try:
            API_KEY = "04537e40b5501f85610cf4e4bbf1d97a"  # this is a sample key
            API_SECRET = "b36376228a6e72314ffd503b8e3c9f5e"

            # In order to perform a write operation you need to authenticate yourself
            username = settings.get_option("music/audioscrobbler_login", "")
            password_hash = md5(settings.get_option("music/audioscrobbler_password", ""))

            BDD.network = LastFMNetwork(
                api_key=API_KEY, api_secret=API_SECRET, username=username, password_hash=password_hash
            )
            logger.debug("Connection successfuly established with Last.fm")
            BDD.network_is_connected.set()
        except NetworkError:
            logger.debug("Connection to Last.fm failed")
开发者ID:yoann01,项目名称:bullseye,代码行数:26,代码来源:bdd.py


示例14: lastfm_login

	def lastfm_login(self):
		if self.lastfm_loggedin:
			self.lastfm_loggedin = False
			self.lastfm_username.setStyleSheet("background:#F0F0F0")
			self.lastfm_password.setStyleSheet("background:#F0F0F0")
			self.lastfm_loginbutton.setText("Login to Last.fm")
			return
		password_hash = pylast.md5(self.lastfm_password.text())
		try:
			self.lastfm_loginbutton.setText("Logging in...")
			self.network = pylast.LastFMNetwork(api_key="1a8078aea8442f92c98755e29e24f4cf",api_secret="cdf440e7b9ebef25087253b8ee64d604",username=self.lastfm_username.text(),password_hash=password_hash)
			self.lastfm_username.setStyleSheet("background:#28a828")
			self.lastfm_password.setStyleSheet("background:#28a828")
			self.lastfm_loginbutton.setText("Logout")
			print("Login to Last.fm successful!")
			self.lastfm_loggedin = True
		except pylast.WSError:
			print("Authentication failed: wrong login")
			errorbox = QMessageBox(self)
			errorbox.setWindowTitle("Authentication failed")
			errorbox.setText(u"Login failed! You have entered incorrect user details.")
			errorbox.show()
		except:
			print("Authentication failed: unknown error")
			errorbox = QMessageBox(self)
			errorbox.setWindowTitle("Authentication failed")
			errorbox.setText(u"Login failed! An unknown error occurred.")
			errorbox.show()
		return
开发者ID:jimdrie,项目名称:qtmarietje,代码行数:29,代码来源:qtmarietje.py


示例15: __init__

 def __init__(self):
   Entity.__init__(self)
   self.lastfm = pylast.LastFMNetwork(api_key=params.LASTFM_API_KEY,
                   api_secret=params.LASTFM_API_SECRET,
                   username=USERNAME,
                   password_hash=pylast.md5(PASSWORD))
   config.ECHO_NEST_API_KEY = params.ECHONEST_API_KEY
开发者ID:Sushant,项目名称:quest,代码行数:7,代码来源:Artist.py


示例16: test

        def test():
            kind_ = unicode(kind.currentText())
            username_ = unicode(username.text())
            password_ = unicode(password.text())
            pass_hash = pylast.md5(password_)
            proxyhost_ = unicode(proxyhost.text())
            proxyport_ = unicode(proxyport.text())

            def update(msg_, color):
                msg.setText(msg_)
                palette.setColor(msg.backgroundRole(), color)
                msg.setPalette(palette)

            if username_ != u"" and password_ != u"":

                def __connect():
                    try:
                        Main.__net = getattr(pylast, Main.__opt[kind_])(
                            api_key=Main.__key, api_secret=Main.__sec, username=username_, password_hash=pass_hash
                        )
                        if proxyhost_ and proxyport_:
                            Main.__net.enable_proxy(proxyhost_, proxyport_)
                        update(QtGui.QApplication.translate("Last.FM", "Successful"), Qt.green)
                    except (pylast.NetworkError, pylast.WSError) as msg_:
                        update(unicode(msg_).split(u".")[0], Qt.red)

                Thread(target=__connect).start()
            else:
                update(QtGui.QApplication.translate("Last.FM", "Username and/or password is empty"), Qt.yellow)
开发者ID:KenjiTakahashi,项目名称:gayeogi,代码行数:29,代码来源:lastfm.py


示例17: _connect

 def _connect(self, username, password, populate_loved=False):
     """
         Connect lastfm
         @param username as str
         @param password as str
         @thread safe
     """
     self._username = username
     if self._goa is not None or (password != '' and username != ''):
         self._is_auth = True
     else:
         self._is_auth = False
     try:
         self._check_for_proxy()
         if self._goa is None:
             LastFMNetwork.__init__(
                 self,
                 api_key=self._API_KEY,
                 api_secret=self._API_SECRET,
                 username=self._username,
                 password_hash=md5(password))
         else:
             LastFMNetwork.__init__(
                 self,
                 api_key=self._API_KEY,
                 api_secret=self._API_SECRET,
                 session_key=self._goa.call_get_access_token_sync(None)[0])
         if populate_loved:
             self._populate_loved_tracks()
     except Exception as e:
         print("Lastfm::_connect(): %s" % e)
开发者ID:ferranroig,项目名称:lollypop,代码行数:31,代码来源:lastfm.py


示例18: _connect

 def _connect(self, username, password, populate_loved=False):
     """
         Connect lastfm
         @param username as str
         @param password as str
         @thread safe
     """
     self._username = username
     if password != "" and username != "":
         self._is_auth = True
     else:
         self._is_auth = False
     try:
         self._check_for_proxy()
         LastFMNetwork.__init__(
             self,
             api_key=self._API_KEY,
             api_secret=self._API_SECRET,
             username=Lp.settings.get_value("lastfm-login").get_string(),
             password_hash=md5(password),
         )
         if populate_loved:
             self._populate_loved_tracks()
     except Exception as e:
         print("Lastfm::_connect(): %s" % e)
开发者ID:kenden,项目名称:lollypop,代码行数:25,代码来源:lastfm.py


示例19: getLastFMScrobbleObject

def getLastFMScrobbleObject():
	(API_KEY, API_SECRET, username, password) = get_config("config.ini")
	password_hash = pylast.md5(password)

	network = pylast.LastFMNetwork(api_key = API_KEY, api_secret = 
	        API_SECRET, username = username, password_hash = password_hash)

	return network
开发者ID:fengchj,项目名称:xiami-for-mac-lastfm-scrobbler,代码行数:8,代码来源:lastfm-scrobler.py


示例20: __init__

	def __init__(self, username, password, use):
		if use:
			if len(password) is 0:
				password = getpass("Last.fm password:")
			import pylast
			password_hash = pylast.md5(password)
			self.session = pylast.LastFMNetwork(api_key = self.API_KEY, api_secret = self.API_SECRET, username = username, password_hash = password_hash)
		self.enabled = use
开发者ID:vulcanfk,项目名称:PlayMusicCL,代码行数:8,代码来源:PlayMusicCL.py



注:本文中的pylast.md5函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pylatex.Document类代码示例发布时间:2022-05-25
下一篇:
Python pylast.get_lastfm_network函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap