本文整理汇总了Python中server.Server.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Server.connect方法的具体用法?Python Server.connect怎么用?Python Server.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server.Server
的用法示例。
在下文中一共展示了Server.connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProcessRequest
# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import connect [as 别名]
def ProcessRequest(title, params, offset = 0, id = -1, type = "default"):
sc = Server(hostname=Prefs['lms_server_address'], port=Prefs['lms_server_cli_port'], username="", password="")
sc.connect()
player = sc.get_player(title);
oc = ObjectContainer(title2 = player.get_name())
for item in player.playlist_get_info():
track_title = player.request("songinfo 1 1 track_id:"+str(item['id']))[8:]
track_url = player.request("songinfo 2 1 track_id:"+str(item['id'])+" tags:u")[21:]
oc.add(DirectoryObject(key = track_url,
title = track_title,
duration = int(item['duration'])
)
)
return oc
示例2: MainMenu
# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import connect [as 别名]
def MainMenu():
sc = Server(hostname=Prefs['lms_server_address'], port=Prefs['lms_server_cli_port'], username="", password="")
sc.connect()
oc = ObjectContainer()
for player in sc.get_players():
player_id = str(player.get_ref())
current_time = str(time.time())
oc.add(DirectoryObject(key = Callback(ProcessRequest, title = player_id, params = {'order': 'hotness'}),
title = player.get_name(),
tagline=player.get_track_artist(),
summary=player.get_track_current_title(),
duration=player.get_track_duration(),
thumb = Resource.ContentsOfURLWithFallback("http://"+Prefs['lms_server_address']+":"+Prefs['lms_server_port']+"/music/current/cover.jpg?player="+player_id+"&time="+current_time)
)
)
return oc