A small application on pcDuino install doufan.fm player
First configure pcDuino environment:
#sudo apt-get install python-dev
If you do not have a player, you can download one :
#sudo apt-get install gnome-mplayer
Then run the python code:
#sudo python test.py
Code:
-
#!/usr/bin/python # coding: utf-8 import httplib import json import os import sys import subprocess import time reload(sys) sys.setdefaultencoding('utf-8') while True: # Get a playlist httpConnection = httplib.HTTPConnection('douban.fm') httpConnection.request('GET', '/j/mine/playlist?type=n&channel=0') song = json.loads(httpConnection.getresponse().read())['song'] # Play player = subprocess.Popen(['mplayer', song[0]['url']]) time.sleep(song[0]['length']) player.kill()
Leave a Reply
You must be logged in to post a comment.