1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 03:22:22 -05:00

Merge branch 'origin/dev'

This commit is contained in:
echel0n 2014-05-13 08:45:40 -07:00
commit 56cf390781
8 changed files with 53 additions and 34 deletions

View File

@ -50,6 +50,8 @@ from sickbeard.databases import mainDB, cache_db, failed_db
from lib.configobj import ConfigObj
import xml.etree.ElementTree as ElementTree
invoked_command = None
PID = None
@ -135,6 +137,7 @@ ROOT_DIRS = None
UPDATE_SHOWS_ON_START = None
SORT_ARTICLE = None
DEBUG = False
CLEAR_CACHE = None
USE_LISTVIEW = None
METADATA_XBMC = None
@ -521,7 +524,7 @@ def initialize(consoleLogging=True):
USE_SYNOLOGYNOTIFIER, SYNOLOGYNOTIFIER_NOTIFY_ONSNATCH, SYNOLOGYNOTIFIER_NOTIFY_ONDOWNLOAD, SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD, \
USE_EMAIL, EMAIL_HOST, EMAIL_PORT, EMAIL_TLS, EMAIL_USER, EMAIL_PASSWORD, EMAIL_FROM, EMAIL_NOTIFY_ONSNATCH, EMAIL_NOTIFY_ONDOWNLOAD, EMAIL_NOTIFY_ONSUBTITLEDOWNLOAD, EMAIL_LIST, \
USE_LISTVIEW, METADATA_XBMC, METADATA_XBMC_12PLUS, METADATA_MEDIABROWSER, METADATA_PS3, metadata_provider_dict, \
NEWZBIN, NEWZBIN_USERNAME, NEWZBIN_PASSWORD, GIT_PATH, MOVE_ASSOCIATED_FILES, \
NEWZBIN, NEWZBIN_USERNAME, NEWZBIN_PASSWORD, GIT_PATH, MOVE_ASSOCIATED_FILES, CLEAR_CACHE, \
GUI_NAME, HOME_LAYOUT, HISTORY_LAYOUT, DISPLAY_SHOW_SPECIALS, COMING_EPS_LAYOUT, COMING_EPS_SORT, COMING_EPS_DISPLAY_PAUSED, COMING_EPS_MISSED_RANGE, DATE_PRESET, TIME_PRESET, TIME_PRESET_W_SECONDS, \
METADATA_WDTV, METADATA_TIVO, METADATA_MEDE8ER, IGNORE_WORDS, CALENDAR_UNPROTECTED, CREATE_MISSING_SHOW_DIRS, \
ADD_SHOWS_WO_DIR, USE_SUBTITLES, SUBTITLES_LANGUAGES, SUBTITLES_DIR, SUBTITLES_SERVICES_LIST, SUBTITLES_SERVICES_ENABLED, SUBTITLES_HISTORY, SUBTITLES_FINDER_FREQUENCY, subtitlesFinderScheduler, \
@ -1123,6 +1126,17 @@ def initialize(consoleLogging=True):
showList = []
loadingShowList = {}
try:
url = 'http://raw.github.com/echel0n/sickrage-init/master/settings.ini'
clear_cache = ElementTree.XML(helpers.getURL(url)).find('cache/clear').text
CLEAR_CACHE = check_setting_str(CFG, 'General', 'clear_cache', '')
if CLEAR_CACHE != clear_cache:
for curProvider in [x for x in providers.sortedProviderList() if x.isActive()]:
curProvider.cache._clearCache()
CLEAR_CACHE = clear_cache
save_config()
except:pass
__INITIALIZED__ = True
return True
@ -1442,6 +1456,8 @@ def save_config():
new_config['General']['ignore_words'] = IGNORE_WORDS
new_config['General']['calendar_unprotected'] = int(CALENDAR_UNPROTECTED)
new_config['General']['clear_cache'] = CLEAR_CACHE
new_config['Blackhole'] = {}
new_config['Blackhole']['nzb_dir'] = NZB_DIR
new_config['Blackhole']['torrent_dir'] = TORRENT_DIR

View File

@ -85,12 +85,12 @@ class TransmissionAPI(GenericClient):
ratio = result.ratio
elif sickbeard.TORRENT_RATIO:
ratio = sickbeard.TORRENT_RATIO
try:
float(ratio)
except ValueError:
logger.log(self.name + u': Invalid Ratio. "' + ratio + u'" is not a number', logger.ERROR)
return False
if ratio:
try:
float(ratio)
except ValueError:
logger.log(self.name + u': Invalid Ratio. "' + ratio + u'" is not a number', logger.ERROR)
return False
torrent_id = self._get_torrent_hash(result)

View File

