Giter Site home page Giter Site logo

douban.fm's Introduction

Hi there

Stats

Anurag's github stats

GitHub Trophies

trophy

douban.fm's People

Contributors

bitdeli-chef avatar blambin avatar cloverstd avatar fansion avatar fewtime avatar gitter-badger avatar hexcles avatar jonas8 avatar killpanda avatar qingyunha avatar qytz avatar taizilongxu avatar vulcan-lin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

douban.fm's Issues

There is a problem in choosing sound_card.

 try:
        if subprocess.check_output('amixer | grep PCM'):
            sound_card = "PCM"
    except:
        sound_card = "Master"

the line "if subprocess.check_output('amixer | grep PCM'):¨ should be modified to:
if subprocess.check_output('amixer | grep PCM',shell='true'):

otherwise: it will choose Master but not PCM in my raspberry pi.

voice volume adjustment with interactive command line does not work with Raspberry pi

hi, installed douban.fm in my rpi , everything works fine except the volume adjustment using "=" and "-" does not work , here is the fix i verified.

the reason is in the douban.py there is a line of code to associated to amixer "Master", but RPi does not use "Master" , it use "PCM" instead

获取音量

def get_volume(self):
    if self.platform == 'Linux':
        volume = subprocess.check_output('amixer get Master | grep Mono: | cut -d " " -f 6', 

shell=True)
volume = volume[1:-3]
elif self.platform == 'Darwin':
volume = subprocess.check_output('osascript -e "output volume of (get volume setti
ngs)"', shell=True)
else:
volume = ''
self.volume = volume

# 调整音量大小
def change_volume(self, increment):
    if increment == 1:
        volume = int(self.volume) + 5
    else:
        volume = int(self.volume) - 5
    if self.platform == 'Linux':
        subprocess.Popen('amixer set Master ' + str(volume) + '% >/dev/null 2>&1', shell=True

)

the way to fix it is just to replace the two words of "Master" in the code with "PCM"

in my system , i got the path of the douban.py
/usr/local/lib/python2.7/dist-packages/douban/douban.py

use an text editor to modify it, and restart your douban.fm, that's all.

after the fix , i got following, noted that i have "vol: 90% →" now

 Douban Fm \ retjiang   >>  64kbps  01:38  rate: ★ ★ ★ ★ ★   vol: 90%  →

红心兆赫 ♥ Hotel California • Hotel California • Eagles 1976
私人兆赫
华语
欧美
七零
八零
九零
粤语
摇滚
民谣
轻音乐
原声
爵士
电子
说唱
R&B
日语
韩语
女声
法语
古典
动漫
咖啡馆
圣诞
Sonos 乐满人家
豆瓣好歌曲
世界音乐
布鲁斯
新歌
雷鬼

pip install issue

Downloading/unpacking douban.fm
Downloading douban.fm-0.2.1.tar.gz
Running setup.py (path:/tmp/pip_build_root/douban.fm/setup.py) egg_info for package douban.fm
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/douban.fm/setup.py", line 9, in
with open('README.md') as f:
IOError: [Errno 2] No such file or directory: 'README.md'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 17, in

File "/tmp/pip_build_root/douban.fm/setup.py", line 9, in

with open('README.md') as f:

IOError: [Errno 2] No such file or directory: 'README.md'

Mac 10.10.1 打开失败

/bin/sh: amixer: command not found
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 "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 356, in load_entry_point
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2476, in load_entry_point
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2190, in load
File "/usr/local/lib/python2.7/site-packages/douban/douban.py", line 25, in
class Win(cli.Cli):
File "/usr/local/lib/python2.7/site-packages/douban/douban.py", line 43, in Win
sound_card = 'Master' if subprocess.check_output('amixer | grep Master', shell=True) else 'PCM'
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 573, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command 'amixer | grep Master' returned non-zero exit status 1

没找到原因,囧

douban.fm run on raspberry pi getting error

Traceback (most recent call last):
File "/usr/local/bin/douban.fm", line 9, in
load_entry_point('douban.fm==0.2.15', 'console_scripts', 'douban.fm')()
File "/usr/local/lib/python2.7/dist-packages/douban.fm-0.2.15-py2.7.egg/douban/douban.py", line 666, in main
Win(douban)
File "/usr/local/lib/python2.7/dist-packages/douban.fm-0.2.15-py2.7.egg/douban/douban.py", line 111, in init
self.play()
File "/usr/local/lib/python2.7/dist-packages/douban.fm-0.2.15-py2.7.egg/douban/douban.py", line 256, in play
self.douban.get_song()
File "/usr/local/lib/python2.7/dist-packages/douban.fm-0.2.15-py2.7.egg/douban/douban_token.py", line 255, in get_song
self.playingsong = self.playlist.pop(0)
IndexError: pop from empty list

音量控制似乎有点问题:

调节音量的时候('+'键)会报这个错误。然后什么命令也不能用了。Orz。

