mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-13 03:22:22 -05:00
Fix for extensions being stripped off by mistake made when adding in -RP fix from few commits ago.
This commit is contained in:
parent
efb94f1675
commit
5ac99b8c5c
@ -1239,3 +1239,16 @@ def mapIndexersToShow(showObj):
|
|||||||
indexerMap[showObj.name] = mapped
|
indexerMap[showObj.name] = mapped
|
||||||
|
|
||||||
return mapped
|
return mapped
|
||||||
|
|
||||||
|
|
||||||
|
def touchFile(self, fname, atime=None):
|
||||||
|
if None != atime:
|
||||||
|
try:
|
||||||
|
with file(fname, 'a'):
|
||||||
|
os.utime(fname, (atime, atime))
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
logger.log(u"File air date stamping not available on your OS", logger.DEBUG)
|
||||||
|
pass
|
||||||
|
|
||||||
|
return False
|
@ -20,7 +20,7 @@ import sickbeard
|
|||||||
from sickbeard import db
|
from sickbeard import db
|
||||||
from sickbeard import logger
|
from sickbeard import logger
|
||||||
|
|
||||||
nameCache = None
|
nameCache = {}
|
||||||
nameCacheLock = threading.Lock()
|
nameCacheLock = threading.Lock()
|
||||||
|
|
||||||
def addNameToCache(name, indexer_id=0):
|
def addNameToCache(name, indexer_id=0):
|
||||||
@ -94,10 +94,6 @@ def saveNameCacheToDb():
|
|||||||
def buildNameCache(show=None):
|
def buildNameCache(show=None):
|
||||||
global nameCache
|
global nameCache
|
||||||
|
|
||||||
# init name cache
|
|
||||||
if not nameCache:
|
|
||||||
nameCache = {}
|
|
||||||
|
|
||||||
with nameCacheLock:
|
with nameCacheLock:
|
||||||
# clear internal name cache
|
# clear internal name cache
|
||||||
clearCache()
|
clearCache()
|
||||||
|
@ -71,13 +71,13 @@ class PostProcessor(object):
|
|||||||
self.file_path = file_path
|
self.file_path = file_path
|
||||||
|
|
||||||
# file name only
|
# file name only
|
||||||
self.file_name = helpers.remove_extension(ek.ek(os.path.basename, file_path))
|
self.file_name = ek.ek(os.path.basename, file_path)
|
||||||
|
|
||||||
# the name of the folder only
|
# the name of the folder only
|
||||||
self.folder_name = helpers.remove_extension(ek.ek(os.path.basename, self.folder_path))
|
self.folder_name = ek.ek(os.path.basename, self.folder_path)
|
||||||
|
|
||||||
# name of the NZB that resulted in this folder
|
# name of the NZB that resulted in this folder
|
||||||
self.nzb_name = helpers.remove_extension(nzb_name)
|
self.nzb_name = nzb_name
|
||||||
|
|
||||||
self.process_method = process_method if process_method else sickbeard.PROCESS_METHOD
|
self.process_method = process_method if process_method else sickbeard.PROCESS_METHOD
|
||||||
|
|
||||||
@ -1007,7 +1007,7 @@ class PostProcessor(object):
|
|||||||
|
|
||||||
# download subtitles
|
# download subtitles
|
||||||
if sickbeard.USE_SUBTITLES and ep_obj.show.subtitles:
|
if sickbeard.USE_SUBTITLES and ep_obj.show.subtitles:
|
||||||
for curEp in [ep_obj]:
|
for cur_ep in [ep_obj] + ep_obj.relatedEps:
|
||||||
with cur_ep.lock:
|
with cur_ep.lock:
|
||||||
cur_ep.location = ek.ek(os.path.join, dest_path, new_file_name)
|
cur_ep.location = ek.ek(os.path.join, dest_path, new_file_name)
|
||||||
cur_ep.downloadSubtitles(force=True)
|
cur_ep.downloadSubtitles(force=True)
|
||||||
@ -1017,21 +1017,20 @@ class PostProcessor(object):
|
|||||||
for cur_ep in [ep_obj] + ep_obj.relatedEps:
|
for cur_ep in [ep_obj] + ep_obj.relatedEps:
|
||||||
with cur_ep.lock:
|
with cur_ep.lock:
|
||||||
cur_ep.location = ek.ek(os.path.join, dest_path, new_file_name)
|
cur_ep.location = ek.ek(os.path.join, dest_path, new_file_name)
|
||||||
|
|
||||||
sql_l.append(cur_ep.get_sql())
|
sql_l.append(cur_ep.get_sql())
|
||||||
|
|
||||||
# set file modify stamp to show airdate
|
|
||||||
if sickbeard.AIRDATE_EPISODES:
|
|
||||||
ep_obj.show.airdateModifyStamp(cur_ep)
|
|
||||||
|
|
||||||
# generate nfo/tbn
|
|
||||||
ep_obj.createMetaFiles()
|
|
||||||
sql_l.append(ep_obj.get_sql())
|
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if len(sql_l) > 0:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
# set file modify stamp to show airdate
|
||||||
|
if sickbeard.AIRDATE_EPISODES:
|
||||||
|
for cur_ep in [ep_obj] + ep_obj.relatedEps:
|
||||||
|
with cur_ep.lock:
|
||||||
|
cur_ep.airdateModifyStamp()
|
||||||
|
|
||||||
|
# generate nfo/tbn
|
||||||
|
ep_obj.createMetaFiles()
|
||||||
|
|
||||||
# log it to history
|
# log it to history
|
||||||
history.logDownload(ep_obj, self.file_path, new_ep_quality, self.release_group)
|
history.logDownload(ep_obj, self.file_path, new_ep_quality, self.release_group)
|
||||||
|
@ -383,10 +383,10 @@ class GenericProvider:
|
|||||||
if not result:
|
if not result:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if epNum in results:
|
if epNum not in results:
|
||||||
results[epNum].append(result)
|
|
||||||
else:
|
|
||||||
results[epNum] = [result]
|
results[epNum] = [result]
|
||||||
|
else:
|
||||||
|
results[epNum].append(result)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@ -162,11 +162,10 @@ class BacklogSearcher:
|
|||||||
common.SNATCHED_BEST) and curQuality < highestBestQuality) or curStatus == common.WANTED:
|
common.SNATCHED_BEST) and curQuality < highestBestQuality) or curStatus == common.WANTED:
|
||||||
|
|
||||||
epObj = show.getEpisode(int(result["season"]), int(result["episode"]))
|
epObj = show.getEpisode(int(result["season"]), int(result["episode"]))
|
||||||
|
if epObj.season not in wanted:
|
||||||
if epObj.season in wanted:
|
|
||||||
wanted[epObj.season].append(epObj)
|
|
||||||
else:
|
|
||||||
wanted[epObj.season] = [epObj]
|
wanted[epObj.season] = [epObj]
|
||||||
|
else:
|
||||||
|
wanted[epObj.season].append(epObj)
|
||||||
|
|
||||||
return wanted
|
return wanted
|
||||||
|
|
||||||
|
@ -1076,52 +1076,12 @@ class TVShow(object):
|
|||||||
else:
|
else:
|
||||||
# the file exists, set its modify file stamp
|
# the file exists, set its modify file stamp
|
||||||
if sickbeard.AIRDATE_EPISODES:
|
if sickbeard.AIRDATE_EPISODES:
|
||||||
self.airdateModifyStamp(curEp)
|
curEp.airdateModifyStamp()
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if len(sql_l) > 0:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
|
||||||
def airdateModifyStamp(self, ep_obj):
|
|
||||||
"""
|
|
||||||
Make the modify date and time of a file reflect the show air date and time.
|
|
||||||
Note: Also called from postProcessor
|
|
||||||
|
|
||||||
"""
|
|
||||||
hr = min = 0
|
|
||||||
airs = re.search('.*?(\d{1,2})(?::\s*?(\d{2}))?\s*(pm)?', ep_obj.show.airs, re.I)
|
|
||||||
if airs:
|
|
||||||
hr = int(airs.group(1))
|
|
||||||
hr = (12 + hr, hr)[None is airs.group(3)]
|
|
||||||
min = int((airs.group(2), min)[None is airs.group(2)])
|
|
||||||
airtime = datetime.time(hr, min)
|
|
||||||
|
|
||||||
airdatetime = datetime.datetime.combine(ep_obj.airdate, airtime)
|
|
||||||
|
|
||||||
filemtime = datetime.datetime.fromtimestamp(os.path.getmtime(ep_obj.location))
|
|
||||||
|
|
||||||
if filemtime != airdatetime:
|
|
||||||
import time
|
|
||||||
|
|
||||||
airdatetime = airdatetime.timetuple()
|
|
||||||
if self.touch(ep_obj.location, time.mktime(airdatetime)):
|
|
||||||
logger.log(str(self.indexerid) + u": Changed modify date of " + os.path.basename(ep_obj.location)
|
|
||||||
+ " to show air date " + time.strftime("%b %d,%Y (%H:%M)", airdatetime))
|
|
||||||
|
|
||||||
def touch(self, fname, atime=None):
|
|
||||||
|
|
||||||
if None != atime:
|
|
||||||
try:
|
|
||||||
with file(fname, 'a'):
|
|
||||||
os.utime(fname, (atime, atime))
|
|
||||||
return True
|
|
||||||
except:
|
|
||||||
logger.log(u"File air date stamping not available on your OS", logger.DEBUG)
|
|
||||||
pass
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def downloadSubtitles(self, force=False):
|
def downloadSubtitles(self, force=False):
|
||||||
# TODO: Add support for force option
|
# TODO: Add support for force option
|
||||||
if not ek.ek(os.path.isdir, self._location):
|
if not ek.ek(os.path.isdir, self._location):
|
||||||
@ -2441,6 +2401,32 @@ class TVEpisode(object):
|
|||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
def airdateModifyStamp(self):
|
||||||
|
"""
|
||||||
|
Make the modify date and time of a file reflect the show air date and time.
|
||||||
|
Note: Also called from postProcessor
|
||||||
|
|
||||||
|
"""
|
||||||
|
hr = min = 0
|
||||||
|
airs = re.search('.*?(\d{1,2})(?::\s*?(\d{2}))?\s*(pm)?', self.show.airs, re.I)
|
||||||
|
if airs:
|
||||||
|
hr = int(airs.group(1))
|
||||||
|
hr = (12 + hr, hr)[None is airs.group(3)]
|
||||||
|
min = int((airs.group(2), min)[None is airs.group(2)])
|
||||||
|
airtime = datetime.time(hr, min)
|
||||||
|
|
||||||
|
airdatetime = datetime.datetime.combine(self.airdate, airtime)
|
||||||
|
|
||||||
|
filemtime = datetime.datetime.fromtimestamp(os.path.getmtime(self.location))
|
||||||
|
|
||||||
|
if filemtime != airdatetime:
|
||||||
|
import time
|
||||||
|
|
||||||
|
airdatetime = airdatetime.timetuple()
|
||||||
|
if helpers.touchFile(self.location, time.mktime(airdatetime)):
|
||||||
|
logger.log(str(self.show.indexerid) + u": Changed modify date of " + os.path.basename(self.location)
|
||||||
|
+ " to show air date " + time.strftime("%b %d,%Y (%H:%M)", airdatetime))
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
d = dict(self.__dict__)
|
d = dict(self.__dict__)
|
||||||
del d['lock']
|
del d['lock']
|
||||||
|
@ -138,8 +138,7 @@ class TVCache():
|
|||||||
return RSSFeeds(self.providerID).getFeed(url, post_data, request_headers)
|
return RSSFeeds(self.providerID).getFeed(url, post_data, request_headers)
|
||||||
|
|
||||||
def _translateTitle(self, title):
|
def _translateTitle(self, title):
|
||||||
title = u'' + title
|
return u'' + title.replace(' ', '.')
|
||||||
return title.replace(' ', '.')
|
|
||||||
|
|
||||||
|
|
||||||
def _translateLinkURL(self, url):
|
def _translateLinkURL(self, url):
|
||||||
@ -345,32 +344,29 @@ class TVCache():
|
|||||||
if not showObj.wantEpisode(curSeason, curEp, curQuality, manualSearch):
|
if not showObj.wantEpisode(curSeason, curEp, curQuality, manualSearch):
|
||||||
logger.log(u"Skipping " + curResult["name"] + " because we don't want an episode that's " +
|
logger.log(u"Skipping " + curResult["name"] + " because we don't want an episode that's " +
|
||||||
Quality.qualityStrings[curQuality], logger.DEBUG)
|
Quality.qualityStrings[curQuality], logger.DEBUG)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# build a result object
|
||||||
|
title = curResult["name"]
|
||||||
|
url = curResult["url"]
|
||||||
|
|
||||||
|
logger.log(u"Found result " + title + " at " + url)
|
||||||
|
|
||||||
|
result = self.provider.getResult([epObj])
|
||||||
|
result.show = showObj
|
||||||
|
result.url = url
|
||||||
|
result.name = title
|
||||||
|
result.quality = curQuality
|
||||||
|
result.release_group = curReleaseGroup
|
||||||
|
result.content = self.provider.getURL(url) \
|
||||||
|
if self.provider.providerType == sickbeard.providers.generic.GenericProvider.TORRENT \
|
||||||
|
and not url.startswith('magnet') else None
|
||||||
|
|
||||||
|
# add it to the list
|
||||||
|
if epObj not in neededEps:
|
||||||
|
neededEps[epObj] = [result]
|
||||||
else:
|
else:
|
||||||
|
neededEps[epObj].append(result)
|
||||||
if not epObj:
|
|
||||||
epObj = showObj.getEpisode(curSeason, curEp)
|
|
||||||
|
|
||||||
# build a result object
|
|
||||||
title = curResult["name"]
|
|
||||||
url = curResult["url"]
|
|
||||||
|
|
||||||
logger.log(u"Found result " + title + " at " + url)
|
|
||||||
|
|
||||||
result = self.provider.getResult([epObj])
|
|
||||||
result.show = showObj
|
|
||||||
result.url = url
|
|
||||||
result.name = title
|
|
||||||
result.quality = curQuality
|
|
||||||
result.release_group = curReleaseGroup
|
|
||||||
result.content = self.provider.getURL(url) \
|
|
||||||
if self.provider.providerType == sickbeard.providers.generic.GenericProvider.TORRENT \
|
|
||||||
and not url.startswith('magnet') else None
|
|
||||||
|
|
||||||
# add it to the list
|
|
||||||
if epObj not in neededEps:
|
|
||||||
neededEps[epObj] = [result]
|
|
||||||
else:
|
|
||||||
neededEps[epObj].append(result)
|
|
||||||
|
|
||||||
# datetime stamp this search so cache gets cleared
|
# datetime stamp this search so cache gets cleared
|
||||||
self.setLastSearch()
|
self.setLastSearch()
|
||||||
|
Loading…
Reference in New Issue
Block a user