Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def reset_song_list(cls):
ControllerApi.player.clear_playlist()
if len(cls._songs) > 0:
song = cls._songs.pop()
mid = song['id']
music_model = ControllerApi.api.get_song_detail(mid)
if not ControllerApi.api.is_response_ok(music_model):
ControllerApi.notify_widget.show_message("Error", "网络异常,请检查网络连接")
return
ControllerApi.player.set_music_list([music_model])
else:
cls._songs = cls.get_songs()
if not ControllerApi.api.is_response_ok(cls._songs):
ControllerApi.player.stop()
ControllerApi.notify_widget.show_message("Error", "网络异常,请检查网络连接")
elif cls._songs == []:
ControllerApi.notify_widget.show_message("|--|", "未知错误")
else:
cls.reset_song_list()
def show_lyric_while_visible(self, ms):
"""给controller调用的函数"""
if self.isVisible():
if self.has_lyric():
self.sync_lyric(ms)
else:
lyric_model = ControllerApi.api.get_lyric_detail(ControllerApi.state['current_mid'])
if not ControllerApi.api.is_response_ok(lyric_model):
return
if lyric_model:
self.set_lyric(lyric_model)
self.sync_lyric(ms)
else:
self.setText(u'歌曲没有歌词')
def set_playlists_options(self):
playlists = ControllerApi.api.get_user_playlist()
if not ControllerApi.api.is_response_ok(playlists):
return
self.playlists = playlists
self.menu.clear()
for playlist in playlists:
if ControllerApi.api.is_playlist_mine(playlist):
name = playlist['name']
pid = playlist['id']
action = QAction(name, self)
action.triggered.connect(partial(self.add_to_playlist, pid))
self.menu.addAction(action)
def play_specific_song_by_mid(cls, mid):
song = ControllerApi.api.get_song_detail(mid)
if not ControllerApi.api.is_response_ok(song):
return False
ControllerApi.player.play(song)
return True
def reset_song_list(cls):
ControllerApi.player.clear_playlist()
if len(cls._songs) > 0:
song = cls._songs.pop()
mid = song['id']
music_model = ControllerApi.api.get_song_detail(mid)
if not ControllerApi.api.is_response_ok(music_model):
ControllerApi.notify_widget.show_message("Error", "网络异常,请检查网络连接")
return
ControllerApi.player.set_music_list([music_model])
else:
cls._songs = cls.get_songs()
if not ControllerApi.api.is_response_ok(cls._songs):
ControllerApi.player.stop()
ControllerApi.notify_widget.show_message("Error", "网络异常,请检查网络连接")
elif cls._songs == []:
ControllerApi.notify_widget.show_message("|--|", "未知错误")
else:
cls.reset_song_list()