Traceback (most recent call last):
  File "/usr/local/bin/douban.fm", line 9, in <module>
    load_entry_point('douban.fm==0.2.12', 'console_scripts', 'douban.fm')()
  File "/usr/local/lib/python2.7/dist-packages/douban/douban.py", line 460, in main
    Win(douban)
  File "/usr/local/lib/python2.7/dist-packages/douban/douban.py", line 85, in __init__
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/douban/douban.py", line 357, in run
    self.change_volume(1)
  File "/usr/local/lib/python2.7/dist-packages/douban/douban.py", line 154, in change_volume
    volume = int(self.volume) + 5
ValueError: invalid literal for int() with base 10: ''
amixer: Unable to find simple control 'Master',0

希望能帮忙看一下。:)

ArchLinux下的错误

Traceback (most recent call last):
File "/usr/bin/douban.fm", line 9, in
load_entry_point('douban.fm==0.2.15', 'console_scripts', 'douban.fm')()
File "/usr/lib/python3.4/site-packages/pkg_resources/init.py", line 521, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3.4/site-packages/pkg_resources/init.py", line 2632, in load_entry_point
return ep.load()
File "/usr/lib/python3.4/site-packages/pkg_resources/init.py", line 2312, in load
return self.resolve()
File "/usr/lib/python3.4/site-packages/pkg_resources/init.py", line 2318, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/lib/python3.4/site-packages/douban/douban.py", line 502
print self.win.TITLE
^
SyntaxError: Missing parentheses in call to 'print'

403 Forbidden

...不知道是不是调试的时候请求歌曲列表太频繁了,我现在所有请求都得到 403 Forbidden 。还是说是豆瓣关了这个接口?@taizilongxu 你能正常使用么?

Deal with missing mplayer (and might add support for mpg123)

#44 & #38 seems related with the missing of mplayer. We should raise a more meaningful exception, failing loudly.

What is more, adding support for mpg123 might also be a good idea, since mpg123 is smaller and more people have it installed (as the dependency of other softwares).

I'll add support for mplayer2 and mpv as well. These twos are clone / next generation of mplayer and have similar interface.

运行后报错

osx 10.2

Traceback (most recent call last):
  File "/usr/local/bin/douban.fm", line 9, in <module>
    load_entry_point('douban.fm==0.2.8', 'console_scripts', 'douban.fm')()
  File "build/bdist.macosx-10.10-intel/egg/douban/douban.py", line 187, in main
  File "build/bdist.macosx-10.10-intel/egg/douban/douban.py", line 43, in __init__
  File "build/bdist.macosx-10.10-intel/egg/douban/douban.py", line 94, in play
  File "build/bdist.macosx-10.10-intel/egg/douban/douban_token.py", line 154, in get_song
IndexError: pop from empty list

无法找到 colorset/default.json

IOError: [Errno 2] No such file or directory: '/usr/lib/python2.7/site-packages/douban/colorset/default.json'

似乎是 setup.py 没做相应更新?

Username login unsupported

目前只支持用邮箱进行登录,但我的豆瓣FM账户是用用户名进行登录的,email字段填入用户名会返回invalidate_email

使用 mplayer 的音量控制替代系统音量控制?

现在处理音量的部分非常 tricky ,主要原因是直接操作了系统的主音量(而静音又是用的 mplayer 内部的功能)。但是今天突然一想:按照正常的逻辑和习惯,这类的播放器应该是管理自己的音量才对。直接使用 mplayer 内部的软音量控制的话会省去很多麻烦。

另外,这也能“顺便”解决静音状态下切换歌曲的 bug 。

调试了一下发现,主要原因是出在 mplayer 的 slave 模式如果是在程序运行的瞬间、流未初始化的时候输入命令是没有效果的。停个一两秒再 mute 也不是个好主意——不同网络状态下初始化的时间不一样,可能出现播个半秒又静音,或者是1秒根本不够初始化的情况。

而如果换个思路,用 mplayer 的软件音量来实现静音功能,就有办法了——启动的时候加 -volume 0 参数即可。解除静音的时候再把音量重置回上一次的值(或者初始值)。

@taizilongxu 你觉得如何?

Exception Handling

身在海外,和豆瓣的连接不稳定,比较经常遇到网络问题,这两天下来好几次遇到 Uncaught Exception 然后程序行为就不正常了。

打算整理一下代码,主要是实现一下更完善的错误处理机制。估计需要一段时间,而且可能会有比较大的改动。好了以后发 PR 上来。

mac 报错,是缺东西吗?

如下:
Traceback (most recent call last):
File "/usr/local/bin/douban.fm", line 5, in
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in
working_set.require(requires)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: requests

配置文件新增了快捷键后载入之前版本配置文件会导致载入异常

Traceback (most recent call last):
  File "/usr/local/bin/douban.fm", line 9, in <module>
    load_entry_point('douban.fm==0.2.9', 'console_scripts', 'douban.fm')()
  File "build/bdist.macosx-10.9-x86_64/egg/douban/douban.py", line 410, in main
  File "build/bdist.macosx-10.9-x86_64/egg/douban/douban.py", line 30, in __init__
  File "build/bdist.macosx-10.9-x86_64/egg/douban/douban.py", line 84, in get_config
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py", line 618, in get
    raise NoOptionError(option, section)
