Skip to content

Commit

Permalink
新增群晖Download Station下载脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
blackmatrix7 committed Sep 27, 2021
1 parent f727bde commit ac1263f
Show file tree
Hide file tree
Showing 8 changed files with 413 additions and 0 deletions.
55 changes: 55 additions & 0 deletions script/boxjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,60 @@
}
]
}
{
"id": "blackmatrix7.synology",
"name": "Synology",
"keys": ["syno_https_url", "syno_account", "syno_passwd", "syno_sid"],
"settings": [
{
"id": "syno_https_url",
"name": "群晖地址",
"val": "",
"type": "input",
"placeholder": "http://192.168.1.100:5000",
"autoGrow": true,
"desc": "目前暂不支持https,请使用http"
},
{
"id": "syno_account",
"name": "群晖账户",
"val": "",
"type": "input",
"placeholder": "admin",
"autoGrow": true,
"desc": "可访问DownloadStation的账号,记得设置默认下载路径"
},
{
"id": "syno_passwd",
"name": "群晖密码",
"val": "",
"type": "input",
"placeholder": "",
"autoGrow": true,
"desc": "建议单独建立一个账户保证安全"
},
{
"id": "syno_sid",
"name": "群晖Sid",
"val": "",
"type": "input",
"placeholder": "",
"autoGrow": true,
"desc": "除非无法正常获取Sid,否则保持现在的值,不要修改"
}
],
"author": "@blackmatrix7",
"repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/synology",
"icons": [
"https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/icon/synology_dark.jpg",
"https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/icon/synology.jpg"
],
"scripts": [
{
"name": "登录Synology",
"script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/downloadstation.js"
}
]
}
]
}
80 changes: 80 additions & 0 deletions script/synology/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Download Station

利用Synology的Download Station下载互联网资源。

## 说明

一个小玩具,实现将互联网某些资源添加到群晖的Download Stations下载,目前暂时支持推特第三方客户端的图片视频下载。

这其实是个架子,提供一种思路:通过脚本获取资源后添加到群晖的Download Station,欢迎有兴趣的大佬一起完善,添加其他功能。~~计划添加自动下载京东电子发票,看什么时候有时间再实现。~~

在使用脚本前,需要有一些前提条件:

1. 一台群晖,安装Download Station
2. 会使用BoxJs
3. 保证能在各种情况下访问群晖
4. 一点点动手和排查问题的能力

## 基础配置

### 新建群晖账户

访问你的群晖,新增User账户,**一定要新建账户**。为了数据安全,强烈建议不要给予管理员权限。仅需要DSM、~~File Station(实际上不需要,看着给)~~、Download Station三个权限。

**目录权限方面,仅需要下载目录的读写权限,其他目录的权限不需要给**,如果你一定要给我也不拦着。

### 登录账户

登录新建的账户,打开Download Station,首次使用会提示选择下载目录,设置好下载目录后完成配置。

### 配置BoxJS

在BoxJS里填入群晖的http地址,不建议使用https,可能因为证书问题会导致访问失败,账户密码根据最近的设置输入,sid不需要填,会自动获取。

目前仅在DSM6.2上验证,DSM7上没有测试是否正常,如果群晖的DSM7接口没有变化应该是可以的。

## 存在的问题

群晖的sid一段时间后会失效,观察了3个多月,sid有效期大概1个月不到,具体的时间没有统计。sid失效后,需要进入boxjs手动将sid删除,让脚本重新获取。~~自动更新sid可以实现,不过比较懒,看看什么时候手动操作烦了再考虑加这个功能。~~

可能会导致用于下载的群晖账户出现异常,表现为sid无论如何重新获取,都无法正常添加下载任务。这个时候需要删除这个用于下载的账户,再根据上述的步骤重新添加账户。目前仅偶尔出现,可能是sid失效后多过重试导致。

**所以新建一个专用的账户给脚本使用就非常重要了。**

## Twitter资源下载

### Twitter第三方客户端

因为Twitter官方的客户端带SSL Pinning,没办法使用此脚本,所以必须使用第三方客户端。并且**开启此脚本的复写后,会导致Twitter官方客户端无法正常使用。**

### 操作方式

在Twitter第三方客户端中,看到喜欢的推文,点击Like,会自动将推文内的图片和视频下载到群晖中。当然还要保证群晖能访问推特,否则下载资源就无从谈起了……

### 配置说明

#### Surge

使用模块

```ini
https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/twitter.sgmodule
```

#### Loon

使用插件

```ini
https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/twitter.lnplugin
```

#### Quantumult X

配置文件

```ini
[rewrite_remote]
https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/twitter.qxrewrite, tag=Twitter_离线下载收藏内容, enabled=true
```

258 changes: 258 additions & 0 deletions script/synology/downloadstation.js

Large diffs are not rendered by default.

Binary file added script/synology/icon/synology.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added script/synology/icon/synology_dark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions script/synology/twitter.lnplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Twitter离线下载收藏内容

[Script]
http-response ^https?:\/\/api\.twitter\.com\/[0-9.]*\/favorites\/create.json requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/downloadstation.js,tag=Twitter_离线下载收藏内容


[MITM]
hostname = api.twitter.com
4 changes: 4 additions & 0 deletions script/synology/twitter.qxrewrite
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Twitter_离线下载收藏内容
^https?:\/\/api\.twitter\.com\/[0-9.]*\/favorites\/create.json url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/downloadstation.js

hostname = api.twitter.com
8 changes: 8 additions & 0 deletions script/synology/twitter.sgmodule
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!name=Twitter
#!desc=Twitter离线下载收藏内容

[Script]
Twitter_收藏离线下载 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/api\.twitter\.com\/[0-9.]*\/favorites\/create.json,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/downloadstation.js

[MITM]
hostname = %APPEND% api.twitter.com

0 comments on commit ac1263f

Please sign in to comment.