Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Demo of controlling music player through wechat.
#coding=utf8
import os
import itchat
from NetEaseMusicApi import interact_select_song
# 第三方包通过该命令安装:pip install itchat, NetEaseMusicApi
HELP_MSG = u'''\
欢迎使用微信网易云音乐
帮助: 显示帮助
关闭: 关闭歌曲
歌名: 按照引导播放音乐\
'''
with open('stop.mp3', 'w') as f: pass
def close_music():
os.startfile('stop.mp3')
@itchat.msg_register(itchat.content.TEXT)
def music_player(msg):
if msg['ToUserName'] != 'filehelper': return
if msg['Text'] == u'关闭':
close_music()
itchat.send(u'音乐已关闭', 'filehelper')
if msg['Text'] == u'帮助':
itchat.send(HELP_MSG, 'filehelper')
else:
itchat.send(interact_select_song(msg['Text']), 'filehelper')
itchat.auto_login(True)
itchat.send(HELP_MSG, 'filehelper')
itchat.run()
@Shunder

This comment has been minimized.

Copy link

@Shunder Shunder commented Mar 12, 2017

Very Good

@hwade

This comment has been minimized.

Copy link

@hwade hwade commented Mar 13, 2017

NetEaseMusicApi os包使用startfile函数打开程序好像在linux下不行,只能在windows下使用该函数

@monkey-wenjun

This comment has been minimized.

Copy link

@monkey-wenjun monkey-wenjun commented Jun 10, 2017

无法播放

@willowj

This comment has been minimized.

Copy link

@willowj willowj commented Aug 31, 2017

api下载到本地的mp3是空的,无法播放

@solar717

This comment has been minimized.

Copy link

@solar717 solar717 commented Aug 21, 2018

无法运行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment