Skip to content

Commit

Permalink
每日模板
Browse files Browse the repository at this point in the history
  • Loading branch information
Benature committed Dec 2, 2020
1 parent 3dc866a commit b4da8c2
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 20 deletions.
49 changes: 39 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,67 @@

# [flomo](https://flomoapp.com/)

一个非官方的 API 玩具盒
一个非官方的 API python 玩具盒

- 【播客】[小宇宙url 👉 flomo memo](./xyz2flomo.py)
- Alfred + flomo ([demo 视频](https://m.okjike.com/originalPosts/5fc1e8f0c5e485001882a2be?s=ewoidSI6ICI1ZWUxZDQ1OGY5MmZiYzAwMTc3NWMwZTgiCn0=))
- [send a new flomo memo](./flomo.py)
- [ ] 模板
- 发送新的 flomo memo
- 按模板创建 memo (inspired by [即刻@阿粒](https://m.okjike.com/originalPosts/5fc648d8c463ad00188e917a?s=ewoidSI6ICI1ZWUxZDQ1OGY5MmZiYzAwMTc3NWMwZTgiCn0=))

# Usage 使用
> *prefer python3.7+*
## Cookies
## Usage 使用

### Cookies

[`config_sample.py`](./config_sample.py) 更名为 `config.py`

<p align="center">
<a href="#"><img src="https://s3.us-west-2.amazonaws.com/secure.notion-static.com/df9f58b6-0e3d-4bc4-86fa-0140afa6c203/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAT73L2G45O3KS52Y5%2F20201201%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20201201T165601Z&X-Amz-Expires=86400&X-Amz-Signature=838775cb2a76b8e8e496931c1d0b20cc3347b0d713c7b6d5ff1e852adb83c510&X-Amz-SignedHeaders=host&response-content-disposition=filename%20%3D%22Untitled.png%22" width="70%"/></a>
<a href="#"><img src="https://s3.us-west-2.amazonaws.com/secure.notion-static.com/df9f58b6-0e3d-4bc4-86fa-0140afa6c203/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAT73L2G45O3KS52Y5%2F20201201%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20201201T165601Z&X-Amz-Expires=86400&X-Amz-Signature=838775cb2a76b8e8e496931c1d0b20cc3347b0d713c7b6d5ff1e852adb83c510&X-Amz-SignedHeaders=host&response-content-disposition=filename%20%3D%22Untitled.png%22" width="80%"/></a>
</p>

[...待补充](https://www.notion.so/benature/flomo-0061a1c4d4b643c58a9855aa8a28e0fb)

## Alfred
### Notify 通知

详细说明见 [About Notification 关于通知](#about-notification-关于通知)

配置参照 [terminal-notifier](https://github.com/julienXX/terminal-notifier#options)

### Template 模板

- `path`: 模板路径
- `time_format`: 日报日期格式

默认模板为[日报](./templates/daily.html),可自行修改格式

## Workflow

### Alfred (macOS)

...待补充

### Wox (Windows)

*TBD...*

## About Notification 关于通知

(macOS)有以下两种通知方法来实现:

- apple script
- [terminal-notifier](https://github.com/julienXX/terminal-notifier)
- **[terminal-notifier](https://github.com/julienXX/terminal-notifier)** (recommended)

推荐后者,前者简单粗暴,后者好处在于

推荐后者,优点在于
- 设置了 logo
- 可自定系统提示音
- 支持点击通知后跳转到 flomo app
- 跳转到 Chrome app
- 跳转到 [flomoapp.com](https://flomoapp.com/) 网页
- 跳转到 [flomoapp.com](https://flomoapp.com/) 网页

不过需要另外安装

```shell
brew install terminal-notifier
```
7 changes: 6 additions & 1 deletion config_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@
'sound': 'Hero',
'activate': 'com.google.Chrome.app.xxxxxxxx',
'open': '', # 如不需打开网页请设置为空字符串 ''
'app_path': '/usr/local/Cellar/terminal-notifier/2.0.0/terminal-notifier.app/Contents/MacOS/terminal-notifier',
'app_path': '/usr/local/Cellar/terminal-notifier/2.0.0/terminal-notifier.app/Contents/MacOS/terminal-notifier', # 注意版本号
}

template = {
'path': 'templates/daily.html',
'time_format': '%Y%m%d',
}
35 changes: 26 additions & 9 deletions flomo.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import requests
import re
import json
import re
import os

from datetime import datetime

from config import cookies
from config import cookies, template as tc
from notify import notify

folder_path = os.path.dirname(os.path.abspath(__file__))


class Flomo():
def __init__(self, cookies=cookies):
Expand Down Expand Up @@ -49,14 +54,26 @@ def new(self, content, parent_memo_id=None, file_ids=[], source='web'):

if __name__ == '__main__':
import sys
# args = sys.argv[1].split(' ')
# notify("test", len(sys.argv))
flomo = Flomo()

if sys.argv[1] == 'new':
content = sys.argv[2]
response = flomo.new(
''.join([f'<p>{c}</p>' for c in content.split('\n')]))
if response.status_code == 200:
notify("flomo: new memo", content)
if content == 't':
# template
from datetime import datetime
today = datetime.now().strftime(tc['time_format'])

with open(os.path.join(folder_path, tc['path']), 'r') as f:
content = f.read()
response = flomo.new(content.format(today))
if response.status_code == 200:
notify("flomo: memo template", today)
else:
notify("🚨 flomo Error", response)
else:
notify("🚨 flomo Error", response)
response = flomo.new(
''.join([f'<p>{c}</p>' for c in content.split('\n')]))
if response.status_code == 200:
notify("flomo: new memo", content)
else:
notify("🚨 flomo Error", response)
22 changes: 22 additions & 0 deletions templates/daily.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<p>#工作日记 </p>
<p>即刻-{}-日报</p>
<p>今日总结</p>
<ol>
<li>
<p></p>
</li>
</ol>
<p></p>
<p>明日计划</p>
<ol>
<li>
<p></p>
</li>
</ol>
<p></p>
<p>一点感想</p>
<ol>
<li>
<p></p>
</li>
</ol>

0 comments on commit b4da8c2

Please sign in to comment.