• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomepcDuinoLinux ApplicationsHomemade douban.fm player on pcDuino
Previous Next

Homemade douban.fm player on pcDuino

Posted by: Alvin Jin , March 15, 2014

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:

  1. #!/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()

Tags: Linux Applications

Share!
Tweet

Alvin Jin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors