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


Python Link.from_track方法代码示例

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


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

示例1: add_track_results

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
    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,代码行数:9,代码来源:spoddit.py

示例2: _to_mopidy_track

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
 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,代码行数:14,代码来源:libspotify.py

示例3: action_search

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
 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,代码行数:27,代码来源:__init__.py

示例4: do_search

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
	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,代码行数:28,代码来源:wekkie_player.py

示例5: change_track

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
    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,代码行数:9,代码来源:playqueue.py

示例6: search_finished

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
 def search_finished(results, userdata):
     resultsRendered = []
     for a in results.tracks():
         resultsRendered.append(dict(link=Link.from_track(a, 0), name=a.name()))
     self.results = resultsRendered
     jukeboxCondition.acquire()
     jukeboxCondition.notify()
     jukeboxCondition.release()
开发者ID:jbarciauskas,项目名称:pyspotify-web,代码行数:10,代码来源:pyspotify-web.py

示例7: __init__

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
 def __init__(self, track):
     super(PlayerCurrentTrackMessage, self).__init__(
         type='player.current_track',
         data=dict(
             name = track.name(),
             artists = ", ".join([artist.name() for artist in track.artists()]),
             link = str(Link.from_track(track)),
             duration = track.duration(),
             image_id = binascii.hexlify(track.album().cover())) if track else None)
开发者ID:johngunnarsson,项目名称:spotifythings,代码行数:11,代码来源:wsmessage.py

示例8: print_search_results

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
	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,代码行数:14,代码来源:wekkie_player.py

示例9: to_mopidy_playlist

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
 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,代码行数:17,代码来源:translator.py

示例10: send_tracks

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
	def send_tracks(self):
		"""
		Send tracks that hasn't already been sent.
		"""
		tracks = set(self.loaded_tracks) - set(self.sent_tracks)
		tracks = list(tracks)

		tracks = [(unicode(Link.from_track(t, 0)), str(t.artists()[0]), t.name()) for t in tracks]
		# Rate limit
		tracks = tracks[:50]

		d = { 
			'action': 'add_tracks',
			'tracks': tracks
		}
		self.connection.sendLine(pickle.dumps(d))
		self.sent_tracks += tracks
开发者ID:knutin,项目名称:spotify_quiz,代码行数:19,代码来源:client.py

示例11: to_mopidy_playlist

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
 def to_mopidy_playlist(cls, spotify_playlist):
     if not spotify_playlist.is_loaded():
         return Playlist(name=u'[loading...]')
     # FIXME Replace this try-except with a check on the playlist type,
     # which is currently not supported by pyspotify, to avoid handling
     # playlist folder boundaries like normal playlists.
     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.info(u'Failed translating Spotify playlist '
             '(probably a playlist folder boundary): %s', e)
开发者ID:Amli,项目名称:mopidy,代码行数:19,代码来源:translator.py

示例12: to_mopidy_track

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
 def to_mopidy_track(cls, spotify_track):
     if not spotify_track.is_loaded():
         return Track(name=u'[loading...]')
     uri = str(Link.from_track(spotify_track, 0))
     if dt.MINYEAR <= int(spotify_track.album().year()) <= dt.MAXYEAR:
         date = dt.date(spotify_track.album().year(), 1, 1)
     else:
         date = None
     return Track(
         uri=uri,
         name=spotify_track.name().decode(ENCODING),
         artists=[cls.to_mopidy_artist(a) for a in spotify_track.artists()],
         album=cls.to_mopidy_album(spotify_track.album()),
         track_no=spotify_track.index(),
         date=date,
         length=spotify_track.duration(),
         bitrate=(settings.SPOTIFY_HIGH_BITRATE and 320 or 160),
     )
开发者ID:bok,项目名称:mopidy,代码行数:20,代码来源:translator.py

示例13: get_collection

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
    def get_collection(self):

        ls = []
        for pl in self.ctr:
            if(pl.name() != 'collection'):
                continue
            for song in pl:
                uri = unicode(str(Link.from_track(song)))
                title = unicode(song.name())
                artists = []
                for arts in song.artists():
                    artists.append(arts.name())
                artist = unicode(' & '.join(artists))
                album = unicode(song.album().name())
                duration = int(song.duration() / 1000)
                ls.append(Song(uri, title, artist, album,
                               duration))
        return ls
开发者ID:tak30,项目名称:youkbox,代码行数:20,代码来源:clientSpotify.py

示例14: to_mopidy_track

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
 def to_mopidy_track(cls, spotify_track):
     uri = str(Link.from_track(spotify_track, 0))
     if not spotify_track.is_loaded():
         return Track(uri=uri, name=u'[loading...]')
     spotify_album = spotify_track.album()
     if spotify_album is not None and spotify_album.is_loaded():
         date = spotify_album.year()
     else:
         date = None
     return Track(
         uri=uri,
         name=spotify_track.name(),
         artists=[cls.to_mopidy_artist(a) for a in spotify_track.artists()],
         album=cls.to_mopidy_album(spotify_track.album()),
         track_no=spotify_track.index(),
         date=date,
         length=spotify_track.duration(),
         bitrate=settings.SPOTIFY_BITRATE,
     )
开发者ID:Dvad,项目名称:mopidy,代码行数:21,代码来源:translator.py

示例15: to_mopidy_track

# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_track [as 别名]
 def to_mopidy_track(cls, spotify_track):
     uri = str(Link.from_track(spotify_track, 0))
     if not spotify_track.is_loaded():
         return Track(uri=uri, name=u'[loading...]')
     if (spotify_track.album() is not None and
             dt.MINYEAR <= int(spotify_track.album().year()) <= dt.MAXYEAR):
         date = dt.date(spotify_track.album().year(), 1, 1)
     else:
         date = None
     return Track(
         uri=uri,
         name=spotify_track.name(),
         artists=[cls.to_mopidy_artist(a) for a in spotify_track.artists()],
         album=cls.to_mopidy_album(spotify_track.album()),
         track_no=spotify_track.index(),
         date=date,
         length=spotify_track.duration(),
         bitrate=BITRATES[settings.SPOTIFY_BITRATE],
     )
开发者ID:Amli,项目名称:mopidy,代码行数:21,代码来源:translator.py


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