@ -212,10 +212,11 @@ def getURL(url, post_data=None, headers=None, params=None, timeout=30, json=Fals
logger.log(u"Connection timed out " + str(e.message) + " while loading URL " + url, logger.WARNING)
return None
if json:
return r.json() if r.ok else None
if r.ok:
if json:
return r.json()
return r.content if r.ok else None
return r.content
def _remove_file_failed(file):
@ -284,7 +285,7 @@ def makeDir(path):
return True
def searchDBForShow(regShowName):
def searchDBForShow(regShowName, log=False):
showNames = [re.sub('[. -]', ' ', regShowName)]
myDB = db.DBConnection()
@ -303,17 +304,20 @@ def searchDBForShow(regShowName):
# if we didn't get exactly one result then try again with the year stripped off if possible
match = re.match(yearRegex, showName)
if match and match.group(1):
logger.log(u"Unable to match original name but trying to manually strip and specify show year",
logger.DEBUG)
if log:
logger.log(u"Unable to match original name but trying to manually strip and specify show year",
logger.DEBUG)
sqlResults = myDB.select(
"SELECT * FROM tv_shows WHERE (show_name LIKE ?) AND startyear = ?",
[match.group(1) + '%', match.group(3)])
if len(sqlResults) == 0:
logger.log(u"Unable to match a record in the DB for " + showName, logger.DEBUG)
if log:
logger.log(u"Unable to match a record in the DB for " + showName, logger.DEBUG)
continue
elif len(sqlResults) > 1:
logger.log(u"Multiple results for " + showName + " in the DB, unable to match show name", logger.DEBUG)
if log:
logger.log(u"Multiple results for " + showName + " in the DB, unable to match show name", logger.DEBUG)
continue
else:
return (int(sqlResults[0]["indexer_id"]), sqlResults[0]["show_name"])

View File

@ -377,7 +377,10 @@ class ParseResult(object):
if self.season_number == None: return self # can't work without a season
if len(self.episode_numbers) == 0: return self # need at least one episode
self.show = helpers.get_show_by_name(self.series_name)
showResult = helpers.searchDBForShow(self.series_name)
if showResult:
self.show = helpers.findCertainShow(sickbeard.showList, int(showResult[0]))
if not self.show:
return self

View File

@ -52,9 +52,9 @@ class Boxcar2Notifier:
data = urllib.urlencode({
'user_credentials': accesstoken,
'notification[title]': "SickRage : " + title,
'notification[title]': "SickRage : " + title + ' ' + msg,
'notification[long_message]': msg,
'notification[sound]': "bird-1"
'notification[sound]': "success"
})
# send the request to boxcar2

View File

@ -142,7 +142,7 @@ class SCCProvider(generic.TorrentProvider):
return [search_string]
def _isSection(section, text):
def _isSection(self, section, text):
title = '<title>.+? \| %s</title>' % section
if re.search(title, text, re.IGNORECASE):
return True

View File

@ -1904,6 +1904,9 @@ class TVEpisode(object):
result_name = result_name.replace('%rg', 'sickbeard')
logger.log(u"Episode has no release name, replacing it with a generic one: " + result_name, logger.DEBUG)
if not replace_map['%RT']:
result_name = re.sub('([ _.-]*)%RT([ _.-]*)', r'\2', result_name)
# split off ep name part only
name_groups = re.split(r'[\\/]', result_name)
@ -2138,4 +2141,4 @@ class TVEpisode(object):
(self.season, self.episode) = sickbeard.scene_numbering.get_indexer_numbering(self.show.indexerid,
self.show.indexer,
self.scene_season,
self.scene_episode)
self.scene_episode)

View File

@ -232,7 +232,7 @@ class TVCache():
# if we don't have complete info then parse the filename to get it
try:
myParser = NameParser()
parse_result = myParser.parse(name)
parse_result = myParser.parse(name).convert()
except InvalidNameException:
logger.log(u"Unable to parse the filename " + name + " into a valid episode", logger.DEBUG)
return None
@ -255,13 +255,6 @@ class TVCache():
if showResult:
indexerid = int(showResult[0])
# if not indexerid:
# for curShow in sickbeard.showList:
# if curShow.name == parse_result.series_name:
# if show_name_helpers.isGoodResult(name, curShow, False):
# indexerid = int(curShow.indexerid)
# break
showObj = None
if indexerid:
showObj = helpers.findCertainShow(sickbeard.showList, indexerid)
@ -327,14 +320,14 @@ class TVCache():
def findNeededEpisodes(self, epObj=None, manualSearch=False):
neededEps = {}
myDB = self._getDB()
cacheDB = self._getDB()
if not epObj:
sqlResults = myDB.select("SELECT * FROM [" + self.providerID + "]")
sqlResults = cacheDB.select("SELECT * FROM [" + self.providerID + "]")
else:
sqlResults = myDB.select(
sqlResults = cacheDB.select(
"SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ?",
[epObj.show.indexerid, epObj.scene_season, "%|" + str(epObj.scene_episode) + "|%"])
[epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"])
# for each cache entry
for curResult in sqlResults:
@ -386,9 +379,9 @@ class TVCache():
# add it to the list
if epObj not in neededEps:
neededEps[epObj] = [result]
neededEps[epObj.episode] = [result]
else:
neededEps[epObj].append(result)
neededEps[epObj.episode].append(result)
return neededEps