用树莓派播放豆瓣FM电台

用树莓派播放豆瓣FM电台,只需要3条简单的命令完成安装。
首先确认使用的树莓派OS是 Raspbian 系统,因为接下来要安装的应用是基于Linux的。

#安装 mplayer 播放器,如果之前没有装过的话
sudo apt-get install mplayer
#安装 Python-pip
sudo apt-get install python-pip
#通过 Python-pip 安装 douban.fm
sudo pip install douban.fm

这个 douban.fm 程序是来自 github 的一个开源项目,基于 douban 的 API。

安装完成之后,输入以下命令行即可进入播放器界面。

douban.fm

第一次登陆需要输入账号,密码,程序不会保留密码,而是保存返回的token存储在~/.douban_token.txt,下次登陆无需输入密码。

效果如下:
douban-fm

douban-fm-2

操作快捷键

移动
[j] –> 下
[k] –> 上
[g] –> 移到最顶
[G] –> 移到最底
音乐
[space] –> 播放
[w] –> 打开歌曲主页
[n] –> 下一首
[r] –> 喜欢/取消喜欢
[b] –> 不再播放
[q] –> 退出
[p] –> 暂停
[l] –> 单曲循环
音量(>=V0.2.9)
[=] –> 增
[-] –> 减
[m] –> 静音
歌词(>=v0.2.9)
[o] –> 显示歌词(Bug很多,先别用,没有反应就是没找到歌词)
[q] –> 退出歌词

.doubanfm_config保存在了~/.doubanfm_config,根据需要可以修改按键的映射

[key]
UP = k       # 上
DOWN = j     # 下
TOP = g      # 顶
BOTTOM = G   # 底
OPENURL = w  # 打开歌曲主页
RATE = r     # 标记喜欢/取消喜欢
NEXT = n     # 下一首
BYE = b      # 不再播放
QUIT = q     # 退出
PAUSE = p    # 暂停
LOOP = l     # 单曲循环
MUTE = m     # 静音
这是一篇发布于 10年 前的文章,其中的信息可能已经有所发展或是发生改变,请了解。


27 评论

  1. 这个要怎么解决QAQ

    amixer: Mixer attach default error: No such file or directory
    Traceback (most recent call last):
    File “/usr/local/bin/douban.fm”, line 9, in
    load_entry_point(‘douban.fm==0.2.13’, ‘console_scripts’, ‘douban.fm’)()
    File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 337, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
    File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 2279, in load_entry_point
    return ep.load()
    File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 1989, in load
    entry = __import__(self.module_name, globals(),globals(), [‘__name__’])
    File “/usr/local/lib/python2.7/dist-packages/douban/douban.py”, line 25, in
    class Win(cli.Cli):
    File “/usr/local/lib/python2.7/dist-packages/douban/douban.py”, line 43, in Win
    sound_card = ‘Master’ if subprocess.check_output(‘amixer | grep Master’, shell=True) else ‘PCM’
    File “/usr/lib/python2.7/subprocess.py”, line 544, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command ‘amixer | grep Master’ returned non-zero exit status 1

  2. Exception in thread Thread-3:
    Traceback (most recent call last):
    File “/usr/lib/python2.7/threading.py”, line 552, in __bootstrap_inner
    self.run()
    File “/usr/lib/python2.7/threading.py”, line 505, in run
    self.__target(*self.__args, **self.__kwargs)
    File “/usr/local/lib/python2.7/dist-packages/douban/douban.py”, line 335, in run
    self.set_play()
    File “/usr/local/lib/python2.7/dist-packages/douban/douban.py”, line 363, in _func
    func(self)
    File “/usr/local/lib/python2.7/dist-packages/douban/douban.py”, line 416, in set_play
    self.kill_mplayer()
    File “/usr/local/lib/python2.7/dist-packages/douban/douban.py”, line 240, in kill_mplayer
    self.p.stdin.write(‘quit 0\n’)
    IOError: [Errno 32] Broken pipe

  3. Exception in thread Thread-3:
    Traceback (most recent call last):
    File “/usr/lib/python2.7/threading.py”, line 552, in __bootstrap_inner
    self.run()
    File “/usr/lib/python2.7/threading.py”, line 505, in run
    self.__target(*self.__args, **self.__kwargs)
    File “/usr/local/lib/python2.7/dist-packages/douban/douban.py”, line 335, in run
    self.set_play()
    File “/usr/local/lib/python2.7/dist-packages/douban/douban.py”, line 363, in _func
    func(self)
    File “/usr/local/lib/python2.7/dist-packages/douban/douban.py”, line 416, in set_play
    self.kill_mplayer()
    File “/usr/local/lib/python2.7/dist-packages/douban/douban.py”, line 240, in kill_mplayer
    self.p.stdin.write(‘quit 0\n’)
    IOError: [Errno 32] Broken pipe

    我也是这样的问题,请问如何解决呢

  4. 提示出错!Traceback (most recent call last):
    File “/usr/local/bin/douban.fm”, line 5, in
    from pkg_resources import load_entry_point
    File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 2876, in
    working_set = WorkingSet._build_master()
    File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 449, in _build_master
    ws.require(__requires__)
    File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 745, in require
    needed = self.resolve(parse_requirements(requirements))
    File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 639, in resolve
    raise DistributionNotFound(req)
    pkg_resources.DistributionNotFound: cryptography==1.3.2

  5. Traceback (most recent call last):
    File “/usr/local/bin/douban.fm”, line 7, in
    from doubanfm.douban import main
    File “/usr/local/lib/python3.4/dist-packages/doubanfm/douban.py”, line 10, in
    import Queue
    ImportError: No module named ‘Queue’

发表评论

你的邮件地址不会公开


*