Skip to content

Commit

Permalink
v0.2.1 修复下标bug,增强稳定性
Browse files Browse the repository at this point in the history
  • Loading branch information
Juszoe committed Jul 29, 2019
1 parent 5897578 commit 679503f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Flexget插件,增强对NexusPHP的过滤
过滤条件包括种子优惠信息(free等)、做种者情况、下载者情况
- `注意:本插件为测试版,未经过完全的测试`
- 开启二级验证将无法使用,自行斟酌取舍,未来版本将完善
- [站点支持列表](#site)

## 运行环境
Expand Down Expand Up @@ -128,3 +129,5 @@ pip3 install flexget # 使用pip3安装
3. 馒头
4. nice
5. 菠萝
6. OurB***s
7. 天空
18 changes: 14 additions & 4 deletions nexusphp.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ def consider_entry(_entry, _link):
_entry.reject('%d is out of range of leecher' % len(leechers)) # 下载人数不匹配
return

max_complete = max(leechers, key=lambda x: x['completed'])['completed']
if len(leechers) != 0:
max_complete = max(leechers, key=lambda x: x['completed'])['completed']
else:
max_complete = 0
if max_complete > config['leechers']['max_complete']:
_entry.reject('%f is more than max_complete' % max_complete) # 最大完成度不匹配
return
Expand All @@ -107,7 +110,7 @@ def consider_entry(_entry, _link):

for f in concurrent.futures.as_completed(futures):
exception = f.exception()
if exception:
if isinstance(exception, plugin.PluginError):
raise exception

@staticmethod
Expand Down Expand Up @@ -168,15 +171,22 @@ def get_peers(table):

soup = get_soup(peer_page.content)
tables = soup.find_all('table', limit=2)
seeders = get_peers(tables[0])
leechers = get_peers(tables[1])
try:
seeders = get_peers(tables[0])
except IndexError:
seeders = []
try:
leechers = get_peers(tables[1])
except IndexError:
leechers = []

return discount, seeders, leechers

@staticmethod
def _get_info(task, link, cookie):
headers = {
'cookie': cookie,
'accept-encoding': 'gzip, deflate',
'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'
}
Expand Down

0 comments on commit 679503f

Please sign in to comment.