Skip to content

Commit

Permalink
🐛 Fix Torrent Feed may fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Mar 13, 2019
1 parent 904a5dd commit 9b20426
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ if no problem or error, You can use `screen` or other software like `supervisor`
| force_judge_dupe_loc | Boolean | False | Judge torrent is dupe or not in location before post it to PT-site. |
| get_clone_id_from_db | Boolean | True | Enable to get clone torrent's id from database first, then search. |
| allow_cat | List | None | Used to limit the reseed torrent category |
| download_torrent | Boolean | False | Download Torrent to temp folder then add to transmission or feed the link |

- class extractors.byrbt.Byrbt(NexusPHP)

Expand Down
11 changes: 10 additions & 1 deletion extractors/base/nexusphp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import re

import requests
from bs4 import BeautifulSoup

from extractors.base.site import Site
Expand Down Expand Up @@ -34,6 +35,7 @@ def __init__(self, status, cookies, passkey, **kwargs):
4. _FORCE_JUDGE_DUPE_LOC : default False, Judge torrent is dupe or not in location before post it to PT-site.
5. _GET_CLONE_ID_FROM_DB : default True, Enable to get clone torrent's id from database first, then search.
6. _ALLOW_CAT : default None, Used to limit the reseed torrent category
7. _DOWNLOAD_TORRENT : default False, Download Torrent to temp folder then add to transmission
"""
self._UPLVER = "yes" if kwargs.setdefault("anonymous_release", True) else "no"
Expand All @@ -42,6 +44,7 @@ def __init__(self, status, cookies, passkey, **kwargs):
self._FORCE_JUDGE_DUPE_LOC = kwargs.setdefault("force_judge_dupe_loc", False)
self._GET_CLONE_ID_FROM_DB = kwargs.setdefault("get_clone_id_from_db", True)
self._ALLOW_CAT = kwargs.setdefault("allow_cat", None)
self._DOWNLOAD_TORRENT = kwargs.setdefault("download_torrent", False)

# -*- Check login's info -*-
def session_check(self):
Expand All @@ -54,7 +57,13 @@ def session_check(self):
return self.status

def torrent_link(self, tid):
return self.url_host + "/download.php?id={tid}&passkey={pk}".format(tid=tid, pk=self.passkey)
torrent_link = self.url_host + "/download.php?id={tid}&passkey={pk}".format(tid=tid, pk=self.passkey)
if self._DOWNLOAD_TORRENT:
tmp_file = "/tmp/[{}].{}.torrent".format(self.name, tid)
with open(tmp_file, "wb") as torrent:
r = requests.get(torrent_link)
torrent.write(r.content)
return tmp_file

# -*- Torrent's download, upload and thank -*-
def torrent_download(self, tid, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions extractors/npubits.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import base64
import re

import requests

from extractors.base.nexusphp import NexusPHP
from utils.constants import ubb_clean, episode_eng2chs
from utils.load.handler import rootLogger as Logger
Expand Down
8 changes: 0 additions & 8 deletions extractors/ourbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ class OurBits(NexusPHP):
url_host = "https://ourbits.club"
db_column = "ourbits.club"

def torrent_link(self, tid):
torrent_link = self.url_host + "/download.php?id={tid}&passkey={pk}".format(tid=tid, pk=self.passkey)
tmp_file = "/tmp/[OurBits].{}.torrent".format(tid)
with open(tmp_file, "wb") as torrent:
r = requests.get(torrent_link)
torrent.write(r.content)
return tmp_file

def exist_torrent_title(self, tag):
torrent_page = self.page_torrent_detail(tid=tag, bs=True)
torrent_title = re.search("\[OurBits\]\.(?P<name>.+?)\.torrent", torrent_page.text).group("name")
Expand Down
8 changes: 0 additions & 8 deletions extractors/tjupt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ def __init__(self, status, cookies, passkey, **kwargs):

super().__init__(status, cookies, passkey, **kwargs)

def torrent_link(self, tid):
torrent_link = self.url_host + "/download.php?id={tid}&passkey={pk}".format(tid=tid, pk=self.passkey)
tmp_file = "/tmp/[TJUPT].{}.torrent".format(tid)
with open(tmp_file, "wb") as torrent:
r = requests.get(torrent_link)
torrent.write(r.content)
return tmp_file

def exist_torrent_title(self, tag):
torrent_file_page = self.page_torrent_info(tid=tag, bs=True)
if re.search("你没有该权限!", torrent_file_page.text):
Expand Down

0 comments on commit 9b20426

Please sign in to comment.