V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
tdoly
V2EX  ›  Python

BaiduFm 命令行 python 版

  •  
  •   tdoly · 2015-06-02 09:53:22 +08:00 · 3077 次点击
    这是一个创建于 3264 天前的主题,其中的信息可能已经有所发展或是发生改变。
    现在主要的功能:

    欢迎fork,试用 https://github.com/tdoly/baidufm-py


    1.随机播放Baidu FM音乐
    2.登录Baidu FM(显示验证码)
    3.快捷键操作(上,下选择切歌...)
    4.暂停/恢复 播放
    5.静音
    6.音量调节
    7.收藏/取消收藏 音乐
    8.音乐加入垃圾箱

    周末加上了命令行验证码的显示:



    16 条回复    2015-06-03 20:14:54 +08:00
    wowpanda
        1
    wowpanda  
       2015-06-02 10:03:31 +08:00
    学习ing
    qgy18
        2
    qgy18  
       2015-06-02 10:19:34 +08:00 via iPhone
    能支持网易云音乐么
    GhostFlying
        3
    GhostFlying  
       2015-06-02 10:22:12 +08:00
    @qgy18 以前有过吧,然后都被网易发了警告信了
    qgy18
        4
    qgy18  
       2015-06-02 10:23:20 +08:00 via iPhone
    @GhostFlying 好吧。。
    tdoly
        5
    tdoly  
    OP
       2015-06-02 12:06:52 +08:00
    @wowpanda 欢迎pull
    @qgy18 不支持啊~自己听baidu fm 和 douban fm比较多
    @GhostFlying 这样也会被警告~
    Goooogle
        6
    Goooogle  
       2015-06-02 12:51:03 +08:00
    iam36
        7
    iam36  
       2015-06-03 09:09:44 +08:00
    楼主,执行报错:

    from _curses import *
    tdoly
        8
    tdoly  
    OP
       2015-06-03 10:08:55 +08:00
    @iam36 能具体说下系统类型,版本,python环境吗?
    这个命令行播放器是用到了python的curses,https://docs.python.org/2/library/curses.html。现在支持的是 osx和 linux系统。
    iam36
        9
    iam36  
       2015-06-03 12:40:04 +08:00
    windows :),看来就是因为这个了
    Freakr
        10
    Freakr  
       2015-06-03 13:07:47 +08:00
    Ubuntu14.04 Python2.7.6 requests里没有packages
    requests.packages.urllib3.disable_warnings()无法执行

    >>> dir(requests)
    ['ConnectionError', 'HTTPError', 'NullHandler', 'PreparedRequest', 'Request', 'RequestException', 'Response', 'Session', 'Timeout', 'TooManyRedirects', 'URLRequired', '__author__', '__build__', '__builtins__', '__copyright__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__path__', '__title__', '__version__', 'adapters', 'api', 'auth', 'certs', 'codes', 'compat', 'cookies', 'delete', 'exceptions', 'get', 'head', 'hooks', 'logging', 'models', 'options', 'patch', 'post', 'put', 'request', 'session', 'sessions', 'status_codes', 'structures', 'utils']
    Freakr
        11
    Freakr  
       2015-06-03 13:15:35 +08:00
    好吧,upgrade了requests,可以了
    tdoly
        12
    tdoly  
    OP
       2015-06-03 13:48:11 +08:00
    @Freakr
    OK,刚看了下requests的包,是有 packages的。
    https://github.com/kennethreitz/requests/tree/master/requests

    这句其实注释掉也是可以的。主要是为了禁用urllib3警告。
    Freakr
        13
    Freakr  
       2015-06-03 15:37:00 +08:00
    登录前正常,登录后报错
    File "/home/????/baidufm-py-master/baidufm/fm_cli.py", line 130, in init_head
    self.head_win.addstr(0, len_x, user_name, curses.color_pair(2))
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-5: ordinal not in range(128)
    用户名是中文的问题?在fm_cli.py加了“
    import sys
    reload(sys)
    sys.setdefaultencoding( "utf-8" )
    ”后成功登录。
    wowpanda
        14
    wowpanda  
       2015-06-03 19:55:00 +08:00
    楼主,你这是爬虫写的还是用的官方api啊
    tdoly
        15
    tdoly  
    OP
       2015-06-03 20:13:54 +08:00
    @Freakr 欢迎pull~
    tdoly
        16
    tdoly  
    OP
       2015-06-03 20:14:54 +08:00
    @wowpanda 官方没API,用wireshark和firebug抓的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   996 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:03 · PVG 05:03 · LAX 14:03 · JFK 17:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.