mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Fix ensure url unicode shownames are correctly 'UTF-8' and urlencoded.
Refactor shownames list into generic provider method, reusable in multiple providers. Add remove English at the end of release names (drunkenslug).
This commit is contained in:
parent
62dfcdd7ae
commit
11dfd66efd
2 changed files with 14 additions and 13 deletions
|
@ -27,6 +27,7 @@ import re
|
|||
import time
|
||||
import urlparse
|
||||
import threading
|
||||
import urllib
|
||||
from urllib import quote_plus
|
||||
import zlib
|
||||
from base64 import b16encode, b32decode
|
||||
|
@ -39,7 +40,7 @@ from hachoir_parser import guessParser
|
|||
from hachoir_core.error import HachoirError
|
||||
from hachoir_core.stream import FileInputStream
|
||||
|
||||
from sickbeard import helpers, classes, logger, db, tvcache, encodingKludge as ek
|
||||
from sickbeard import helpers, classes, logger, db, tvcache, scene_exceptions, encodingKludge as ek
|
||||
from sickbeard.common import Quality, MULTI_EP_RESULT, SEASON_RESULT, USER_AGENT
|
||||
from sickbeard.exceptions import SickBeardException, AuthException, ex
|
||||
from sickbeard.helpers import maybe_plural, remove_file_failed
|
||||
|
@ -165,6 +166,12 @@ class GenericProvider:
|
|||
return helpers.getURL(url, post_data=post_data, params=params, headers=self.headers, timeout=timeout,
|
||||
session=self.session, json=json, hooks=dict(response=self.cb_response))
|
||||
|
||||
@staticmethod
|
||||
def get_show_names_url_encoded(ep_obj, spacer='.'):
|
||||
return [urllib.quote_plus(n.replace('.', spacer).encode('utf-8', errors='replace')) for n in list(
|
||||
set([helpers.sanitizeSceneName(a) for a in
|
||||
scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name]]))]
|
||||
|
||||
def download_result(self, result):
|
||||
"""
|
||||
Save the result to disk.
|
||||
|
|
|
@ -27,7 +27,7 @@ from math import ceil
|
|||
|
||||
from sickbeard.sbdatetime import sbdatetime
|
||||
from . import generic
|
||||
from sickbeard import helpers, logger, scene_exceptions, tvcache, classes, db
|
||||
from sickbeard import helpers, logger, tvcache, classes, db
|
||||
from sickbeard.common import neededQualities, Quality
|
||||
from sickbeard.exceptions import AuthException, MultipleShowObjectsException
|
||||
from sickbeard.indexers.indexer_config import *
|
||||
|
@ -351,15 +351,12 @@ class NewznabProvider(generic.NZBProvider):
|
|||
use_id = True
|
||||
use_id and search_params.append(params)
|
||||
|
||||
spacer = 'nzbgeek.info' in self.url.lower() and ' ' or '.'
|
||||
# query search and exceptions
|
||||
name_exceptions = list(
|
||||
set([helpers.sanitizeSceneName(a) for a in
|
||||
scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name]]))
|
||||
name_exceptions = self.get_show_names_url_encoded(ep_obj, spacer)
|
||||
|
||||
spacer = 'geek' in self.get_id() and ' ' or '.'
|
||||
for cur_exception in name_exceptions:
|
||||
params = base_params.copy()
|
||||
cur_exception = cur_exception.replace('.', spacer)
|
||||
if 'q' in params:
|
||||
params['q'] = '%s%s%s' % (cur_exception, spacer, params['q'])
|
||||
search_params.append(params)
|
||||
|
@ -408,17 +405,14 @@ class NewznabProvider(generic.NZBProvider):
|
|||
use_id = True
|
||||
use_id and search_params.append(params)
|
||||
|
||||
spacer = 'nzbgeek.info' in self.url.lower() and ' ' or '.'
|
||||
# query search and exceptions
|
||||
name_exceptions = list(
|
||||
set([helpers.sanitizeSceneName(a) for a in
|
||||
scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name]]))
|
||||
name_exceptions = self.get_show_names_url_encoded(ep_obj, spacer)
|
||||
|
||||
spacer = 'geek' in self.get_id() and ' ' or '.'
|
||||
if sickbeard.scene_exceptions.has_abs_episodes(ep_obj):
|
||||
search_params.append({'q': '%s%s%s' % (ep_obj.show.name, spacer, base_params['ep'])})
|
||||
for cur_exception in name_exceptions:
|
||||
params = base_params.copy()
|
||||
cur_exception = cur_exception.replace('.', spacer)
|
||||
params['q'] = cur_exception
|
||||
search_params.append(params)
|
||||
|
||||
|
@ -444,7 +438,7 @@ class NewznabProvider(generic.NZBProvider):
|
|||
r_found = True
|
||||
while r_found:
|
||||
r_found = False
|
||||
for pattern, repl in ((r'(?i)-Obfuscated$', ''), (r'(?i)-postbot$', '')):
|
||||
for pattern, repl in ((r'(?i)-Obfuscated$', ''), (r'(?i)-postbot$', ''), (r'(?i)[-.]English$', '')):
|
||||
if re.search(pattern, title):
|
||||
r_found = True
|
||||
title = re.sub(pattern, repl, title)
|
||||
|
|
Loading…
Reference in a new issue