Created
September 28, 2016 02:12
-
-
Save littlecodersh/8468afbbb8d34c0c0e6848b6f9009c4c to your computer and use it in GitHub Desktop.
Demo of controlling music player through wechat.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() |
NetEaseMusicApi os包使用startfile函数打开程序好像在linux下不行,只能在windows下使用该函数
无法播放
api下载到本地的mp3是空的,无法播放
无法运行
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very Good