Format weeks as titles by default (for DVD sync)
This commit is contained in:
parent
7769b7d936
commit
d032a72869
@ -64,7 +64,7 @@ def parseTime(timeStr):
|
||||
time_params[name] = int(param)
|
||||
return datetime.timedelta(**time_params).total_seconds()
|
||||
|
||||
def formatTime(timeInSeconds):
|
||||
def formatTime(timeInSeconds, weeksAsTitles=True):
|
||||
if(timeInSeconds < 0):
|
||||
timeInSeconds = -timeInSeconds
|
||||
sign = '-'
|
||||
@ -72,18 +72,26 @@ def formatTime(timeInSeconds):
|
||||
sign = ''
|
||||
timeInSeconds = round(timeInSeconds)
|
||||
weeks = timeInSeconds // 604800
|
||||
if weeksAsTitles and weeks > 0:
|
||||
title = weeks
|
||||
weeks = 0
|
||||
else:
|
||||
title = 0
|
||||
days = (timeInSeconds % 604800) // 86400
|
||||
hours = (timeInSeconds % 86400) // 3600
|
||||
minutes = (timeInSeconds % 3600) // 60
|
||||
seconds = timeInSeconds % 60
|
||||
if(weeks > 0):
|
||||
return '{0:}{1:.0f}w, {2:.0f}d, {3:02.0f}:{4:02.0f}:{5:02.0f}'.format(sign, weeks, days, hours, minutes, seconds)
|
||||
formattedTime = '{0:}{1:.0f}w, {2:.0f}d, {3:02.0f}:{4:02.0f}:{5:02.0f}'.format(sign, weeks, days, hours, minutes, seconds)
|
||||
elif(days > 0):
|
||||
return '{0:}{1:.0f}d, {2:02.0f}:{3:02.0f}:{4:02.0f}'.format(sign, days, hours, minutes, seconds)
|
||||
formattedTime = '{0:}{1:.0f}d, {2:02.0f}:{3:02.0f}:{4:02.0f}'.format(sign, days, hours, minutes, seconds)
|
||||
elif(hours > 0):
|
||||
return '{0:}{1:02.0f}:{2:02.0f}:{3:02.0f}'.format(sign, hours, minutes, seconds)
|
||||
formattedTime = '{0:}{1:02.0f}:{2:02.0f}:{3:02.0f}'.format(sign, hours, minutes, seconds)
|
||||
else:
|
||||
return '{0:}{1:02.0f}:{2:02.0f}'.format(sign, minutes, seconds)
|
||||
formattedTime = '{0:}{1:02.0f}:{2:02.0f}'.format(sign, minutes, seconds)
|
||||
if title > 0:
|
||||
formattedTime = "{0:} (Title {1:.0f})".format(formattedTime, title)
|
||||
return formattedTime
|
||||
|
||||
def findWorkingDir():
|
||||
frozen = getattr(sys, 'frozen', '')
|
||||
@ -133,7 +141,7 @@ def blackholeStdoutForFrozenWindow():
|
||||
# Relate to file hashing / difference checking:
|
||||
|
||||
def stripfilename(filename):
|
||||
return re.sub(constants.FILENAME_STRIP_REGEX,"",filename)
|
||||
return re.sub(constants.FILENAME_STRIP_REGEX, "", filename)
|
||||
|
||||
def hashFilename(filename):
|
||||
return hashlib.sha256(stripfilename(filename).encode('utf-8')).hexdigest()[:12]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user