Skip to main content
## 饭否命令行客户端

### 安装
- 通过pip安装
```sh
pip3 install fanfou-cli
```
- 手动安装
```sh
git clone https://github.com/j178/fanfou-cli
cd fanfou-cli
pip3 install . --user
```

### 使用
![](_images/4.png)

**日常使用**:

```sh
fan 任意文字,不需要引号,可以包含空格,fan命令之后的任意内容均被当作新饭的内容
```

**其他功能**:
- 不加任何参数直接运行`fan`, 则在默认浏览器中打开饭否主页(fanfou.com)
- `fan 任意文字 -i <image-filename>/<image-url>` 上传图片。
`-i`参数可以是图片的本地路径或者网络URL,网络URL请用引号引起来。文字可以为空。
- `fan -` `fan`命令后加短横线`-`,表示从标准输入(stdin)中读取内容。这样就可以输入多行的饭,输入完成后按`Ctrl+D`(Windows下`Ctrl+Z`)结束输入。
也可以与其他命令结合起来使用,如`echo 'hello' | fan -`
- `fan -r` 撤回上一条饭
- `fan -v` 在终端上刷饭
- `fan -m` 查看自己的饭否资料
- `fan -d` 随机查看一些公开的饭
- `fan -u <user-id>` 查看他人的资料,`user-id`可从`fan -v`模式的`名字@id`中获得
- `fan --lock 1` 上锁;`fan --lock 0` 解锁
- `fan --dump <文件名>` 将所有饭否消息保存为JSON格式。文件名可选,默认为`timeline.json`
在此模式下,`j`键翻页,`c 序号 xxx` 评论一条饭,`r 序号 xxx` 转发一条饭,`f 序号`关注一条被转发的饭的原PO,`u 序号`取消关注
- `fan -h` 查看帮助


初次使用时,此工具需要获取你的授权才能帮你发饭。
1. 首先执行`fan`的任意命令,工具会指示你在浏览器中打开一个链接:
```sh
$ fan -h
请在浏览器中打开此网址: http://fanfou.com/oauth/authorize?callback_uri=http%3A%2F%2Fu.nigel.top&oauth_t
oken=20a6af62dc1913997c48b7d4f03177ef
```
**这个是饭否官方授权第三方应用的页面,请放心打开。**

2. 打开之后会出现如下授权页面:
![](_images/1.png)
点击同意,即允许第三方应用操作你在饭否上的数据。

3. 然后,浏览器会重定向到一个链接,浏览器会提示无法打开这个页面,没关系,我们需要的只是这个页面的网址,
即`http://my.nigel.top/callback?oauth_token=db6d6915fe3bb31df2675b9cac1e3569` 这样的东西,将它复制到我们运行的脚本中:
```sh
请将跳转后的网站粘贴到这里: http://my.nigel.top/callback?oauth_token=db6d6915fe3bb31df2675b9cac1e3569
授权完成,可以愉快地发饭啦!
```
OK! 授权已经完成了,现在可以愉快地刷饭了!

**整个授权过程都是使用饭否官方地OAuth API,此工具无法获取到你的密码。如果你想取消对此工具的授权,
可以随时访问 `http://fanfou.com/settings/apps`, 找到`爱米饭`, 然后`取消认证`就可以了啦~。如下图所示:**
![](_images/2.png)


### 说明
- 此工具会在`~/.fancache`(*unix系统)或 `%USERPROFILE%/.fancache`中保存认证凭据(`access_token`),用户的饭否资料,和你的最新的一条饭否消息。你可以随时删除这个文件,不过删除之后需要重新授权。
- 上锁/解锁功能需要你在浏览器中打开饭否页面,然后按`F12`打开控制台,执行以下`Javascript`代码,将代码的输出结果粘贴到脚本中。
```javascript
(/al=(.*?);/i).exec(document.cookie)[1]
```
**[!!!]获取你的登陆Cookie是非常危险的行为,此工具保证不会上传保存任何你的个人资料和Cookie,但 Use at your own risk!**

### 依赖
- Python3
- requests-oauthlib
- arrow

### TODO
- [x] 图片上传
- [x] colorize
- [x] time humanize
- [x] 转发/评论消息
- [x] 上锁/解锁功能
- [ ] 备份进度条
- [ ] 查看提到我的消息
- [ ] 查看私信

Release files for fanfou-cli 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fanfou-cli 0.1.11
File Size Uploaded
fanfou-cli-0.1.11.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fanfou-cli 0.1.11
File Interpreter ABI Platform
fanfou_cli-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 26.5 kB

Release files / fanfou-cli-0.1.11.tar.gz

Download URL fanfou-cli-0.1.11.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b9e4d8beaa373e989f8030bed83dfc45820c25130565a92035694447fd8ebe97
BLAKE2b-256 checksum
How to use checksums
d89de0939315914c293bd70764d4ad067c6189ebb3da02fe9fa56fa0804c9a82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fanfou_cli-0.1.11-py3-none-any.whl

Download URL fanfou_cli-0.1.11-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa64c98f7530fa1b21d13673cc49a7c54b8ee09aff742059b02a05f449a74712
BLAKE2b-256 checksum
How to use checksums
b243794603dc38918cee2b9978b5763b00df21bbdbff773f10d28e5184a27ab9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.1.18

1 release file

0.1.13

2 release files

0.1.12

2 release files

This release

0.1.11 This release

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page