mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-07 10:33:38 +00:00
Change file modify date of episodes older than 1970 can be changed to airdate, log warning on set fail.
This commit is contained in:
parent
35b282e797
commit
a74f022ea3
3 changed files with 25 additions and 17 deletions
|
@ -13,6 +13,7 @@
|
||||||
* Update Beautiful Soup 4.4.0 (r397) to 4.5.3 (r439)
|
* Update Beautiful Soup 4.4.0 (r397) to 4.5.3 (r439)
|
||||||
* Update cachecontrol library 0.11.5 to 0.12.3 (db54c40)
|
* Update cachecontrol library 0.11.5 to 0.12.3 (db54c40)
|
||||||
* Update Certifi 2015.11.20.1 (385476b) to 2017.01.23 (9f9dc30)
|
* Update Certifi 2015.11.20.1 (385476b) to 2017.01.23 (9f9dc30)
|
||||||
|
* Update dateutil library 2.4.2 (d4baf97) to 2.6.1 (2f3a160)
|
||||||
* Update feedparser library 5.2.0 (8c62940) to 5.2.1 (f1dd1bb)
|
* Update feedparser library 5.2.0 (8c62940) to 5.2.1 (f1dd1bb)
|
||||||
* Update html5lib 0.99999999/1.0b9 (46dae3d) to (1a28d72)
|
* Update html5lib 0.99999999/1.0b9 (46dae3d) to (1a28d72)
|
||||||
* Update IMDb 5.1dev20160106 to 5.1 (r907)
|
* Update IMDb 5.1dev20160106 to 5.1 (r907)
|
||||||
|
@ -79,6 +80,7 @@
|
||||||
* Change improve newnab autoselect categories
|
* Change improve newnab autoselect categories
|
||||||
* Change add nzb.org BoxSD and BoxHD categories
|
* Change add nzb.org BoxSD and BoxHD categories
|
||||||
* Change post processor, ignore symlinks found in process_dir
|
* Change post processor, ignore symlinks found in process_dir
|
||||||
|
* Change file modify date of episodes older than 1970 can be changed to airdate, log warning on set fail
|
||||||
|
|
||||||
|
|
||||||
[develop changelog]
|
[develop changelog]
|
||||||
|
|
|
@ -1017,15 +1017,14 @@ def set_up_anidb_connection():
|
||||||
return sickbeard.ADBA_CONNECTION.authed()
|
return sickbeard.ADBA_CONNECTION.authed()
|
||||||
|
|
||||||
|
|
||||||
def touchFile(fname, atime=None):
|
def touch_file(fname, atime=None):
|
||||||
if None != atime:
|
if None is not atime:
|
||||||
try:
|
try:
|
||||||
with open(fname, 'a'):
|
with open(fname, 'a'):
|
||||||
ek.ek(os.utime, fname, (atime, atime))
|
ek.ek(os.utime, fname, (atime, atime))
|
||||||
return True
|
return True
|
||||||
except:
|
except (StandardError, Exception):
|
||||||
logger.log(u"File air date stamping not available on your OS", logger.DEBUG)
|
logger.log('File air date stamping not available on your OS', logger.DEBUG)
|
||||||
pass
|
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1581,3 +1580,13 @@ def is_link(filepath):
|
||||||
return invalid_file_attributes != attr and 0 != attr & file_attribute_reparse_point
|
return invalid_file_attributes != attr and 0 != attr & file_attribute_reparse_point
|
||||||
|
|
||||||
return ek.ek(os.path.islink, filepath)
|
return ek.ek(os.path.islink, filepath)
|
||||||
|
|
||||||
|
|
||||||
|
def datetime_to_epoch(dt):
|
||||||
|
""" convert a datetime to seconds after (or possibly before) 1970-1-1 """
|
||||||
|
""" can raise an error with dates pre 1970-1-1 """
|
||||||
|
if not isinstance(getattr(dt, 'tzinfo'), datetime.tzinfo):
|
||||||
|
from sickbeard.network_timezones import sb_timezone
|
||||||
|
dt = dt.replace(tzinfo=sb_timezone)
|
||||||
|
utc_naive = dt.replace(tzinfo=None) - dt.utcoffset()
|
||||||
|
return int((utc_naive - datetime.datetime(1970, 1, 1)).total_seconds())
|
||||||
|
|
|
@ -2623,13 +2623,7 @@ class TVEpisode(object):
|
||||||
% (self.show.indexerid, ek.ek(os.path.basename, self.location)), logger.DEBUG)
|
% (self.show.indexerid, ek.ek(os.path.basename, self.location)), logger.DEBUG)
|
||||||
return
|
return
|
||||||
|
|
||||||
hr = m = 0
|
hr, m = network_timezones.parse_time(self.show.airs)
|
||||||
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)]
|
|
||||||
hr = (hr, hr - 12)[0 == hr % 12 and 0 != hr]
|
|
||||||
m = int((airs.group(2), m)[None is airs.group(2)])
|
|
||||||
airtime = datetime.time(hr, m)
|
airtime = datetime.time(hr, m)
|
||||||
|
|
||||||
airdatetime = datetime.datetime.combine(self.airdate, airtime)
|
airdatetime = datetime.datetime.combine(self.airdate, airtime)
|
||||||
|
@ -2637,12 +2631,15 @@ class TVEpisode(object):
|
||||||
filemtime = datetime.datetime.fromtimestamp(ek.ek(os.path.getmtime, self.location))
|
filemtime = datetime.datetime.fromtimestamp(ek.ek(os.path.getmtime, self.location))
|
||||||
|
|
||||||
if filemtime != airdatetime:
|
if filemtime != airdatetime:
|
||||||
import time
|
|
||||||
|
|
||||||
airdatetime = airdatetime.timetuple()
|
if helpers.touch_file(self.location, helpers.datetime_to_epoch(airdatetime)):
|
||||||
if helpers.touchFile(self.location, time.mktime(airdatetime)):
|
|
||||||
logger.log('%s: Changed modify date of %s to show air date %s'
|
logger.log('%s: Changed modify date of %s to show air date %s'
|
||||||
% (self.show.indexerid, ek.ek(os.path.basename, self.location), time.strftime('%b %d,%Y (%H:%M)', airdatetime)))
|
% (self.show.indexerid, ek.ek(os.path.basename, self.location),
|
||||||
|
airdatetime.strftime('%b %d,%Y (%H:%M)')))
|
||||||
|
else:
|
||||||
|
logger.log('%s: Error changing modify date of %s to show air date %s, Error: %s'
|
||||||
|
% (self.show.indexerid, ek.ek(os.path.basename, self.location),
|
||||||
|
airdatetime.strftime('%b %d,%Y (%H:%M)'), e.message), logger.WARNING)
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
d = dict(self.__dict__)
|
d = dict(self.__dict__)
|
||||||
|
|
Loading…
Reference in a new issue