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


Python Webclient.get_stream_url方法代码示例

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


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

示例1: GMusic

# 需要导入模块: from gmusicapi import Webclient [as 别名]
# 或者: from gmusicapi.Webclient import get_stream_url [as 别名]
class GMusic(object):
    def __init__(self):
        self.webclient = Webclient(debug_logging=False)
        self.email = None
        self.password = None
        self.authenticated = False
        self.all_songs = list()
        self.playlists = list()

    def authenticate(self, email=None, password=None):
        if email:
            self.email = email
        if password:
            self.password = password

        try:
            Log("AUTHENTICATING!!!!111")
            self.authenticated = self.webclient.login(self.email, self.password)
        except AlreadyLoggedIn:
            self.authenticated = True


        return self.authenticated

    def get_all_songs(self):
        try:
            self.all_songs = self.webclient.get_all_songs()
        except NotLoggedIn:
            if self.authenticate():
                self.all_songs = self.webclient.get_all_songs()
            else:
                Log("LOGIN FAILURE")
                return

        return self.all_songs

    def get_all_playlists(self):
        try:
            self.playlists = self.webclient.get_all_playlist_ids()
        except NotLoggedIn:
            if self.authenticate():
                self.playlists = self.webclient.get_all_playlist_ids()
            else:
                Log("LOGIN FAILURE")
                return

        return self.playlists

    def get_stream_url(self, song_id):
        try:
            stream_url = self.webclient.get_stream_url(song_id)
        except NotLoggedIn:
            if self.authenticate():
                stream_url = self.webclient.get_stream_url(song_id)
            else:
                Log("LOGIN FAILURE")
                return

        return stream_url
开发者ID:ceekee,项目名称:GoogleMusic.bundle,代码行数:61,代码来源:__init__.py

示例2: download_song

# 需要导入模块: from gmusicapi import Webclient [as 别名]
# 或者: from gmusicapi.Webclient import get_stream_url [as 别名]
def download_song():
	print "Request : Download url"
	mm = Webclient()
	token = request.form['token']
	songid = request.form['songid']
	mm.setToken(token)
	songs = mm.get_all_songs(incremental=False)
	url = mm.get_stream_url(songid)
	return url
开发者ID:scleriot,项目名称:syncgmusic,代码行数:11,代码来源:server.py

示例3: main

# 需要导入模块: from gmusicapi import Webclient [as 别名]
# 或者: from gmusicapi.Webclient import get_stream_url [as 别名]
def main():
  api = Webclient()
  login(api)
  playlists = api.get_all_playlist_ids().pop('user')
  indexed_playlist_names = index_playlists(playlists)
  curlist = choose_playlist(api, indexed_playlist_names, playlists)[0]
  songs = api.get_playlist_songs(curlist)
  print songs

  curpos = 0;
  cursongid = songs[curpos]['id']
  cursongurl = api.get_stream_url(cursongid)
  print cursongurl
  #cursong = play(cursongurl)

  while 1:
    if cursong.poll() is not None:
      curpos += 1
      cursongid = songs[curpos]['id']
      cursong = play(get_stream_url(cursongid))
    c = getch() 
    if (c == 'q'):
      api.logout() 
      break
开发者ID:skrblr,项目名称:gmusicbar,代码行数:26,代码来源:gmusicbar.py


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