Skip to content

Instantly share code, notes, and snippets.

@littlecodersh
Created September 28, 2016 02:12
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save littlecodersh/8468afbbb8d34c0c0e6848b6f9009c4c to your computer and use it in GitHub Desktop.
Save littlecodersh/8468afbbb8d34c0c0e6848b6f9009c4c to your computer and use it in GitHub Desktop.
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
Copy link

Shunder commented Mar 12, 2017

Very Good

@hwade
Copy link

hwade commented Mar 13, 2017

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

@monkey-wenjun
Copy link

无法播放

@willowj
Copy link

willowj commented Aug 31, 2017

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

@solar717
Copy link

无法运行

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