当前位置: 首页>>代码示例>>Python>>正文


Python spotify.Link类代码示例

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


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

示例1: action_search

 def action_search(self, line):
     if not line:
         if self.results is False:
             print "No search is in progress"
             return False
         elif self.results is None:
             print "Searching is in progress"
         else:
             print "Artists:"
             for a in self.results.artists():
                 print "    ", Link.from_artist(a), a.name()
             print "Albums:"
             for a in self.results.albums():
                 print "    ", Link.from_album(a), a.name()
             print "Tracks:"
             for a in self.results.tracks():
                 print "    ", Link.from_track(a, 0), a.name()
             print self.results.total_tracks() - len(self.results.tracks()), "Tracks not shown"
             self.results = False
     else:
         self.results = None
         def _(results, userdata):
             print "\nSearch results received"
             self.results = results
         self.search(line, _)
开发者ID:olekenneth,项目名称:chains,代码行数:25,代码来源:__init__.py

示例2: do_search

	def do_search(self, line):
		if not line:
			if self.results is False:
				print "No search is in progress"
			elif self.results is None:
				print "Searching is in progress"
			else:
				print "Artists:"
				for a in self.results.artists():
					print "	", Link.from_artist(a), a.name()
				print "Albums:"
				for a in self.results.albums():
					print "	", Link.from_album(a), a.name()
				print "Tracks:"
				for a in self.results.tracks():
					print "	", Link.from_track(a, 0), a.name()
				print self.results.total_tracks() - \
						len(self.results.tracks()), "Tracks not shown"
		else:
			line = line.decode('utf-8')
			self.results = None
			def search_finished(results, userdata):
				print "\nSearch results received"
				self.results = results
				self.print_search_results()
			self.jukebox.search(line, search_finished)
开发者ID:bertspaan,项目名称:wekkie,代码行数:26,代码来源:wekkie_player.py

示例3: add_track_results

    def add_track_results(self):
        print "Tracks:"
        tracklist=self.results.tracks()
        print "    ", str(Link.from_track(tracklist[0], 0))[14:], tracklist[0].name()	
	f.write(str(Link.from_track(tracklist[0], 0))[14:]+',')	
	trackList.append(tracklist[0])
	print len(trackList)
开发者ID:sbondada,项目名称:Spoddit,代码行数:7,代码来源:spoddit.py

示例4: print_search_results

	def print_search_results(self):
		print "Artists:"
		for a in self.results.artists():
			print "	", Link.from_artist(a), a.name()
		print "Albums:"
		for a in self.results.albums():
			print "	", Link.from_album(a), a.name()
		print "Tracks:"
		for a in self.results.tracks():
			print "	", Link.from_track(a, 0), a.name()
		print self.results.total_tracks() - len(self.results.tracks()), \
			"Tracks not shown"
开发者ID:bertspaan,项目名称:wekkie,代码行数:12,代码来源:wekkie_player.py

示例5: _to_mopidy_track

 def _to_mopidy_track(self, spotify_track):
     return Track(
         uri=str(Link.from_track(spotify_track, 0)),
         title=spotify_track.name().decode(ENCODING),
         artists=[self._to_mopidy_artist(a)
             for a in spotify_track.artists()],
         album=self._to_mopidy_album(spotify_track.album()),
         track_no=spotify_track.index(),
         date=dt.date(spotify_track.album().year(), 1, 1),
         length=spotify_track.duration(),
         id=self._to_mopidy_id(str(Link.from_track(spotify_track, 0))),
     )
开发者ID:mortenberg80,项目名称:mopidy,代码行数:12,代码来源:libspotify.py

示例6: to_mopidy_playlist

 def to_mopidy_playlist(cls, spotify_playlist):
     if not spotify_playlist.is_loaded():
         return Playlist(name=u'[loading...]')
     if spotify_playlist.type() != 'playlist':
         return
     try:
         return Playlist(
             uri=str(Link.from_playlist(spotify_playlist)),
             name=spotify_playlist.name(),
             # FIXME if check on link is a hackish workaround for is_local
             tracks=[cls.to_mopidy_track(t) for t in spotify_playlist
                 if str(Link.from_track(t, 0))],
         )
     except SpotifyError, e:
         logger.warning(u'Failed translating Spotify playlist: %s', e)
开发者ID:WoLpH,项目名称:mopidy,代码行数:15,代码来源:translator.py

