Browse Source
Change Emby notifier to add unofficial support for Jellyfin. Change Filelist torrent provider.tags/release_0.21.27^2
7 changed files with 138 additions and 123 deletions
@ -1,111 +1,110 @@ |
|||||
# coding=utf-8 |
# coding=utf-8 |
||||
# |
# |
||||
# This file is part of SickGear. |
# This file is part of SickGear. |
||||
# |
# |
||||
# SickGear is free software: you can redistribute it and/or modify |
# SickGear is free software: you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation, either version 3 of the License, or |
# the Free Software Foundation, either version 3 of the License, or |
||||
# (at your option) any later version. |
# (at your option) any later version. |
||||
# |
# |
||||
# SickGear is distributed in the hope that it will be useful, |
# SickGear is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
# GNU General Public License for more details. |
||||
# |
# |
||||
# You should have received a copy of the GNU General Public License |
# You should have received a copy of the GNU General Public License |
||||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. |
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. |
||||
|
|
||||
import re |
import re |
||||
import traceback |
import traceback |
||||
|
|
||||
from . import generic |
from . import generic |
||||
from .. import logger |
from .. import logger |
||||
from ..helpers import try_int |
from ..helpers import try_int |
||||
from bs4_parser import BS4Parser |
from bs4_parser import BS4Parser |
||||
|
|
||||
from _23 import unidecode |
from _23 import unidecode |
||||
from six import iteritems |
from six import iteritems |
||||
|
|
||||
|
|
||||
class FLProvider(generic.TorrentProvider): |
class FLProvider(generic.TorrentProvider): |
||||
|
|
||||
def __init__(self): |
def __init__(self): |
||||
generic.TorrentProvider.__init__(self, 'FileList') |
generic.TorrentProvider.__init__(self, 'FileList') |
||||
|
|
||||
self.url_base = 'https://filelist.ro/' |
self.url_base = 'https://filelist.io/' |
||||
self.urls = {'config_provider_home_uri': self.url_base, |
self.urls = {'config_provider_home_uri': self.url_base, |
||||
'login_action': self.url_base + 'login.php', |
'login_action': self.url_base + 'login.php', |
||||
'search': self.url_base + 'browse.php?search=%s&%s&incldead=0'} |
'search': self.url_base + 'browse.php?search=%s&%s&incldead=0'} |
||||
|
|
||||
self.categories = {'Season': [14], 'Episode': [13, 21, 23], 'anime': [24]} |
self.categories = dict(shows=[13, 21, 23, 27], anime=[24]) |
||||
self.categories['Cache'] = self.categories['Season'] + self.categories['Episode'] |
|
||||
|
self.url = self.urls['config_provider_home_uri'] |
||||
self.url = self.urls['config_provider_home_uri'] |
|
||||
|
self.username, self.password, self.minseed, self.minleech = 4 * [None] |
||||
self.username, self.password, self.minseed, self.minleech = 4 * [None] |
|
||||
|
def _authorised(self, **kwargs): |
||||
def _authorised(self, **kwargs): |
|
||||
|
return super(FLProvider, self)._authorised() |
||||
return super(FLProvider, self)._authorised() |
|
||||
|
def _search_provider(self, search_params, **kwargs): |
||||
def _search_provider(self, search_params, **kwargs): |
|
||||
|
results = [] |
||||
results = [] |
if not self._authorised(): |
||||
if not self._authorised(): |
return results |
||||
return results |
|
||||
|
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []} |
||||
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []} |
|
||||
|
rc = dict([(k, re.compile('(?i)' + v)) for (k, v) in iteritems({'info': 'details', 'get': 'download'})]) |
||||
rc = dict([(k, re.compile('(?i)' + v)) for (k, v) in iteritems({'info': 'details', 'get': 'download'})]) |
for mode in search_params: |
||||
for mode in search_params: |
rc['cats'] = re.compile('(?i)cat=(?:%s)' % self._categories_string(mode, template='', delimiter='|')) |
||||
rc['cats'] = re.compile('(?i)cat=(?:%s)' % self._categories_string(mode, template='', delimiter='|')) |
for search_string in search_params[mode]: |
||||
for search_string in search_params[mode]: |
search_string = unidecode(search_string) |
||||
search_string = unidecode(search_string) |
|
||||
|
html = self.get_url(self.urls['search'] % ('+'.join(search_string.split()), |
||||
html = self.get_url(self.urls['search'] % ('+'.join(search_string.split()), |
self._categories_string(mode, template='cats[]=%s'))) |
||||
self._categories_string(mode, template='cats[]=%s'))) |
if self.should_skip(): |
||||
if self.should_skip(): |
return results |
||||
return results |
|
||||
|
cnt = len(items[mode]) |
||||
cnt = len(items[mode]) |
try: |
||||
try: |
if not html or self._has_no_results(html): |
||||
if not html or self._has_no_results(html): |
raise generic.HaltParseException |
||||
raise generic.HaltParseException |
|
||||
|
with BS4Parser(html) as soup: |
||||
with BS4Parser(html) as soup: |
tbl_rows = soup.find_all('div', 'torrentrow') |
||||
tbl_rows = soup.find_all('div', 'torrentrow') |
|
||||
|
if not len(tbl_rows): |
||||
if not len(tbl_rows): |
raise generic.HaltParseException |
||||
raise generic.HaltParseException |
|
||||
|
for tr in tbl_rows: |
||||
for tr in tbl_rows: |
cells = tr.select('span[style*="cell"]') |
||||
cells = tr.select('span[style*="cell"]') |
if 6 > len(cells): |
||||
if 6 > len(cells): |
continue |
||||
continue |
try: |
||||
try: |
seeders, leechers, size = [try_int(n, n) for n in [ |
||||
seeders, leechers, size = [try_int(n, n) for n in [ |
cells[x].get_text().strip() for x in (-3, -2, -5)]] |
||||
cells[x].get_text().strip() for x in (-3, -2, -5)]] |
if not tr.find('a', href=rc['cats']) or self._reject_item(seeders, leechers): |
||||
if not tr.find('a', href=rc['cats']) or self._reject_item(seeders, leechers): |
continue |
||||
continue |
|
||||
|
title = tr.find('a', href=rc['info']).get_text().strip() |
||||
title = tr.find('a', href=rc['info']).get_text().strip() |
download_url = self._link(tr.find('a', href=rc['get'])['href']) |
||||
download_url = self._link(tr.find('a', href=rc['get'])['href']) |
except (AttributeError, TypeError, ValueError, IndexError): |
||||
except (AttributeError, TypeError, ValueError, IndexError): |
continue |
||||
continue |
|
||||
|
if title and download_url: |
||||
if title and download_url: |
items[mode].append((title, download_url, seeders, self._bytesizer(size))) |
||||
items[mode].append((title, download_url, seeders, self._bytesizer(size))) |
|
||||
|
except generic.HaltParseException: |
||||
except generic.HaltParseException: |
pass |
||||
pass |
except (BaseException, Exception): |
||||
except (BaseException, Exception): |
logger.log(u'Failed to parse. Traceback: %s' % traceback.format_exc(), logger.ERROR) |
||||
logger.log(u'Failed to parse. Traceback: %s' % traceback.format_exc(), logger.ERROR) |
|
||||
|
self._log_search(mode, len(items[mode]) - cnt, self.session.response.get('url')) |
||||
self._log_search(mode, len(items[mode]) - cnt, self.session.response.get('url')) |
|
||||
|
results = self._sort_seeding(mode, results + items[mode]) |
||||
results = self._sort_seeding(mode, results + items[mode]) |
|
||||
|
return results |
||||
return results |
|
||||
|
|
||||
|
provider = FLProvider() |
||||
provider = FLProvider() |
|
||||
|
Loading…
Reference in new issue