mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 11:02:21 -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
|
||||
|
||||
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 logger
|
||||
|
||||
nameCache = None
|
||||
nameCache = {}
|
||||
nameCacheLock = threading.Lock()
|
||||
|
||||
def addNameToCache(name, indexer_id=0):
|
||||
@ -94,10 +94,6 @@ def saveNameCacheToDb():
|
||||
def buildNameCache(show=None):
|
||||
global nameCache
|
||||
|
||||
# init name cache
|
||||
if not nameCache:
|
||||
nameCache = {}
|
||||
|
||||
with nameCacheLock:
|
||||
# clear internal name cache
|
||||
clearCache()
|
||||
|
@ -71,13 +71,13 @@ class PostProcessor(object):
|
||||
self.file_path = file_path
|
||||
|
||||
# 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
|
||||
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
|
||||
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
|
||||
|
||||
@ -1007,7 +1007,7 @@ class PostProcessor(object):
|
||||
|
||||
# download 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:
|
||||
cur_ep.location = ek.ek(os.path.join, dest_path, new_file_name)
|
||||
cur_ep.downloadSubtitles(force=True)
|
||||
@ -1017,21 +1017,20 @@ class PostProcessor(object):
|
||||
for cur_ep in [ep_obj] + ep_obj.relatedEps:
|
||||
with cur_ep.lock:
|
||||
cur_ep.location = ek.ek(os.path.join, dest_path, new_file_name)
|
||||
|
||||
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:
|
||||
myDB = db.DBConnection()
|
||||
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
|
||||
history.logDownload(ep_obj, self.file_path, new_ep_quality, self.release_group)
|
||||
|
@ -383,10 +383,10 @@ class GenericProvider:
|
||||
if not result:
|
||||
continue
|
||||
|
||||
if epNum in results:
|
||||
results[epNum].append(result)
|
||||
else:
|
||||
if epNum not in results:
|
||||
results[epNum] = [result]
|
||||
else:
|
||||
results[epNum].append(result)
|
||||
|
||||
return results
|
||||
|
||||
|
@ -162,11 +162,10 @@ class BacklogSearcher:
|
||||
common.SNATCHED_BEST) and curQuality < highestBestQuality) or curStatus == common.WANTED:
|
||||
|
||||
epObj = show.getEpisode(int(result["season"]), int(result["episode"]))
|
||||
|
||||
if epObj.season in wanted:
|
||||
wanted[epObj.season].append(epObj)
|
||||
else:
|
||||
if epObj.season not in wanted:
|
||||
wanted[epObj.season] = [epObj]
|
||||
else:
|
||||
wanted[epObj.season].append(epObj)
|
||||
|
||||
return wanted
|
||||
|
||||
|
@ -1076,52 +1076,12 @@ class TVShow(object):
|
||||
else:
|
||||
# the file exists, set its modify file stamp
|
||||
if sickbeard.AIRDATE_EPISODES:
|
||||
self.airdateModifyStamp(curEp)
|
||||
curEp.airdateModifyStamp()
|
||||
|
||||
if len(sql_l) > 0:
|
||||
myDB = db.DBConnection()
|
||||
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):
|
||||
# TODO: Add support for force option
|
||||
if not ek.ek(os.path.isdir, self._location):
|
||||
@ -2441,6 +2401,32 @@ class TVEpisode(object):
|
||||
myDB = db.DBConnection()
|
||||
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):
|
||||
d = dict(self.__dict__)
|
||||
del d['lock']
|
||||
|
@ -138,8 +138,7 @@ class TVCache():
|
||||
return RSSFeeds(self.providerID).getFeed(url, post_data, request_headers)
|
||||
|
||||
def _translateTitle(self, title):
|
||||
title = u'' + title
|
||||
return title.replace(' ', '.')
|
||||
return u'' + title.replace(' ', '.')
|
||||
|
||||
|
||||
def _translateLinkURL(self, url):
|
||||
@ -345,32 +344,29 @@ class TVCache():
|
||||
if not showObj.wantEpisode(curSeason, curEp, curQuality, manualSearch):
|
||||
logger.log(u"Skipping " + curResult["name"] + " because we don't want an episode that's " +
|
||||
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:
|
||||
|
||||
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)
|
||||
neededEps[epObj].append(result)
|
||||
|
||||
# datetime stamp this search so cache gets cleared
|
||||
self.setLastSearch()
|
||||
|
Loading…
Reference in New Issue
Block a user