dmhy-subscribe
Advanced tools
Comparing version
@@ -7,3 +7,2 @@ # Docker | ||
## Requirements 依賴軟體 | ||
@@ -31,8 +30,7 @@ | ||
docker build . -t dmhy-subscribe | ||
``` | ||
執行腳本建立必要之檔案環境與設定檔。 | ||
執行 `setup.bash` 建立必要之檔案環境與設定檔。 | ||
這個腳本會建立 `data` 資料夾,包含了 `dmhy-subscribe` 、 `cron` 和 `aria2` 的設定檔。可以直接使用或依個人需求修改。 | ||
這個腳本會建立 `data` 資料夾,包含了 `dmhy-subscribe` 、 `cron` 和 `aria2` 的設定檔。 | ||
@@ -43,3 +41,33 @@ ```sh | ||
可以直接使用或參考下面設定說明依個人需求修改。 | ||
## dmhy-subscribe 個人化設定 | ||
在 `setup.bash` 內可以設定個人化參數 | ||
```sh | ||
# dmhy 的語系設定 | ||
export LANG='C.UTF-8' | ||
# LANG='zh_TW.utf8' # 中文 | ||
# cron 的排程週期設定 | ||
export CRON_FREQ='0 * * * *' | ||
``` | ||
## Aria2 設定 | ||
我們使用 [docker-aria2-with-webui](https://github.com/abcminiuser/docker-aria2-with-webui) 作為下載容器。如果要修改相關設定請參考連結說明。 | ||
為相容 MacOS,預設 `file-allocation` 為 `prealloc`,若系統允許可以更改 `data/aria2` 中的設定檔為更高速的 `falloc`。 | ||
## Docker Compose 設定 | ||
可以修改 `docker-compose.yml` 以進行設定。 | ||
### 重要設定 | ||
請使用 `id` 指令查看自己的 `UID` 和 `GID`,並將 `docker-compose.yml` 中的 `PUID` 和 `PGID` 分別設定為個人之 `UID` 與 `GID` ,以確保 aria2 有正確的讀寫權限。 | ||
`setup.bash` 會試著設定目前使用者的 `UID` 及 `GID`。 | ||
## 執行方式 | ||
@@ -62,2 +90,4 @@ | ||
若發現有連線到 RPC 伺服器但出現警告,是因為 WebUI 有設定 token,預設為 dockerdmhy (可在 `docker-compose.yml` 設定),可以到 **設定>連線設定>密碼令牌** 輸入 | ||
要執行 dmhy 指令可以透過以下方式: | ||
@@ -72,17 +102,2 @@ | ||
docker exec dmhy dmhy ls | ||
``` | ||
## Aria2 設定 | ||
我們使用 [docker-aria2-with-webui](https://github.com/abcminiuser/docker-aria2-with-webui) 作為下載容器。如果要修改相關設定請參考連結說明。 | ||
為相容 MacOS,預設 `file-allocation` 為 `prealloc`,若系統允許可以更改 `data/aria2` 中的設定檔為更高速的 `falloc`。 | ||
## Docker Compose 設定 | ||
可以修改 docker-compose.yml 以進行設定。 | ||
### 重要設定 | ||
請使用 `id` 指令查看自己的 `UID` 和 `GID`,並將 docker-compose.yml 中的 `PUID` 和 `PGID` 分別設定為個人之 `UID` 與 `GID` ,以確保 aria2 有正確的讀寫權限。 |
{ | ||
"name": "dmhy-subscribe", | ||
"version": "0.6.15", | ||
"version": "0.6.16", | ||
"bin": { | ||
@@ -27,20 +27,20 @@ "dmhy": "./bin/cli.js" | ||
"devDependencies": { | ||
"ajv": "^5.5.2", | ||
"all-contributors-cli": "^4.11.2", | ||
"eslint": "^4.19.1", | ||
"eslint-config-google": "^0.9.1", | ||
"ajv": "^6.7.0", | ||
"all-contributors-cli": "^5.11.0", | ||
"eslint": "^5.12.1", | ||
"eslint-config-google": "^0.12.0", | ||
"mocha": "^5.2.0" | ||
}, | ||
"dependencies": { | ||
"aria2": "^3.0.1", | ||
"aria2": "^4.0.3", | ||
"axios": "^0.18.0", | ||
"chalk": "^2.4.1", | ||
"cheerio": "^1.0.0-rc.2", | ||
"chalk": "^2.4.2", | ||
"easy-table": "^1.1.1", | ||
"fs-extra": "^6.0.1", | ||
"js-yaml": "^3.12.0", | ||
"opn": "^5.3.0", | ||
"prompts": "^0.1.14", | ||
"semver": "^5.5.1", | ||
"yargs": "^11.1.0" | ||
"fs-extra": "^7.0.1", | ||
"js-yaml": "^3.12.1", | ||
"opn": "^5.4.0", | ||
"prompts": "^2.0.1", | ||
"rss-parser": "^3.6.2", | ||
"semver": "^5.6.0", | ||
"yargs": "^12.0.5" | ||
}, | ||
@@ -47,0 +47,0 @@ "yargs": { |
@@ -77,3 +77,3 @@ # dmhy-subscribe | ||
如果習慣使用 Docker 或 npm 無法正確安裝,也可以透過 [Docker](https://www.docker.com) 來執行本程式。 | ||
* [Dokcer 安裝與使用教學](docs/docker.md) | ||
* [Docker 安裝與使用教學](docs/docker.md) | ||
@@ -137,4 +137,4 @@ ## Usage 使用方法 | ||
<!-- prettier-ignore --> | ||
| [<img src="https://avatars0.githubusercontent.com/u/5981459?v=4" width="100px;"/><br /><sub><b>Chun-Hao Lien</b></sub>](https://github.com/FlandreDaisuki)<br />[💻](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=FlandreDaisuki "Code") [📖](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=FlandreDaisuki "Documentation") [⚠️](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=FlandreDaisuki "Tests") [👀](#review-FlandreDaisuki "Reviewed Pull Requests") | [<img src="https://avatars1.githubusercontent.com/u/9370547?v=4" width="100px;"/><br /><sub><b>maple</b></sub>](https://blog.maple3142.net/)<br />[💻](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=maple3142 "Code") [📖](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=maple3142 "Documentation") [🤔](#ideas-maple3142 "Ideas, Planning, & Feedback") [🐛](https://github.com/FlandreDaisuki/dmhy-subscribe/issues?q=author%3Amaple3142 "Bug reports") | | ||
| :---: | :---: | | ||
| [<img src="https://avatars0.githubusercontent.com/u/5981459?v=4" width="100px;"/><br /><sub><b>Chun-Hao Lien</b></sub>](https://github.com/FlandreDaisuki)<br />[💻](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=FlandreDaisuki "Code") [📖](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=FlandreDaisuki "Documentation") [⚠️](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=FlandreDaisuki "Tests") [👀](#review-FlandreDaisuki "Reviewed Pull Requests") | [<img src="https://avatars1.githubusercontent.com/u/9370547?v=4" width="100px;"/><br /><sub><b>maple</b></sub>](https://blog.maple3142.net/)<br />[💻](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=maple3142 "Code") [📖](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=maple3142 "Documentation") [🤔](#ideas-maple3142 "Ideas, Planning, & Feedback") [🐛](https://github.com/FlandreDaisuki/dmhy-subscribe/issues?q=author%3Amaple3142 "Bug reports") | [<img src="https://avatars1.githubusercontent.com/u/2549826?v=4" width="100px;"/><br /><sub><b>Ting Shu Lin</b></sub>](http://sudopotato.github.io/)<br />[💻](https://github.com/FlandreDaisuki/dmhy-subscribe/commits?author=wabilin "Code") [🤔](#ideas-wabilin "Ideas, Planning, & Feedback") [📦](#platform-wabilin "Packaging/porting to new platform") | | ||
| :---: | :---: | :---: | | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
@@ -141,0 +141,0 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): |
@@ -1,3 +0,2 @@ | ||
const axios = require('axios'); | ||
const cheerio = require('cheerio'); | ||
const RssParser = require('rss-parser'); | ||
const { Subscription } = require('./dmhy/subscription'); | ||
@@ -7,14 +6,11 @@ const { Thread } = require('./dmhy/thread'); | ||
const parser = new RssParser(); | ||
/** | ||
* @param {string[]} kws | ||
* @return {HTML} axios data | ||
* @return {object} rss | ||
*/ | ||
async function fetchSearchHTML(kws) { | ||
const response = await axios.get( | ||
`https://share.dmhy.org/topics/list?sort_id=2&keyword=${kws.map(encodeURIComponent).join('+')}` | ||
function fetchRssFromKeywords(kws) { | ||
return parser.parseURL( | ||
`https://share.dmhy.org/topics/rss/rss.xml?sort_id=2&keyword=${kws.map(encodeURIComponent).join('+')}` | ||
); | ||
if (response.status !== 200) { | ||
throw new Error(response); | ||
} | ||
return response.data; | ||
} | ||
@@ -49,3 +45,4 @@ | ||
async function fetchThreadLikesByKeywords(kws, ukws = []) { | ||
const threadLikes = parseThreadLikesFromHTML(await fetchSearchHTML(kws)) | ||
const threadLikes = (await fetchRssFromKeywords(kws)).items | ||
.map((item) => ({ title: item.title, link: item.enclosure.url })) | ||
.filter((th) => !ukws.some((ukw) => th.title.includes(ukw))); | ||
@@ -56,43 +53,3 @@ | ||
/** | ||
* | ||
* | ||
* @param {HTML} html | ||
* @return {threadLike[]} threadLikes | ||
*/ | ||
function parseThreadLikesFromHTML(html) { | ||
const $ = cheerio.load(html); | ||
const titles = getTitlesFromCheerio($); | ||
const magnets = getMagnetsFromCheerio($); | ||
if (titles.length !== magnets.length) { | ||
throw new Error('titles.length !== magnets.length'); | ||
} | ||
return titles | ||
.map((title, i) => ({ title, link: magnets[i] })); | ||
} | ||
/** | ||
* @param {cheerio} $ | ||
* @return {string[]} titles | ||
*/ | ||
function getTitlesFromCheerio($) { | ||
return $('#topic_list tr:nth-child(n+1) .title > a') | ||
.text() | ||
.split(/[\n\t]+/) | ||
.filter(Boolean); | ||
} | ||
/** | ||
* @param {cheerio} $ | ||
* @return {string[]} links | ||
*/ | ||
function getMagnetsFromCheerio($) { | ||
return $('#topic_list tr:nth-child(n+1) a.download-arrow') | ||
.toArray() | ||
.map((x) => x.attribs.href); | ||
} | ||
exports.fetchThreads = fetchThreads; | ||
exports.fetchThreadLikesByKeywords = fetchThreadLikesByKeywords; |
85514
0.04%1811
-2.06%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated
Updated
Updated
Updated