Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def exit(cls):
ControllerApi.notify_widget.show_message("通知", "退出单曲电台播放模式")
def play_mv_by_mvid(cls, mvid):
mv_model = ControllerApi.api.get_mv_detail(mvid)
if not ControllerApi.api.is_response_ok(mv_model):
return
url_middle = mv_model['url_middle']
clipboard = QApplication.clipboard()
clipboard.setText(url_middle)
cls.view.ui.STATUS_BAR.showMessage(
u"程序已经将视频的播放地址复制到剪切板", 5000)
if platform.system() == "Linux":
ControllerApi.player.pause()
ControllerApi.notify_widget.show_message(
"通知", "正在尝试调用VLC视频播放器播放MV")
try:
subprocess.Popen(['vlc', url_middle, '--play-and-exit', '-f'])
except:
LOG.error('call vlc player failed')
elif platform.system().lower() == 'Darwin'.lower():
ControllerApi.player.pause()
ControllerApi.notify_widget.show_message(
"通知", "准备调用 QuickTime Player 播放mv")
try:
subprocess.Popen(
['open', '-a', 'QuickTime Player', url_middle])
except:
LOG.error('call quicktime player failed')
def delete_playlist(self):
m = QMessageBox(QMessageBox.Warning, '警告', '确认删除歌单么 ?',
QMessageBox.Yes | QMessageBox.No)
if m.exec() != QMessageBox.Yes:
return False
pid = self.data['id']
flag = ControllerApi.api.delete_playlist(pid)
if flag:
ControllerApi.notify_widget.show_message('◕◡◔', '删除歌单成功')
self.close()
self.deleteLater()
return True
else:
ControllerApi.notify_widget.show_message('◕◠◔', '删除歌单失败')
return False
def add_to_playlist(self, pid):
if not ControllerApi.state['current_mid']:
return False
flag = ControllerApi.api.add_song_to_playlist(ControllerApi.state['current_mid'], pid)
if flag:
ControllerApi.notify_widget.show_message('◕◡◔', '加入歌单成功')
else:
ControllerApi.notify_widget.show_message('◕◠◔', '加入歌单失败, 可能早已在列表了哦')
LOG.info('正在查找新版本...')
try:
loop = asyncio.get_event_loop()
future = loop.run_in_executor(
None, partial(requests.get, url, timeout=5))
res = yield from future
if not res.status_code == 200:
LOG.warning('connect to api.github.com timeout')
return
releases = res.json()
for release in releases:
if release['tag_name'] > cls.current_version:
title = u'发现新版本 %s hoho' % release['tag_name']
LOG.info(title)
content = release['name']
ControllerApi.notify_widget.show_message(title, content)
ViewOp.ui.STATUS_BAR.showMessage(title, 5000)
break
except Exception as e:
LOG.error(str(e))
def show_start_tip():
tips_content = list(tips.values())
index = random.randint(0, len(tips_content)-1)
ControllerApi.notify_widget.show_message("Tips", tips_content[index])