示例7: run

	def run(self):
		container_loaded.wait()
		container_loaded.clear()

		link = Link.from_string(sys.argv[3])
		if link.type() == Link.LINK_TRACK:
			track = link.as_track()
			itrack = iter([track])
		elif link.type() == Link.LINK_PLAYLIST:
			playlist = link.as_playlist()
			print('loading playlist...')
			while not playlist.is_loaded():
				time.sleep(0.1)
			print('done')
			itrack = iter(playlist)

		session = self.ripper.session
		for track in itrack:

			self.ripper.load_track(track)

			rip_init(session, track)

			self.ripper.play()

			end_of_track.wait()
			end_of_track.clear()

			rip_terminate(session, track)
			rip_id3(session, track)

		self.ripper.disconnect()
开发者ID:jrevillas,项目名称:spotify-mp3-ripper,代码行数:32,代码来源:sputrifis.py

示例8: _lookup_album

 def _lookup_album(self, uri):
     album = Link.from_string(uri).as_album()
     album_browser = self.backend.spotify.session.browse_album(album)
     self._wait_for_object_to_load(album_browser)
     return [
         SpotifyTrack(track=t)
         for t in album_browser if t.availability() == TRACK_AVAILABLE]
开发者ID:cave-scorpion,项目名称:mopidy,代码行数:7,代码来源:library.py

示例9: to_mopidy_artist

 def to_mopidy_artist(cls, spotify_artist):
     if not spotify_artist.is_loaded():
         return Artist(name=u'[loading...]')
     return Artist(
         uri=str(Link.from_artist(spotify_artist)),
         name=spotify_artist.name()
     )
开发者ID:Amli,项目名称:mopidy,代码行数:7,代码来源:translator.py

示例10: do_play

 def do_play(self, line):
     if not line:
         self.jukebox.play()
         return
     try:
         if line.startswith("spotify:"):
             # spotify url
             l = Link.from_string(line)
             if not l.type() == Link.LINK_TRACK:
                 print "You can only play tracks!"
                 return
             self.jukebox.load_track(l.as_track())
         else:
             try:
                 playlist, track = map(int, line.split(' ', 1))
                 self.jukebox.load(playlist, track)
             except ValueError:
                 try:
                     playlist = int(line)
                     self.jukebox.load_playlist(playlist)
                 except ValueError:
                     print("Usage: play [track_link] | "
                           "[playlist] [track] | [playlist]")
                     return
     except SpotifyError as e:
         print "Unable to load track:", e
         return
     self.jukebox.play()
开发者ID:adamcik,项目名称:pyspotify,代码行数:28,代码来源:jukebox.py

示例11: _lookup_track

 def _lookup_track(self, uri):
     track = Link.from_string(uri).as_track()
     utils.wait_for_object_to_load(track, self._timeout)
     if track.is_loaded():
         return [SpotifyTrack(track=track)]
     else:
         return [SpotifyTrack(uri=uri)]
开发者ID:TheDirectwave,项目名称:mopidy-spotify,代码行数:7,代码来源:library.py

示例12: load

 def load(self, tid):
     log.msg("load %r" % tid, system="squeal.spot.service.SpotifyManager")
     if self.playing:
         self.session.play(0)
     link = Link.from_string(tid)
     track = link.as_track()
     self.session.load(track)
开发者ID:bne,项目名称:squeal,代码行数:7,代码来源:manager.py

示例13: add_artist_link

    def add_artist_link(self, artist, source):
        """
        Add an artist link to the queue.
        """
        link = str(Link.from_artist(artist))

        if not self._items:
            self._items = [ ]

            with open('queue.json', 'r') as fp:
                self._items = json.load(fp)

        found = False

        for item in self._items:
            if item['link'] == link:
                found = True
                break

        if not found:
            while not artist.is_loaded():
                time.sleep(0.1)

            print 'Adding %s' % artist.name()

            self._items.append({
                    'name':   artist.name(),
                    'link':   link,
                    'source': source,
                    })

            with open('queue.json', 'w') as fp:
                json.dump(self._items, fp, indent=2)

        return True
开发者ID:poelzi,项目名称:spotify-ripper,代码行数:35,代码来源:json_queue.py

示例14: change_track

    def change_track(self, track_link):
        for index, item in enumerate(self.play_queue):
            if str(Link.from_track(item.track)) == track_link:
                self.current_track_index = index
                return True

        return False
开发者ID:johngunnarsson,项目名称:spotifythings,代码行数:7,代码来源:playqueue.py

示例15: to_mopidy_artist

def to_mopidy_artist(spotify_artist):
    if spotify_artist is None:
        return
    uri = str(Link.from_artist(spotify_artist))
    if not spotify_artist.is_loaded():
        return Artist(uri=uri, name='[loading...]')
    return Artist(uri=uri, name=spotify_artist.name())
开发者ID:AndreaCrotti,项目名称:mopidy,代码行数:7,代码来源:translator.py


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