Skip to content

Commit

Permalink
v0.2 增加cookie提示
Browse files Browse the repository at this point in the history
  • Loading branch information
Juszoe committed Jul 28, 2019
1 parent 6234904 commit 6d9a7b6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
Flexget插件,增强对NexusPHP的过滤
过滤条件包括种子优惠信息(free等)、做种者情况、下载者情况
- `注意:本插件为测试版,未经过完全的测试`

- [站点支持列表](#site)
# de
s
## 运行环境
- 已安装flexget
- python 3.X
- python 3.X [python2解决方案](#py2)

## 安装插件
1. 下载插件 [nexusphp.py](https://github.com/Juszoe/flexget-nexusphp/releases/download/v0.1/nexusphp.py)
1. 下载插件 [nexusphp.py](https://github.com/Juszoe/flexget-nexusphp/releases)
2. 在Flexget配置文件夹下新建plugins文件夹,例如:
```
~/.flexget/plugins/ # Linux
Expand Down Expand Up @@ -110,3 +112,20 @@ tasks:
min: 20
download: ~/flexget/torrents/
```
## 常见问题
#### 我的python版本是2.X如何使用?
<span id="py2"></span>
本插件只支持python 3.X版本,请卸载flexget后使用python3重装
```bash
pip uninstall flexget # 卸载
pip3 install flexget # 使用pip3安装
```
#### 目前支持哪些站点
<span id="site"></span>
以下站点名使用别称或简称,欢迎反馈更多可用或不可用的站点
1. 任何未修改关键结构的nexusphp站点
2. 铂金家
3. 馒头
4. nice
5. 菠萝
32 changes: 19 additions & 13 deletions nexusphp.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ def consider_entry(_entry, _link):
"For example: other_fields: - link")
futures.append(executor.submit(consider_entry, entry, link))

concurrent.futures.as_completed(futures)
for f in concurrent.futures.as_completed(futures):
exception = f.exception()
if exception:
raise exception

@staticmethod
# 解析页面,获取优惠、做种者信息、下载者信息
Expand Down Expand Up @@ -149,18 +152,17 @@ def get_peers(table):
elif text == '完成':
completed_index = i
else:
tds = tr.find_all('td')
peers.append({
'name': tds[name_index].get_text(),
'connectable': True if tds[connectable_index].get_text() != '是' else False,
'uploaded': tds[uploaded_index].get_text(),
'downloaded': tds[downloaded_index].get_text(),
'completed': float(tds[completed_index].get_text().strip('%')) / 100
# 'completed': tds[7].get_text()
})
tds = tr.find_all('td')
peers.append({
'name': tds[name_index].get_text(),
'connectable': True if tds[connectable_index].get_text() != '是' else False,
'uploaded': tds[uploaded_index].get_text(),
'downloaded': tds[downloaded_index].get_text(),
'completed': float(tds[completed_index].get_text().strip('%')) / 100
})
except IndexError:
pass
except ValueError as e:
except ValueError:
pass
return peers

Expand All @@ -178,9 +180,13 @@ def _get_info(task, link, cookie):
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/75.0.3770.142 Safari/537.36'
}
detail_page = task.requests.get(link, headers=headers) # 详情
detail_page = task.requests.get(link, headers=headers, allow_redirects=False) # 详情
peer_url = link.replace('details.php', 'viewpeerlist.php', 1)
peer_page = task.requests.get(peer_url, headers=headers) # peer详情
peer_page = task.requests.get(peer_url, headers=headers, allow_redirects=False) # peer详情

if detail_page.status_code == 302 or peer_page.status_code == 302:
raise plugin.PluginError("Can't access the site. Your cookie may be wrong!")

return NexusPHP.info_from_page(detail_page, peer_page)


Expand Down

0 comments on commit 6d9a7b6

Please sign in to comment.