本文整理汇总了Python中spotify.Link类的典型用法代码示例。如果您正苦于以下问题:Python Link类的具体用法?Python Link怎么用?Python Link使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Link类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: track_playback_started
def track_playback_started(self, track):
try:
if track.name == u'[loading...]':
spotify_track = Link.from_string(track.uri).as_track()
# TODO Block until metadata_updated callback is called. Before that
# the track will be unloaded, unless it's already in the stored
# playlists.
if not spotify_track.is_loaded():
logger.debug(u'Looking up "%s" from metadata API', track.uri)
spotify_track = utils.lookup_spotify_track(track.uri)
track = Track(
uri=track.uri,
name=spotify_track["track"]["name"],
artists=[Artist(name=artist["name"], uri=artist["href"]) for artist in spotify_track["track"]["artists"]],
album=Album(name=spotify_track["track"]["album"]["name"], uri=spotify_track["track"]["album"]["href"]),
track_no=spotify_track["track"]["track-number"],
length=spotify_track["track"]["length"],
bitrate=settings.SPOTIFY_BITRATE,
)
else:
track = SpotifyTranslator.to_mopidy_track(spotify_track)
# Tweet #Nowplaying ... / ... requested by @...
artists = ', '.join([a.name for a in track.artists])
uri = track.uri
screen_name = self.requests.pop(uri)
# Send tweet!
tweet = u'#Nowplaying %s / %s, requested by @%s %s' % (artists, track.name, screen_name, utils.spotify_uri_to_url(uri))
self.api.update_status(status=tweet, lat="50.82519295639108", long="-0.14594435691833496", display_coordinates="1")
logger.info(u'Tweeted: %s' % tweet)
except SpotifyError, e:
logger.debug(u'Failed to lookup "%s": %s', track.uri, e)
开发者ID:swinton,项目名称:mopidyextra,代码行数:34,代码来源:base.py
示例17: play
def play(self, track):
if track.uri is None:
return False
spotify_backend = self.backend.actor_ref.proxy()
need_data_callback_bound = functools.partial(
need_data_callback, spotify_backend)
enough_data_callback_bound = functools.partial(
enough_data_callback, spotify_backend)
seek_data_callback_bound = functools.partial(
seek_data_callback, spotify_backend)
self._first_seek = True
try:
spotify_track = Link.from_string(track.uri).as_track()
utils.wait_for_object_to_load(spotify_track, self._timeout)
self.backend.spotify.session.load(spotify_track)
self.backend.spotify.session.play(1)
self.backend.spotify.buffer_timestamp = 0
self.audio.prepare_change()
self.audio.set_appsrc(
self._caps,
need_data=need_data_callback_bound,
enough_data=enough_data_callback_bound,
seek_data=seek_data_callback_bound)
self.audio.start_playback()
self.audio.set_metadata(track)
return True
except SpotifyError as e:
logger.info('Playback of %s failed: %s', track.uri, e)
return False
开发者ID:bh,项目名称:mopidy-spotify,代码行数:34,代码来源:playback.py
示例18: search_finished
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,代码行数:8,代码来源:pyspotify-web.py
示例19: do_quit
def do_quit(self, line):
link = Link.from_string("spotify:track:5sCCUyrCF2u9LerPMUsmlY")
track = link.as_track()
while(track.is_loaded() != 1):
pass
self.jukebox.load_track(track)
self.jukebox.play()
开发者ID:BigNetwork,项目名称:spotify-daemon,代码行数:8,代码来源:userinterface.py
示例20: to_mopidy_playlist
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,代码行数:17,代码来源:translator.py
注:本文中的spotify.Link类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论