-
Notifications
You must be signed in to change notification settings - Fork 276
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
Feature/fix behondhd #7323
Merged
Merged
Feature/fix behondhd #7323
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f66383e
Add cookies auth to behondhd
p0psicles 62ee8b3
Fix parsing.
p0psicles a154b61
Resolve flake issues
p0psicles 35b9db4
Make sure both modern and classic themes work.
p0psicles 27ae08c
Added changelog
p0psicles af97407
Update CHANGELOG.md
medariox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,9 @@ def __init__(self): | |
"""Initialize the class.""" | ||
super(BeyondHDProvider, self).__init__('Beyond-HD') | ||
|
||
self.username = None | ||
self.password = None | ||
self.enable_cookies = True | ||
self.cookies = '' | ||
self.required_cookies = ('remember_web_[**long_hash**]',) | ||
|
||
self.url = 'https://beyond-hd.me' | ||
self.urls = { | ||
|
@@ -99,7 +100,7 @@ def parse(self, data, mode): | |
items = [] | ||
|
||
with BS4Parser(data, 'html5lib') as html: | ||
torrent_table = html.find('table', class_='table-striped') | ||
torrent_table = html.find('div', class_='table-torrents').find('table') | ||
torrent_rows = torrent_table('tr') if torrent_table else [] | ||
|
||
# Continue only if one release is found | ||
|
@@ -111,14 +112,17 @@ def parse(self, data, mode): | |
cells = result('td') | ||
|
||
try: | ||
link = cells[1].find('div') | ||
if len(cells) < 2: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an hidden tr at the end with one td. |
||
continue | ||
|
||
link = cells[1].find('a') | ||
download_url = urljoin(self.url, cells[2].find('a')['href']) | ||
title = link.get_text(strip=True) | ||
if not all([title, download_url]): | ||
continue | ||
|
||
seeders = int(cells[5].find('span').get_text()) | ||
leechers = int(cells[6].find('span').get_text()) | ||
seeders = int(cells[6].find('span').get_text()) | ||
leechers = int(cells[7].find('span').get_text()) | ||
|
||
# Filter unseeded torrent | ||
if seeders < self.minseed: | ||
|
@@ -128,10 +132,10 @@ def parse(self, data, mode): | |
title, seeders) | ||
continue | ||
|
||
torrent_size = cells[4].find('span').get_text() | ||
torrent_size = cells[5].find('span').get_text() | ||
size = convert_size(torrent_size, units=units) or -1 | ||
|
||
pubdate_raw = cells[3].find('span').get_text() | ||
pubdate_raw = cells[4].find('span').get_text() | ||
pubdate = self.parse_pubdate(pubdate_raw, human_time=True) | ||
|
||
item = { | ||
|
@@ -154,33 +158,16 @@ def parse(self, data, mode): | |
|
||
def login(self): | ||
"""Login method used for logging in before doing search and torrent downloads.""" | ||
if any(dict_from_cookiejar(self.session.cookies).values()): | ||
return True | ||
|
||
if 'pass' in dict_from_cookiejar(self.session.cookies): | ||
return True | ||
return self.cookie_login('Login now') | ||
|
||
login_html = self.session.get(self.urls['login']) | ||
with BS4Parser(login_html.text, 'html5lib') as html: | ||
token = html.find('input', attrs={'name': '_token'}).get('value') | ||
|
||
login_params = { | ||
'_token': token, | ||
'username': self.username, | ||
'password': self.password, | ||
'remember': 'on', | ||
} | ||
|
||
response = self.session.post(self.urls['login'], data=login_params) | ||
if not response or not response.text: | ||
log.warning('Unable to connect to provider') | ||
return False | ||
|
||
if 'These credentials do not match our records.' in response.text: | ||
log.warning('Invalid username or password. Check your settings') | ||
return False | ||
def check_required_cookies(self): | ||
""" | ||
Check if we have the required cookies in the requests sessions object. | ||
|
||
return True | ||
Meaning that we've already successfully authenticated once, and we don't need to go through this again. | ||
Note! This doesn't mean the cookies are correct! | ||
""" | ||
return False | ||
|
||
|
||
provider = BeyondHDProvider() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now beyond-hd is the only one with a cookie name like: remember_web_59ba36addc2b2f9401580f01445acd8ea4e30af9d. So I had to make an exception for this provider.