Commit 472da49f authored by echel0n's avatar echel0n

Merge branch 'release/9.1.72'

parents be351589 15e1861e
# Changelog
- * 33de5b6 - 2017-11-10: Release v9.1.70
- * fd3f998 - 2017-11-12: Release v9.1.72
- * 47880bb - 2017-11-12: Hard-coded SiCKRAGE API url into app as a variable
- * c98575b - 2017-11-11: Disabled external caching of private search provider results
- * c5c2b4a - 2017-11-11: Revert "Revert "Added feature that stores and retrieves provider cache results from sickrage's cache server""
- * 9575d5f - 2017-11-11: Revert "Added feature that stores and retrieves provider cache results from sickrage's cache server"
- * b024c05 - 2017-11-11: Added feature that stores and retrieves provider cache results from sickrage's cache server
- * f380f9b - 2017-11-11: Added web session hook to log urls and post data
- * 810662e - 2017-11-11: Added web session hook to log urls and post data
- * 342df0e - 2017-11-11: refactored providers
- * aa6d45f - 2017-11-11: Added YGG torrent provider
- * 846f1d5 - 2017-11-11: Added YGG torrent provider
- * 7c3be4f - 2017-11-11: Added YGG torrent provider
- * f2a792d - 2017-11-11: Added Subscene subtitle provider
- * 27d1a59 - 2017-11-11: Added Wizdom subtitle provider Added NapiProjekt subtitle provider
- * 253be31 - 2017-11-11: Added Wizdom subtitle provider Added NapiProjekt subtitle provider
- * 660e69d - 2017-11-10: Fixed issue #119 - Add custom search provider: expected string or buffer
- * 0b32673 - 2017-11-10: Unidecode Newpct titles to avoid unicode issues during name parsing Refactored TNTVillage torrent provider Refactored regular regexes
- * 1c854a2 - 2017-11-10: Fixed search issue with Newpct torrent provider Added subtitles category to Newpct torrent provider Quality of Newpct releases determined from title and url now
- * 022e4f9 - 2017-11-10: Fixed unicode decode issues for EliteTorrent provider
- * 24e1037 - 2017-11-10: Release v9.1.70
- * 9498449 - 2017-11-10: Fixed typo in code for daily searcher
- * b26010a - 2017-11-09: Release v9.1.69
- * e0c1882 - 2017-11-09: Fixed typo for server status template
......
......@@ -94,6 +94,7 @@ class Core(object):
self.newest_version = None
self.newest_version_string = None
self.api_url = 'https://api.sickrage.ca'
self.user_agent = 'SiCKRAGE.CE.1/({};{};{})'.format(platform.system(), platform.release(), str(uuid.uuid1()))
self.sys_encoding = get_sys_encoding()
self.languages = [language for language in os.listdir(sickrage.LOCALE_DIR) if '_' in language]
......
......@@ -19,6 +19,7 @@
from __future__ import unicode_literals
import datetime
import json
import time
import urllib2
......@@ -217,8 +218,7 @@ class TVCache(object):
# get version
version = parse_result.version
# add to DB
sickrage.app.cache_db.db.insert({
dbData = {
'_t': 'providers',
'provider': self.providerID,
'name': name,
......@@ -233,22 +233,42 @@ class TVCache(object):
'seeders': seeders,
'leechers': leechers,
'size': size,
'files': files
})
'files': json.dumps(files)
}
# add to internal database
sickrage.app.cache_db.db.insert(dbData)
# add to external database
if not self.provider.private:
headers = {'content-type': 'application/json',
'x-authorization': sickrage.app.config.api_key}
sickrage.app.wsession.post(sickrage.app.api_url + '/provider_cache/',
data=json.dumps(dbData), headers=headers)
sickrage.app.log.debug("SEARCH RESULT:[%s] ADDED TO CACHE!", name)
def search_cache(self, episode=None, manualSearch=False, downCurQuality=False):
def search_cache(self, ep_obj=None, manualSearch=False, downCurQuality=False):
neededEps = {}
dbData = []
if not episode:
dbData = [x['doc'] for x in
sickrage.app.cache_db.db.get_many('providers', self.providerID, with_doc=True)]
else:
dbData = [x['doc'] for x in sickrage.app.cache_db.db.get_many('providers', self.providerID, with_doc=True)
if x['doc']['indexerid'] == episode.show.indexerid
and x['doc']['season'] == episode.season
and "|" + str(episode.episode) + "|" in x['doc']['episodes']]
# get data from external database
if not self.provider.private:
try:
headers = {'content-type': 'application/json',
'x-authorization': sickrage.app.config.api_key}
dbData += sickrage.app.wsession.get(sickrage.app.api_url + '/provider_cache/',
params={'provider': self.providerID}, headers=headers).json()
except Exception:
pass
# get data from internal database
dbData += [x['doc'] for x in sickrage.app.cache_db.db.get_many('providers', self.providerID, with_doc=True)]
dbData = [x for x in dbData if x['indexerid'] == ep_obj.show.indexerid and x['season'] == ep_obj.season
and "|" + str(ep_obj.episode) + "|" in x['episodes']] if ep_obj else dbData
# for each cache entry
for curResult in dbData:
......@@ -302,7 +322,7 @@ class TVCache(object):
result.seeders = curResult.get("seeders", -1)
result.leechers = curResult.get("leechers", -1)
result.size = curResult.get("size", -1)
result.files = curResult.get("files", {})
result.files = json.loads(curResult.get("files", {}))
result.content = None
# add it to the list
......
......@@ -37,7 +37,7 @@ from configobj import ConfigObj
import sickrage
from sickrage.core.common import SD, WANTED, SKIPPED, Quality
from sickrage.core.helpers import backupVersionedFile, makeDir, generateCookieSecret, auto_type, get_lan_ip, \
extract_zipfile, try_int, checkbox_to_value
extract_zipfile, try_int, checkbox_to_value, generateApiKey
class Config(object):
......@@ -702,7 +702,7 @@ class Config(object):
'web_use_gzip': True,
'dailysearch_frequency': 40,
'ignore_words': 'german,french,core2hd,dutch,swedish,reenc,MrLss',
'api_key': '',
'api_key': generateApiKey(),
'check_propers_interval': 'daily',
'nzb_method': 'blackhole',
'web_cookie_secret': generateCookieSecret(),
......
......@@ -181,14 +181,17 @@ class srDatabase(object):
previous_version = self.db.indexes_names[index_name]._version
current_version = self._indexes[index_name]._version
# Only edit index if versions are different
if previous_version < current_version:
self.db.destroy_index(self.db.indexes_names[index_name])
self.db.add_index(self._indexes[index_name](self.db.path, index_name))
self.db.reindex_index(index_name)
self.check_versions(index_name, current_version, previous_version)
except:
sickrage.app.log.debug('Failed adding index {}'.format(index_name))
def check_versions(self, index_name, current_version, previous_version):
# Only edit index if versions are different
if previous_version < current_version:
self.db.destroy_index(self.db.indexes_names[index_name])
self.db.add_index(self._indexes[index_name](self.db.path, index_name))
self.db.reindex_index(index_name)
def close(self):
self.db.close()
......
......@@ -49,3 +49,10 @@ class CacheDB(srDatabase):
def __init__(self, name='cache'):
super(CacheDB, self).__init__(name)
self.old_db_path = os.path.join(sickrage.app.data_dir, 'cache.db')
def check_versions(self, index_name, current_version, previous_version):
# Wipe table if versions are different
if previous_version < current_version:
for x in self.db.all(index_name, with_doc=True):
self.db.delete(x['doc'])
super(CacheDB, self).check_versions(index_name, current_version, previous_version)
......@@ -114,7 +114,7 @@ class CacheSceneExceptionsRefreshIndex(HashIndex):
class CacheProvidersIndex(HashIndex):
_version = 2
_version = 3
def __init__(self, *args, **kwargs):
kwargs['key_format'] = '32s'
......
......@@ -39,3 +39,10 @@ class FailedDB(srDatabase):
def __init__(self, name='failed'):
super(FailedDB, self).__init__(name)
self.old_db_path = os.path.join(sickrage.app.data_dir, 'failed.db')
def check_versions(self, index_name, current_version, previous_version):
# Wipe table if versions are different
if previous_version < current_version:
for x in self.db.all(index_name, with_doc=True):
self.db.delete(x['doc'])
super(FailedDB, self).check_versions(index_name, current_version, previous_version)
\ No newline at end of file
......@@ -27,8 +27,8 @@ normal_regexes = [
# Show Name - S01E02 - S01E03 - S01E04 - Ep Name
r'''
^(?P<series_name>.+?)[. _-]+ # Show_Name and separator
s(?P<season_num>\d+)[. _-]* # S01 and optional separator
e(?P<ep_num>\d+) # E02 and separator
[Ss](?P<season_num>\d+)[. _-]* # S01 and optional separator
[Ee](?P<ep_num>\d+) # E02 and separator
([. _-]+s(?P=season_num)[. _-]* # S01 and optional separator
e(?P<extra_ep_num>\d+))+ # E03/etc and separator
[. _-]*((?P<extra_info>.+?) # Source_Quality_Etc-
......@@ -57,9 +57,9 @@ normal_regexes = [
# Show.Name.S01.E02.E03
r'''
^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator
\(?s(?P<season_num>\d+)[. _-]* # S01 and optional separator
e(?P<ep_num>\d+)\)? # E02 and separator
(([. _-]*e|-) # linking e/- char
\(?[Ss](?P<season_num>\d+)[. _-]* # S01 and optional separator
[Ee](?P<ep_num>\d+)\)? # E02 and separator
(([. _-]*[Ee]|-) # linking e/- char
(?P<extra_ep_num>(?!(1080|720|480)[pi])\d+)(\))?)* # additional E03/etc
([. _,-]+((?P<extra_info>.+?) # Source_Quality_Etc-
((?<![. _-])(?<!WEB) # Make sure this is really the release group
......@@ -145,7 +145,7 @@ normal_regexes = [
# Show.Name.S01.Source.Quality.Etc-Group
r'''
^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator
s(eason[. _-])? # S01/Season 01
[Ss](eason[. _-])? # S01/Season 01
(?P<season_num>\d+)[. _-]* # S01 and optional separator
[. _-]*((?P<extra_info>.+?) # Source_Quality_Etc-
((?<![. _-])(?<!WEB) # Make sure this is really the release group
......@@ -156,7 +156,7 @@ normal_regexes = [
# Show.Name.E02.2010
r'''
^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator
(e(p(isode)?)?|part|pt)[. _-]? # e, ep, episode, or part
([Ee](p(isode)?)?|part|pt)[. _-]? # e, ep, episode, or part
(?P<ep_num>(\d+|(?<!e)[ivx]+)) # first ep num
((([. _-]+(and|&|to)[. _-]+)|-) # and/&/to joiner
(?P<extra_ep_num>(?!(1080|720|480)[pi])(\d+|(?<!e)[ivx]+))[. _-]) # second ep num
......@@ -170,10 +170,10 @@ normal_regexes = [
# Show.Name.Part.1.and.Part.2.Blah-Group
r'''
^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator
(e(p(isode)?)?|part|pt)[. _-]? # e, ep, episode, or part
([Ee](p(isode)?)?|part|pt)[. _-]? # e, ep, episode, or part
(?P<ep_num>(\d+|((?<!e)[ivx]+(?=[. _-])))) # first ep num
([. _-]+((and|&|to)[. _-]+)? # and/&/to joiner
((e(p(isode)?)?|part|pt)[. _-]?) # e, ep, episode, or part
(([Ee](p(isode)?)?|part|pt)[. _-]?) # e, ep, episode, or part
(?P<extra_ep_num>(?!(1080|720|480)[pi])
(\d+|((?<!e)[ivx]+(?=[. _-]))))[. _-])* # second ep num
([. _-]*(?P<extra_info>.+?) # Source_Quality_Etc-
......@@ -353,8 +353,8 @@ anime_regexes = [
# Show Name - S01E02-03
r'''
^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator
(\()?s(?P<season_num>\d+)[. _-]* # S01 and optional separator
e(?P<ep_num>\d+)(\))? # E02 and separator
(\()?[Ss](?P<season_num>\d+)[. _-]* # S01 and optional separator
[Ee](?P<ep_num>\d+)(\))? # E02 and separator
(([. _-]*e|-) # linking e/- char
(?P<extra_ep_num>(?!(1080|720|480)[pi])\d+)(\))?)* # additional E03/etc
([. _-]+((?P<extra_info>.+?))? # Source_Quality_Etc-
......@@ -367,8 +367,8 @@ anime_regexes = [
# Bleach s16e03e04 313-314
r'''
^(?P<series_name>.+?)[ ._-]+ # start of string and series name and non optinal separator
[sS](?P<season_num>\d+)[. _-]* # S01 and optional separator
[eE](?P<ep_num>\d+) # epipisode E02
[Ss](?P<season_num>\d+)[. _-]* # S01 and optional separator
[Ee](?P<ep_num>\d+) # epipisode E02
(([. _-]*e|-) # linking e/- char
(?P<extra_ep_num>\d+))* # additional E03/etc
([ ._-]{2,}|[ ._]+) # if "-" is used to separate at least something else has to be there(->{2,}) "s16e03-04-313-314" would make sens any way
......@@ -414,8 +414,8 @@ anime_regexes = [
(-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # "-" as separator and anditional absolute number, all optinal
(v(?P<version>[0-9]))?[ ._-]+ # the version e.g. "v2"
(?P<series_name>.+?)[ ._-]+
[sS](?P<season_num>\d+)[. _-]* # S01 and optional separator
[eE](?P<ep_num>\d+)
[Se](?P<season_num>\d+)[. _-]* # S01 and optional separator
[Ee](?P<ep_num>\d+)
(([. _-]*e|-) # linking e/- char
(?P<extra_ep_num>\d+))* # additional E03/etc
.*?
......
......@@ -28,7 +28,7 @@ from tornado.httpserver import HTTPServer
from tornado.web import Application, RedirectHandler, StaticFileHandler
import sickrage
from sickrage.core.helpers import create_https_certificates, generateApiKey, launch_browser
from sickrage.core.helpers import create_https_certificates, launch_browser
from sickrage.core.webserver.api import ApiHandler, KeyHandler
from sickrage.core.webserver.routes import Route
from sickrage.core.webserver.views import CalendarHandler, LoginHandler, LogoutHandler
......@@ -79,8 +79,6 @@ class WebServer(threading.Thread):
'/' + sickrage.app.config.web_root.lstrip('/').strip('/'))
# api root
if not sickrage.app.config.api_key:
sickrage.app.config.api_key = generateApiKey()
self.api_root = r'%s/api/%s' % (sickrage.app.config.web_root, sickrage.app.config.api_key)
# tornado setup
......
......@@ -4290,7 +4290,7 @@ class ConfigProviders(Config):
def canAddNewznabProvider(name):
if not name: return json_encode({'error': 'No Provider Name specified'})
providerObj = NewznabProvider(name, '', True)
providerObj = NewznabProvider(name, '')
if providerObj.id not in sickrage.app.search_providers.newznab():
return json_encode({'success': providerObj.id})
return json_encode({'error': 'Provider Name already exists as ' + name})
......@@ -4299,7 +4299,7 @@ class ConfigProviders(Config):
def canAddTorrentRssProvider(name, url, cookies, titleTAG):
if not name: return json_encode({'error': 'No Provider Name specified'})
providerObj = TorrentRssProvider(name, url, True, cookies, titleTAG)
providerObj = TorrentRssProvider(name, url, cookies, titleTAG)
if providerObj.id not in sickrage.app.search_providers.torrentrss():
validate = providerObj.validateRSS()
if validate['result']:
......
......@@ -33,6 +33,7 @@ from cachecontrol import CacheControlAdapter
import sickrage
from sickrage.core.helpers import chmodAsParent, remove_file_failed
from sickrage.core.helpers.encoding import to_unicode
class DBCache(object):
......@@ -104,6 +105,7 @@ class WebSession(cfscrape.CloudflareScraper):
params=params,
verify=verify,
proxies=proxies,
hooks={'response': WebHooks.log_url},
*args, **kwargs
)
......@@ -161,3 +163,18 @@ class WebSession(cfscrape.CloudflareScraper):
correct_segments[0] += '/'
return '/'.join(correct_segments) + '/'
class WebHooks(object):
@staticmethod
def log_url(response, **kwargs):
"""Response hook to log request URL."""
request = response.request
sickrage.app.log.debug('{} URL: {} [Status: {}]'.format(request.method, request.url, response.status_code))
sickrage.app.log.debug('User-Agent: {}'.format(request.headers['User-Agent']))
if request.method.upper() == 'POST':
if isinstance(request.body, unicode):
sickrage.app.log.debug('With post data: {}'.format(request.body))
else:
sickrage.app.log.debug('With post data: {}'.format(to_unicode(request.body)))
......@@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: sickrage 9.1.70\n"
"Project-Id-Version: sickrage 9.1.72\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2017-11-10 12:21-0500\n"
"POT-Creation-Date: 2017-11-12 00:51-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
......
......@@ -487,6 +487,11 @@ class GenericProvider(object):
:return: dict
"""
if isinstance(self, TorrentRssProvider) and not self.cookies:
return {'result': True,
'message': 'This is a TorrentRss provider without any cookies provided. '
'Cookies for this provider are considered optional.'}
# This is the generic attribute used to manually add cookies for provider authentication
if not self.enable_cookies:
return {'result': False,
......
......@@ -81,12 +81,10 @@ class AlphaRatioProvider(TorrentProvider):
for mode in search_strings.keys():
sickrage.app.log.debug("Search Mode: %s" % mode)
for search_string in search_strings[mode]:
if mode != 'RSS':
sickrage.app.log.debug("Search string: %s " % search_string)
searchURL = self.urls['search'] % (search_string, self.catagories)
sickrage.app.log.debug("Search URL: %s" % searchURL)
try:
data = sickrage.app.wsession.get(searchURL).text
......
......@@ -69,13 +69,13 @@ class ArcheTorrentProvider(TorrentProvider):
'returnto': '/index.php'
}
response = sickrage.app.wsession.post(self.urls['login'], data=login_params).text
if response:
try:
sickrage.app.wsession.post(self.urls['login'], data=login_params)
search = sickrage.app.wsession.get(self.urls['search']).text
except Exception:
sickrage.app.log.warning('Unable to connect to provider')
return False
search = sickrage.app.wsession.get(self.urls['search'])
if not re.search('torrents.php', search):
sickrage.app.log.warning('Invalid username or password. Check your settings')
return False
......
......@@ -99,7 +99,7 @@ class EliteTorrentProvider(TorrentProvider):
results = []
def _processTitle(title):
def _process_title(title):
# Quality, if no literal is defined it's HDTV
if 'calidad' not in title:
title += ' HDTV x264'
......@@ -126,9 +126,8 @@ class EliteTorrentProvider(TorrentProvider):
for row in torrent_rows[1:]:
try:
title = _process_title(row.find('a', class_='nombre')['title'])
download_url = self.urls['base_url'] + row.find('a')['href']
row_title = row.find('a', class_='nombre')['title']
title = _processTitle(row_title.encode('latin-1').decode('utf8'))
if not all([title, download_url]):
continue
......
......@@ -62,8 +62,9 @@ class FileListProvider(TorrentProvider):
"password": self.password
}
response = sickrage.app.wsession.post(self.urls["login"], data=login_params).text
if not response:
try:
response = sickrage.app.wsession.post(self.urls["login"], data=login_params).text
except Exception:
sickrage.app.log.warning("Unable to connect to provider")
return False
......
......@@ -90,7 +90,6 @@ class GFTrackerProvider(TorrentProvider):
sickrage.app.log.debug("Search string: %s " % search_string)
searchURL = self.urls['search'] % (self.categories, search_string)
sickrage.app.log.debug("Search URL: %s" % searchURL)
# Set cookies from response
# Returns top 30 results by default, expandable in user profile
......
......@@ -79,8 +79,9 @@ class ImmortalseedProvider(TorrentProvider):
'password': self.password,
}
response = sickrage.app.wsession.post(self.urls['login'], data=login_params).text
if not response:
try:
response = sickrage.app.wsession.post(self.urls['login'], data=login_params).text
except Exception:
sickrage.app.log.warning("Unable to connect to provider")
return False
......
......@@ -77,8 +77,6 @@ class IPTorrentsProvider(TorrentProvider):
return results
search_url = urljoin(self.custom_url, search_url.split(self.urls['base_url'])[1])
sickrage.app.log.debug("Search URL: %s" % search_url)
try:
data = sickrage.app.wsession.get(search_url).text
results += self.parse(data, mode)
......
......@@ -109,7 +109,6 @@ class MoreThanTVProvider(TorrentProvider):
sickrage.app.log.debug("Search string: %s " % search_string)
searchURL = self.urls['search'] % (search_string.replace('(', '').replace(')', ''))
sickrage.app.log.debug("Search URL: %s" % searchURL)
# returns top 15 results by default, expandable in user profile to 100
try:
......
......@@ -65,8 +65,9 @@ class NcoreProvider(TorrentProvider):
'submitted': '1',
}
response = sickrage.app.wsession.post(self.urls["login"], data=login_params).text
if not response:
try:
response = sickrage.app.wsession.post(self.urls["login"], data=login_params).text
except Exception:
sickrage.app.log.warning("Unable to connect to provider")
return False
......
......@@ -58,8 +58,7 @@ class NebulanceProvider(TorrentProvider):
}
try:
response = sickrage.app.wsession.post(self.urls['base_url'], params={'page': 'login'},
data=login_params, timeout=30).text
response = sickrage.app.wsession.post(self.urls['base_url'], params={'page': 'login'}, data=login_params, timeout=30).text
except Exception:
sickrage.app.log.warning("Unable to connect to provider".format(self.name))
return False
......@@ -89,7 +88,6 @@ class NebulanceProvider(TorrentProvider):
sickrage.app.log.debug("Search string: %s " % search_string)
searchURL = self.urls['base_url'] + "?" + urlencode(search_params)
sickrage.app.log.debug("Search URL: %s" % searchURL)
try:
data = sickrage.app.wsession.get(searchURL).text
......
......@@ -23,6 +23,8 @@ from __future__ import unicode_literals
import re
from unidecode import unidecode
import sickrage
from sickrage.core.caches.tv_cache import TVCache
from sickrage.core.helpers import bs4_parser, convert_size
......@@ -36,7 +38,8 @@ class NewpctProvider(TorrentProvider):
self.urls.update({
'search': ['{base_url}/descargar-serie/%s'.format(**self.urls),
'{base_url}/descargar-seriehd/%s'.format(**self.urls)],
'{base_url}/descargar-seriehd/%s'.format(**self.urls),
'{base_url}/descargar-serievo/%s'.format(**self.urls)],
'rss': '{base_url}/feed'.format(**self.urls),
'download': 'http://tumejorserie.com/descargar/index.php?link=torrents/%s.torrent'.format(**self.urls),
})
......@@ -49,16 +52,22 @@ class NewpctProvider(TorrentProvider):
"""
Get season search strings.
"""
search_string = {
search_strings = {
'Season': []
}
season_strings = ['%s/capitulo-%s%s/',
'%s/capitulo-%s%s/hdtv/',
'%s/capitulo-%s%s/hdtv-720p-ac3-5-1/',
'%s/capitulo-%s%s/hdtv-1080p-ac3-5-1/',
'%s/capitulo-%s%s/bluray-1080p/']
for show_name in allPossibleShowNames(episode.show, episode.scene_season):
for string in ['%s/capitulo-%s%s/', '%s/capitulo-%s%s/hdtv/', '%s/capitulo-%s%s/hdtv-720p-ac3-5-1/']:
season_string = string % (show_name.replace(' ', '-'), episode.season, episode.episode)
search_string['Season'].append(season_string.strip())
for season_string in season_strings:
season_string = season_string % (show_name.replace(' ', '-'), episode.season, episode.episode)
search_strings['Season'].append(season_string.strip())
return [search_string]
return [search_strings]
def _get_episode_search_strings(self, episode, add_string=''):
"""
......@@ -67,16 +76,22 @@ class NewpctProvider(TorrentProvider):
if not episode:
return []
search_string = {
search_strings = {
'Episode': []
}
episode_strings = ['%s/capitulo-%s%s/',
'%s/capitulo-%s%s/hdtv/',
'%s/capitulo-%s%s/hdtv-720p-ac3-5-1/',
'%s/capitulo-%s%s/hdtv-1080p-ac3-5-1/',
'%s/capitulo-%s%s/bluray-1080p/']
for show_name in allPossibleShowNames(episode.show, episode.scene_season):
for string in ['%s/capitulo-%s%s/', '%s/capitulo-%s%s/hdtv/', '%s/capitulo-%s%s/hdtv-720p-ac3-5-1/']:
episode_string = string % (show_name.replace(' ', '-'), episode.season, episode.episode)
search_string['Episode'].append(episode_string.strip())
for episode_string in episode_strings:
episode_string = episode_string % (show_name.replace(' ', '-'), episode.season, episode.episode)
search_strings['Episode'].append(episode_string.strip())
return [search_string]
return [search_strings]
def search(self, search_strings, age=0, ep_obj=None):
results = []
......@@ -99,9 +114,7 @@ class NewpctProvider(TorrentProvider):
for search_url in self.urls['search']:
try:
data = sickrage.app.wsession.get(search_url % search_string).text
items = self.parse(data, mode)
if not len(items): break
results += items
results += self.parse(data, mode)
except Exception:
sickrage.app.log.debug('No data returned from provider')
......@@ -124,7 +137,9 @@ class NewpctProvider(TorrentProvider):
return results
try:
title = self._process_title(html.find('h1').get_text().split('/')[1])
link = html.find(rel='canonical')['href']
title = unidecode(html.find('h1').get_text().split('/')[1])
title = self._process_title(title, link)
download_id = re.search(r'http://tumejorserie.com/descargar/.+?(\d{6}).+?\.html', html.get_text(),
re.DOTALL).group(1)
download_url = self.urls['download'] % download_id