ConfigParser.NoOptionError: No option 'pause' in section: 'key'

Linux下音量获取有问题

我这儿 amixer get Master 的输出是这样的:

Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 11142 [17%] [on]
  Front Right: Playback 11142 [17%] [on]

所以像现在代码里那样 grep Mono 的话拿到的是空行,不能获取音量。

不知道是有bug还是 amixer 不同版本、平台下的表现不同。前者的话我这儿已经改好了一个版本,可以发个PR上来;后者的话,需要考虑一下更可靠的音量获取方法了。

请大神讲讲播放这部分,谢谢!

比如如何调用mplayer等。还有fifo是用来做什么的,将歌曲信息写入管道然后子进程获取显示在终端?

    # 播放歌曲
    def play(self):
        self.lrc_dict = {}  # 歌词清空
        if not self.loop:
            self.douban.get_song()
        if self.is_muted:  # 静音状态
            subprocess.Popen('echo "mute {mute}" > {fifo}'.format(
                fifo=self.mplayer_controller, mute=1), shell=True, stdin=subprocess.PIPE)
        song = self.douban.playingsong
        self.song_time = song['length']
        # 是否是红心歌曲
        if song['like'] == 1:
            love = self.love
        else:
            love = ''
        title = colored(song['title'], 'green')
        albumtitle = colored(song['albumtitle'], 'yellow')
        artist = colored(song['artist'], 'white')
        self.SUFFIX_SELECTED = (love + ' ' + title + ' • ' + albumtitle + ' • ' + artist + ' ' + song['public_time']).replace('\\', '')

        cmd = 'mplayer -slave -input file={fifo} {song_url} >/dev/null 2>&1'
        self.p = subprocess.Popen(cmd.format(fifo=self.mplayer_controller, song_url=song['url']), shell=True, stdin=subprocess.PIPE)  # subprocess.PIPE防止继承父进程
        self.pause = False
        self.display()
        self.notifySend()
        if self.lrc_display:  # 获取歌词
            self.lrc_dict = self.douban.get_lrc()
            if not self.lrc_dict:  # 歌词获取失败,关闭歌词界面
                self.lrc_display = 0
        self.start = 1

douban.fm无法运行成功

Mac下通过pip安装douban.fm成功后,执行douban.fm报出错误,如下:

Traceback (most recent call last):
File "/usr/local/bin/douban.fm", line 5, in
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in
working_set.require(requires)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: requests

termcolor和requests已经安装,我的Mac版本是10.9.5

如果红心兆赫一个也没有的话,会出现一个错误

Traceback (most recent call last):
  File "/usr/local/bin/douban.fm", line 9, in <module>
    load_entry_point('douban.fm==0.2.9', 'console_scripts', 'douban.fm')()
  File "/usr/local/lib/python2.7/dist-packages/douban/douban.py", line 323, in main
    w = Win(douban)
  File "/usr/local/lib/python2.7/dist-packages/douban/douban.py", line 53, in __init__
    self.play()
  File "/usr/local/lib/python2.7/dist-packages/douban/douban.py", line 130, in play
    self.douban.get_song()
  File "/usr/local/lib/python2.7/dist-packages/douban/douban_token.py", line 157, in get_song
    self.playingsong  = self.playlist.pop(0)
IndexError: pop from empty list

其他都好赞!!!

GNOME Shell 图标缓存问题

notify-send中指定的图标是有缓存的,只要路径完全一样,即使文件内容改变图标也不会更新。考虑使用随机路径(现在用的 /tmp/tmp.jpg 也的确不大科学)。

正在写,好了以后发PR。

Support arrow keys?

HJKL might not be intuitive enough for non-vim users. Adding arrow key support is acceptable, I think.

网络掉线异常处理

放歌放到一半断网然后又恢复之后虽然已经加载出歌曲了,但是mplayer提示的歌名还是在不断变......但是最后会稳定......

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6

On startup:

Traceback (most recent call last):
  File "/home/robot/studio/douban.fm/douban/douban.py", line 775, in <module>
    main()
  File "/home/robot/studio/douban.fm/douban/douban.py", line 772, in main
    Win(douban)
  File "/home/robot/studio/douban.fm/douban/douban.py", line 120, in __init__
    self.display()
  File "/home/robot/studio/douban.fm/douban/douban.py", line 210, in display
    cli.Cli.display(self)
  File "/home/robot/studio/douban.fm/douban/cli.py", line 73, in display
    line = '%s %s %s' % (prefix, i, suffix)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)

【建议】

~1.请问声音调整幅度能改成5吗
~2.还有就是下一首的时候Ubuntu桌面通知会有延迟
~3.能设置默认的电台吗,每次重启后都是默认红心兆赫
~4.还有就是向上滚动的时候会有以下情况:http://i2.tietuku.com/bac084cf097018a9.png
~5.有时专辑名称过长之后会省略
~6.能不能自定义电台的显示,平常我只是听一下粤语什么的
~7.现在普通用户听的是192kbps,POR用户听的是320kbps,能否提升音质?

P.S.问题有点多哈,别介意,谢啦~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.