Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from lushdog:master #1

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
9e60254
'test'
Sep 27, 2019
8a765c1
'test.'
Sep 27, 2019
02e8abe
schedule
lushdog Sep 27, 2019
d94aea5
rm log
lushdog Sep 27, 2019
c7f1ab4
log
lushdog Sep 27, 2019
a5616e5
fix
lushdog Sep 27, 2019
3e1960e
fix time
lushdog Sep 27, 2019
6fe7425
fix time
lushdog Sep 27, 2019
16a22fa
fix size
lushdog Sep 29, 2019
4973b3f
add rule
lushdog Sep 29, 2019
758212c
add rule.
lushdog Sep 29, 2019
0025ff5
fix size
lushdog Sep 29, 2019
06273d1
readme
lushdog Oct 11, 2019
822793f
GoldenPopcorn
lushdog Oct 16, 2019
86076ec
fetch all page
lushdog Oct 17, 2019
8cc74bc
all torrent
lushdog Oct 17, 2019
1fea8a0
Update README.md
lushdog Oct 23, 2019
622c169
Update README.md
lushdog Oct 23, 2019
0fb7607
Update README.md
lushdog Oct 23, 2019
7fa5571
chinese readme
lushdog Oct 24, 2019
782dece
chinese readme
lushdog Oct 24, 2019
6d1cf43
edit chinese readme
lushdog Oct 24, 2019
7fbe4e9
link chinese readme
lushdog Oct 24, 2019
d526eee
link chinese readme
lushdog Oct 24, 2019
7a6ece9
时间问题
lushdog Oct 28, 2019
4c45c21
fix time
lushdog Oct 28, 2019
086f85d
fix
lushdog Oct 28, 2019
677e052
url
lushdog Nov 1, 2019
b615438
条件
lushdog Dec 10, 2019
f2a60ff
分页
lushdog Apr 20, 2020
83d2c23
maxsize
lushdog Aug 21, 2020
9a33bee
Bump node-fetch from 2.6.0 to 2.6.1
dependabot[bot] Sep 12, 2020
117a381
Merge pull request #1 from lushdog/dependabot/npm_and_yarn/node-fetch…
lushdog Oct 9, 2020
39862c6
Update index.js
lushdog Oct 13, 2020
3f126bb
Update index.js
lushdog Oct 14, 2020
3d10907
Update index.js
lushdog Oct 19, 2020
37a112b
Update index.js
lushdog Oct 19, 2020
773eaa1
金种默认为false
lushdog Jan 13, 2021
e53cb1d
docker
lushdog Jan 26, 2021
57949d8
readme
lushdog Jan 26, 2021
626eb2e
readme
lushdog Jan 26, 2021
71b627f
Merge branch 'dev-docker'
lushdog Jan 26, 2021
82fba1c
CACHED
lushdog Feb 19, 2021
131b446
Update Dockerfile
lushdog Apr 1, 2021
cc705ff
Update README.zh-CN.md
lushdog Apr 21, 2021
02f83a5
Update README.zh-CN.md
lushdog Jun 8, 2021
3ef4e69
upgrade node-schedule
lushdog May 5, 2022
6f544bd
Bump luxon from 1.28.0 to 1.28.1
dependabot[bot] Jan 10, 2023
7b96c5b
Merge pull request #5 from lushdog/dependabot/npm_and_yarn/luxon-1.28.1
lushdog Mar 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ config.json
node_modules/
data/*
!data/.gitkeep
test.js
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:14.15.4-slim

ENV NODE_ENV=production
ENV RUN_ENV=docker

WORKDIR /app

COPY package.json yarn.lock ./

RUN yarn install

COPY . .

CMD ["node", "index.js"]
20 changes: 20 additions & 0 deletions README.docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 使用docker运行

首先新建配置文件config.json, 将example.config.json模版的配置复制进去然后修改
### 运行
`yourconfig`是配置文件的路径,`yourwatch`是下载软件监控文件夹

```bash
docker run --name ptpfl -d -v /yourconfig:/config -v /yourwatch:/watch trancelife/ptpfl
```

### 进入容器

```bash
docker exec -it ptpfl /bin/sh
```
### 查看日志

```bash
docker logs ptpfl -f
```
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
## [中文](https://github.com/lushdog/ptpfl/blob/master/README.zh-CN.md)
## [Docker运行](https://github.com/lushdog/ptpfl/blob/master/README.docker.md)

# PassThePopcorn Freeleech Automator

A node.js script that automates the downloading of PassThePopcorn freeleech torrents.

### To install

`npm install pm2 -g`

`npm install`

Copy `example.config.json` to `config.json` and fill in your apiUser and apiKey credentials from your user profile.
Expand All @@ -12,7 +17,11 @@ Add a `downloadPath` to `config.json` to have the torrents added to your torrent

### To run

`npm start`
`pm2 start index.js`

### Log

`pm2 log index`

### Discord notifications

Expand All @@ -34,7 +43,14 @@ Configuration options with defaults shown
"maxsize": -1, // Maximum size in megabytes. Set to -1 for unlimited.
"maxAge": -1, // Maximum time in minutes since torrent was uploaded. See below note.
"downloadPath": "", // Path to download .torrent files to. Optional.
"discordWebhookUrl": "" // Discord webhook URI. Optional.
"discordWebhookUrl": "", // Discord webhook URI. Optional.
"interval": 15,// Download interval.
"GoldenPopcorn": true, // Download all GoldenPopcorn.
"page": 1, // page
"matchByAgeAndMaxSeeders": [
{ "maxAge": 600, "maxSeeders": 5 },
{ "maxAge": 1200, "maxSeeders": 2 }
] // For new Freeleeh which uploaded some time ago but had a few seeders.
}
```

Expand Down
79 changes: 79 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# PTP免费种子下载

一个自动下载ptp免费种子的nodejs程序.

### 安装

依赖nodejs环境, 推荐使用nvm安装。

`wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash`

`source .profile`

然后安装nodejs

`nvm install stable`

安装pm2

`npm install pm2 -g`

下载代码

`git clone https://github.com/lushdog/ptpfl.git`

进入到ptpfl目录下, 安装依赖

`npm install`

修改配置文件: 复制`example.config.json`为`config.json`, 填上你的apiUser和apiKey(ptp网站edit-security)

### 运行(ptpfl目录下)

`pm2 start index.js --name "myapp"`

### 查看日志

`pm2 log myapp`

### 暂停

`pm2 stop myapp`

### 重启

`pm2 restart myapp`

### Discord 通知

需要在下载种子时收到通知的可以填上discordWebhookUrl, discord使用方法可以google

### 配置说明

```javascript
{
"apiUser": "", // apiUser.
"apiKey": "", // apiKey.
"minseeders": -1, // 最少做种数. -1表示无限制.
"maxseeders": -1, // 最大做种数. -1表示无限制.
"minleechers": -1, // 最少下载数. -1表示无限制.
"maxleechers": -1, // 最大下载数. -1表示无限制.
"minsize": -1, // 种子最小大小(单位mb). -1表示无限制.
"maxsize": -1, // 种子最大大小(单位mb). -1表示无限制.
"maxAge": -1, // 种子上传最大时间(单位分钟).
"downloadPath": "/watch", // 下载软件的监控文件夹路径,种子文件下载到这里.(如果用docker启动请填'/watch')
"discordWebhookUrl": "", // Discord机器人url, 可选.
"interval": 15,// 运行间隔时间. 实测一个小时超过20次管理员有可能会发私信要求调整!!,所以不要设置低于3.
"GoldenPopcorn": true, // 是否下载金种(会忽略所有其他条件).
"page": 1, // 爬的页数,50个种子为一页,有时候免费种子会超过一页。 爬取多页会重复调用ptp的api. 实测一个小时调用超过20次管理员有可能会发私信要求调整
"matchByAgeAndMaxSeeders": [
{ "maxAge": 600, "maxSeeders": 5 },
{ "maxAge": 1200, "maxSeeders": 2 }
] // 见 上传时间和做种人数组合筛选
}
```

#### 上传时间和做种人数组合筛选

根据上传时间和做种人数组合筛选,因为有很多很老的种子加为免费种,做种人数很少,也有刷的价值。上边例子的过滤为: 上传10个小时以内,做种小于5; 上传20个小时以内, 做种小于5; 可以根据自己情况调整。

9 changes: 8 additions & 1 deletion example.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@
"maxSize": -1,
"maxAge": -1,
"downloadPath": "",
"discordWebhookUrl": ""
"discordWebhookUrl": "",
"interval": 10,
"GoldenPopcorn": false,
"page": 1,
"matchByAgeAndMaxSeeders": [
{ "maxAge": 600, "maxSeeders": 5 },
{ "maxAge": 1200, "maxSeeders": 2 }
]
}
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
require('./src')();
const app = require('./src')
const schedule = require('node-schedule')
const RUN_ENV = process.env.RUN_ENV
const interval = require(RUN_ENV === 'docker' ? '/config/config.json' : './config.json').interval

let index = 1
const scheduleJob = async () => {
console.log(index)
index ++
await app()
}

schedule.scheduleJob(`*/${interval} * * * *`, scheduleJob)
90 changes: 0 additions & 90 deletions package-lock.json

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
"author": "",
"license": "ISC",
"dependencies": {
"dayjs": "^1.8.16",
"directory-exists": "^2.0.1",
"discord.js": "^11.5.1",
"import-fresh": "^3.1.0",
"node-fetch": "^2.6.0"
"node-fetch": "^2.6.0",
"node-schedule": "^2.1.0"
}
}
16 changes: 13 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ const { validateConfig, fetchTorrents, torrentMatchesFilters, writeTorrentCache

module.exports = async function() {
try {
const config = await validateConfig(),
{ torrents, authKey, passKey } = await fetchTorrents(config.apiUser, config.apiKey);

const config = await validateConfig()
const { page } = config
const { torrents, authKey, passKey, totalResults } = await fetchTorrents(config.apiUser, config.apiKey);
let pageNum = Math.ceil(totalResults/50)
if (page !== -1) {
pageNum = page
}
if (pageNum >= 2) {
for (let index = 2; index <= pageNum; index++) {
const result = await fetchTorrents(config.apiUser, config.apiKey, index);
torrents.push(...result.torrents);
}
}
for (const torrent of torrents) {
if (torrentMatchesFilters(torrent, config)) {
await downloadTorrent({ torrent, authKey, passKey }, config);
Expand Down
Loading