本文整理汇总了Python中api.NetEase.get_version方法的典型用法代码示例。如果您正苦于以下问题:Python NetEase.get_version方法的具体用法?Python NetEase.get_version怎么用?Python NetEase.get_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.NetEase
的用法示例。
在下文中一共展示了NetEase.get_version方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from api import NetEase [as 别名]
# 或者: from api.NetEase import get_version [as 别名]
class Menu:
def __init__(self):
reload(sys)
sys.setdefaultencoding("UTF-8")
self.config = Config()
self.datatype = "main"
self.title = "网易云音乐"
self.datalist = ["排行榜", "艺术家", "新碟上架", "精选歌单", "我的歌单", "DJ节目", "每日推荐", "私人FM", "搜索", "帮助"]
self.offset = 0
self.index = 0
self.storage = Storage()
self.storage.load()
self.collection = self.storage.database["collections"][0]
self.player = Player()
self.player.playing_song_changed_callback = self.song_changed_callback
self.cache = Cache()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.step = 10
self.stack = []
self.djstack = []
self.userid = self.storage.database["user"]["user_id"]
self.username = self.storage.database["user"]["nickname"]
self.resume_play = True
self.at_playing_list = False
signal.signal(signal.SIGWINCH, self.change_term)
signal.signal(signal.SIGINT, self.send_kill)
self.START = time.time()
def change_term(self, signum, frame):
self.ui.screen.clear()
self.ui.screen.refresh()
def send_kill(self, signum, fram):
self.player.stop()
self.cache.quit()
self.storage.save()
curses.endwin()
sys.exit()
def alert(self, version):
latest = Menu().check_version()
if latest != version:
if platform.system() == "Darwin":
os.system(
'/usr/bin/osascript -e \'display notification "MusicBox Update is available"sound name "/System/Library/Sounds/Ping.aiff"\''
)
time.sleep(0.5)
os.system(
"/usr/bin/osascript -e 'display notification \"NetEase-MusicBox installed version:"
+ version
+ "\nNetEase-MusicBox latest version:"
+ latest
+ "\"'"
)
else:
os.system('/usr/bin/notify-send "MusicBox Update is available"')
def check_version(self):
# 检查更新
tree = ET.ElementTree(ET.fromstring(str(self.netease.get_version())))
root = tree.getroot()
return root[0][4][0][0].text
def start_fork(self, version):
# Hong, Fork a child process.
# Return 0 in the child and the child’s process id in the parent.
pid = os.fork()
if pid == 0:
Menu().alert(version)
else:
Menu().start()
def play_pause(self):
if len(self.storage.database["player_info"]["player_list"]) == 0:
return
if self.player.pause_flag:
self.player.resume()
else:
self.player.pause()
time.sleep(0.1)
def next_song(self):
if len(self.storage.database["player_info"]["player_list"]) == 0:
return
self.player.next()
time.sleep(0.1)
def previous_song(self):
if len(self.storage.database["player_info"]["player_list"]) == 0:
return
self.player.prev()
time.sleep(0.1)
def start(self):
# Hong, Return the time in seconds since the epoch as a floating point number.
self.START = time.time() // 1
self.ui.build_menu(self.datatype, self.title, self.datalist, self.offset, self.index, self.step, self.START)
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from api import NetEase [as 别名]
# 或者: from api.NetEase import get_version [as 别名]
class Menu:
def __init__(self):
reload(sys)
sys.setdefaultencoding('UTF-8')
self.config = Config()
self.datatype = 'main'
self.title = '网易云音乐'
self.datalist = ['排行榜', '艺术家', '新碟上架', '精选歌单', '我的歌单', 'DJ节目', '每日推荐', '私人FM', '搜索', '帮助']
self.offset = 0
self.index = 0
self.storage = Storage()
self.storage.load()
self.collection = self.storage.database['collections'][0]
self.player = Player()
self.player.playing_song_changed_callback = self.song_changed_callback
self.cache = Cache()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.step = 10
self.stack = []
self.djstack = []
self.userid = self.storage.database["user"]["user_id"]
self.username = self.storage.database["user"]["nickname"]
self.resume_play = True
self.at_playing_list = False
signal.signal(signal.SIGWINCH, self.change_term)
signal.signal(signal.SIGINT, self.send_kill)
self.START = time.time()
def change_term(self, signum, frame):
self.ui.screen.clear()
self.ui.screen.refresh()
def send_kill(self, signum, fram):
self.player.stop()
self.cache.quit()
self.storage.save()
curses.endwin()
sys.exit()
def update_alert(self, version):
latest = Menu().check_version()
if latest != version and latest != 0:
if platform.system() == 'Darwin':
os.system('/usr/bin/osascript -e \'display notification "MusicBox Update is available"sound name "/System/Library/Sounds/Ping.aiff"\'')
time.sleep(0.5)
os.system('/usr/bin/osascript -e \'display notification "NetEase-MusicBox installed version:' + version + '\nNetEase-MusicBox latest version:' + latest + '"\'')
else:
os.system('/usr/bin/notify-send "MusicBox Update is available"')
def signin_alert(self, type):
if type == 0:
if platform.system() == 'Darwin':
os.system('/usr/bin/osascript -e \'display notification "Mobile signin success"sound name "/System/Library/Sounds/Ping.aiff"\'')
else:
os.system('/usr/bin/notify-send "Mobile signin success"')
else:
if platform.system() == 'Darwin':
os.system('/usr/bin/osascript -e \'display notification "PC signin success"sound name "/System/Library/Sounds/Ping.aiff"\'')
else:
os.system('/usr/bin/notify-send "PC signin success"')
def check_version(self):
# 检查更新 && 签到
try:
mobilesignin = self.netease.daily_signin(0)
if mobilesignin != -1 and mobilesignin['code'] != -2:
self.signin_alert(0)
time.sleep(0.5)
pcsignin = self.netease.daily_signin(1)
if pcsignin != -1 and pcsignin['code'] != -2:
self.signin_alert(1)
tree = ET.ElementTree(ET.fromstring(str(self.netease.get_version())))
root = tree.getroot()
return root[0][4][0][0].text
except:
return 0
def start_fork(self, version):
pid = os.fork()
if pid == 0:
Menu().update_alert(version)
else:
Menu().start()
def play_pause(self):
if len(self.storage.database["player_info"]["player_list"]) == 0:
return
if self.player.pause_flag:
self.player.resume()
else:
self.player.pause()
time.sleep(0.1)
def next_song(self):
if len(self.storage.database["player_info"]["player_list"]) == 0:
return
self.player.next()
#.........这里部分代码省略.........
示例3: Menu
# 需要导入模块: from api import NetEase [as 别名]
# 或者: from api.NetEase import get_version [as 别名]
class Menu(object):
def __init__(self):
reload(sys)
sys.setdefaultencoding('UTF-8')
self.config = Config()
self.datatype = 'main'
self.title = 'NetEase Music'
self.datalist = ['Charts', 'Artists', 'New Songs', 'Songs', 'My Songs', 'Radio Stations', 'Recommended',
'Personal Radio', 'Search', 'Help']
self.offset = 0
self.index = 0
self.storage = Storage()
self.storage.load()
self.collection = self.storage.database['collections'][0]
self.player = Player()
self.player.playing_song_changed_callback = self.song_changed_callback
self.cache = Cache()
self.ui = Ui()
self.netease = NetEase()
self.screen = curses.initscr()
self.screen.keypad(1)
self.step = 10
self.stack = []
self.djstack = []
self.userid = self.storage.database['user']['user_id']
self.username = self.storage.database['user']['nickname']
self.resume_play = True
self.at_playing_list = False
signal.signal(signal.SIGWINCH, self.change_term)
signal.signal(signal.SIGINT, self.send_kill)
self.START = time.time()
def change_term(self, signum, frame):
self.ui.screen.clear()
self.ui.screen.refresh()
def send_kill(self, signum, fram):
self.player.stop()
self.cache.quit()
self.storage.save()
curses.endwin()
sys.exit()
def update_alert(self, version):
latest = Menu().check_version()
if latest != version and latest != 0:
notify('MusicBox Update is available', 1)
time.sleep(0.5)
notify('NetEase-MusicBox installed version:' + version +
'\nNetEase-MusicBox latest version:' + latest, 0)
def check_version(self):
# 检查更新 && 签到
try:
mobilesignin = self.netease.daily_signin(0)
if mobilesignin != -1 and mobilesignin['code'] != -2:
notify('Mobile signin success', 1)
time.sleep(0.5)
pcsignin = self.netease.daily_signin(1)
if pcsignin != -1 and pcsignin['code'] != -2:
notify('PC signin success', 1)
tree = ET.ElementTree(ET.fromstring(str(self.netease.get_version(
))))
root = tree.getroot()
return root[0][4][0][0].text
except TypeError as e:
log.error(e)
return 0
def start_fork(self, version):
pid = os.fork()
if pid == 0:
Menu().update_alert(version)
else:
Menu().start()
def _is_playlist_empty(self):
return len(self.storage.database['player_info']['player_list']) == 0
def play_pause(self):
if self._is_playlist_empty():
return
if self.player.pause_flag:
self.player.resume()
else:
self.player.pause()
time.sleep(0.1)
def next_song(self):
if self._is_playlist_empty():
return
self.player.next()
time.sleep(0.5)
def previous_song(self):
if self._is_playlist_empty():
return
self.player.prev()
time.sleep(0.5)
#.........这里部分代码省略.........