V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
waterlife
V2EX  ›  分享创造

douban.fm 命令行版

  •  
  •   waterlife · 2017-06-27 09:04:09 +08:00 · 2811 次点击
    这是一个创建于 2488 天前的主题,其中的信息可能已经有所发展或是发生改变。

    doubanfm

    douban.fm

    这是最近学 js/node.js 做的练手项目。由于 js 目前并不是主要工作语言,所以代码可能不太好看,不过功能使用是没什么大问题的。

    截屏

    image

    功能特性

    • 支持登录
    • 支持同步收听记录
    • 支持播放红心兆赫
    • 支持标记红心 /取消红心 /丢垃圾桶
    • 支持歌词显示
    • 支持暂停 /恢复播放

    依赖

    • Node.js 7.6+
    • mplayer

    安装

    • npm i doubanfm -g

    命令行启动

    • doubanfm

    快捷键

    • j 光标下移,选择兆赫
    • k 光标上移,选择兆赫
    • enter/return(回车) 切换到当前选择兆赫
    • n 播放下一首
    • r 标记红心
    • u 取消红心
    • b 丢垃圾桶
    • space(空格) 播放 /暂停

    仅在 mac 上做过运行测试。由于一些限制,在 iTerm 上运行会比较完美。

    18 条回复    2017-06-28 14:08:54 +08:00
    hsmocc
        1
    hsmocc  
       2017-06-27 09:27:06 +08:00 via iPhone
    个人感觉丢进垃圾桶 d 比较合适,还可以绑定光标上下键
    waterlife
        2
    waterlife  
    OP
       2017-06-27 10:07:33 +08:00
    @hsmocc 丢垃圾桶 d 这个快捷键确实不错,回头加上。
    liujiangbei
        3
    liujiangbei  
       2017-06-27 16:02:14 +08:00
    出错了,Nodejs8.1.2
    waterlife
        4
    waterlife  
    OP
       2017-06-27 16:37:15 +08:00
    @liujiangbei 我使用的也是 Node.js 8.1.2,没有问题。有什么出错提示吗?
    liujiangbei
        5
    liujiangbei  
       2017-06-27 20:35:47 +08:00
    @waterlife 提示

    events.js:182
    throw er; // Unhandled 'error' event
    ^

    Error: spawn mplayer ENOENT
    at exports._errnoException (util.js:1016:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:189:19)
    at onErrorNT (internal/child_process.js:366:16)
    at _combinedTickCallback (internal/process/next_tick.js:102:11)
    at process._tickCallback (internal/process/next_tick.js:161:9)
    at Function.Module.runMain (module.js:607:11)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

    我的系统升级到了 10.13 develop 版本
    waterlife
        6
    waterlife  
    OP
       2017-06-27 20:38:29 +08:00
    @liujiangbei #5 你是不是没安装 mplayer ?
    liujiangbei
        7
    liujiangbei  
       2017-06-27 20:44:23 +08:00
    @waterlife mplayer 怎么安装,没有用过这个东西?
    liujiangbei
        8
    liujiangbei  
       2017-06-27 20:47:10 +08:00
    @waterlife 你的 package.json 里边不是已经指定了 mplayer 吗?我还需要 brew install mplayer 安装是吗?

    {
    "name": "doubanfm",
    "version": "0.1.4",
    "description": "Command line interface player of douban.fm",
    "main": "index.js",
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "douban.fm": "node ./index.js"
    },
    "bin": {
    "doubanfm": "./index.js"
    },
    "author": "",
    "license": "MIT",
    "dependencies": {
    "chalk": "^1.1.3",
    "cookie": "^0.3.1",
    "log": "^1.4.0",
    "mplayer": "^2.1.0",
    "opn": "^5.0.0",
    "readline-sync": "^1.4.7",
    "superagent": "^3.5.2",
    "term-img": "^1.0.0",
    "term-list-scrollable": "^0.1.3",
    "underscore": "^1.8.3"
    }
    }
    waterlife
        9
    waterlife  
    OP
       2017-06-27 20:49:33 +08:00
    @liujiangbei #7 推荐安装方式: brew install mplayer
    liujiangbei
        10
    liujiangbei  
       2017-06-27 20:51:36 +08:00
    @waterlife 好的,我试试。
    hwding
        11
    hwding  
       2017-06-27 23:00:09 +08:00
    nodejs 外行问一句,这个能停留在一页上的操作面板是怎么实现的。
    mingyun
        12
    mingyun  
       2017-06-27 23:45:29 +08:00
    貌似不支持 win

    $ doubanfm
    d:\nodejs\node_modules\doubanfm\lib\fm.js:79
    async run() {
    ^^^
    SyntaxError: Unexpected identifier
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (d:\nodejs\node_modules\doubanfm\index.js:3:10)
    at Module._compile (module.js:570:32)
    morethansean
        13
    morethansean  
       2017-06-28 00:43:39 +08:00
    @mingyun 升级到 8.x.
    waterlife
        14
    waterlife  
    OP
       2017-06-28 09:14:11 +08:00
    @mingyun windows 没做测试。但是看你的报错,应该是 Node.js 版本过低的原因。因为项目使用了 async/await 语法,所以 Node.js 至少要求 7.6+。
    waterlife
        15
    waterlife  
    OP
       2017-06-28 09:17:13 +08:00
    @hwding 你可以看看这个库: https://github.com/tj/node-term-list
    liujiangbei
        16
    liujiangbei  
       2017-06-28 10:10:22 +08:00
    @waterlife OK 了,我一开始进入的时候没有登录,现在想要登录怎么搞?
    liujiangbei
        17
    liujiangbei  
       2017-06-28 10:13:10 +08:00
    @waterlife 看了你的源码,自己弄好了,挺有意思的,这个工具。
    LeoEatle
        18
    LeoEatle  
       2017-06-28 14:08:54 +08:00
    不错不错!超喜欢 douban.fm
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4461 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 04:04 · PVG 12:04 · LAX 21:04 · JFK 00:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.