Private GIT

Skip to content
Snippets Groups Projects
Commit 39c5dc61 authored by Yoann Laissus's avatar Yoann Laissus Committed by miigotu
Browse files

Update the YggTorrent provider due to the new version of the website

parent 7f82bb14
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ class YggTorrentProvider(TorrentProvider): # pylint: disable=too-many-instance-
self.minleech = None
# URLs
self.url = 'https://yggtorrent.com/'
self.url = 'https://yggtorrent.is/'
self.urls = {
'login': urljoin(self.url, 'user/login'),
'search': urljoin(self.url, 'engine/search')
......@@ -69,16 +69,25 @@ class YggTorrentProvider(TorrentProvider): # pylint: disable=too-many-instance-
'pass': self.password,
}
response = self.get_url(self.urls['login'], post_data=login_params, returns='text')
if not response: # When you call /login if it's OK, it's return 200 with no body, i retry in main if it's logged !
response = self.get_url(self.url, returns='text')
if not response: # The provider is dead !!!
logger.log('Unable to connect to provider', logger.WARNING)
response = self.get_url(self.urls['login'], post_data=login_params, returns='response')
# The login is now an AJAX call (401 : Bad credentials, 200 : Logged in, other : server failure)
if response.status_code == 401:
logger.log('Invalid username or password. Check your settings', logger.WARNING)
return False
elif response.status_code == 200:
# It seems we are logged, let's verify that !
response = self.get_url(self.url, returns='response')
if 'logout' not in response:
if response.status_code != 200:
logger.log('Unable to connect to provider', logger.WARNING)
return False
if 'logout' not in response.text:
logger.log('Invalid username or password. Check your settings', logger.WARNING)
return False
else:
logger.log('Unable to connect to provider', logger.WARNING)
return False
return True
......@@ -112,15 +121,16 @@ class YggTorrentProvider(TorrentProvider): # pylint: disable=too-many-instance-
try:
search_params = {
'category': "2145",
'subcategory' : "2184",
'q': re.sub(r'[()]', '', search_string)
'sub_category' : "2184",
'name': re.sub(r'[()]', '', search_string),
'do': 'search'
}
data = self.get_url(self.urls['search'], params=search_params, returns='text')
if not data:
continue
with BS4Parser(data, 'html5lib') as html:
torrent_table = html.find(class_='table table-striped')
torrent_table = html.find(class_='table')
torrent_rows = torrent_table('tr') if torrent_table else []
# Continue only if at least one Release is found
......@@ -131,23 +141,20 @@ class YggTorrentProvider(TorrentProvider): # pylint: disable=too-many-instance-
# Skip column headers
for result in torrent_rows[1:]:
cells = result('td')
if len(cells) < 5:
if len(cells) < 9:
continue
download_url = ""
title = cells[0].find('a', class_='torrent-name').get_text(strip=True)
for download_img in cells[0].select('a[href] img'):
if download_img['src'] == urljoin(self.url,"static/icons/icon_download.gif"):
download_url = urljoin(self.url, download_img.parent['href'])
break
title = cells[1].find('a').get_text(strip=True)
id = cells[2].find('a')['target']
download_url = urljoin(self.url, 'engine/download_torrent?id=' + id)
if not (title and download_url):
continue
seeders = try_int(cells[4].get_text(strip=True))
leechers = try_int(cells[5].get_text(strip=True))
seeders = try_int(cells[7].get_text(strip=True))
leechers = try_int(cells[8].get_text(strip=True))
torrent_size = cells[2].get_text()
torrent_size = cells[5].get_text()
size = convert_size(torrent_size) or -1
# Filter unseeded torrent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment