forked from Github/Axter-Stash
Adjust duration difference check to allow small non-significant differences if one file is better in other ways
Duration difference now respects the setting for what is significant duration difference
This commit is contained in:
@@ -503,11 +503,18 @@ def isBetterVideo(scene1, scene2, swapCandidateCk = False): # is scene2 better t
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def isSignificantTimeDiff(duration1, duration2):
|
||||||
|
dur1 = int(duration1)
|
||||||
|
dur2 = int(duration2)
|
||||||
|
return abs(dur1 - dur2) / max(abs(dur1), abs(dur2)) > (1 - significantTimeDiff)
|
||||||
|
|
||||||
def significantMoreTimeCompareToBetterVideo(scene1, scene2): # is scene2 better than scene1
|
def significantMoreTimeCompareToBetterVideo(scene1, scene2): # is scene2 better than scene1
|
||||||
if isinstance(scene1, int):
|
if isinstance(scene1, int):
|
||||||
scene1 = stash.find_scene(scene1)
|
scene1 = stash.find_scene(scene1)
|
||||||
scene2 = stash.find_scene(scene2)
|
scene2 = stash.find_scene(scene2)
|
||||||
if int(scene1['files'][0]['duration']) >= int(scene2['files'][0]['duration']):
|
dur1 = int(scene1['files'][0]['duration'])
|
||||||
|
dur2 = int(scene2['files'][0]['duration'])
|
||||||
|
if dur1 >= dur2 or not isSignificantTimeDiff(dur1, dur2):
|
||||||
return False
|
return False
|
||||||
if int(scene1['files'][0]['width']) * int(scene1['files'][0]['height']) > int(scene2['files'][0]['width']) * int(scene2['files'][0]['height']):
|
if int(scene1['files'][0]['width']) * int(scene1['files'][0]['height']) > int(scene2['files'][0]['width']) * int(scene2['files'][0]['height']):
|
||||||
if significantTimeDiffCheck(scene1, scene2):
|
if significantTimeDiffCheck(scene1, scene2):
|
||||||
@@ -520,7 +527,7 @@ def significantMoreTimeCompareToBetterVideo(scene1, scene2): # is scene2 better
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def allThingsEqual(scene1, scene2): # If all important things are equal, return true
|
def allThingsEqual(scene1, scene2): # If all important things are equal, return true
|
||||||
if int(scene1['files'][0]['duration']) != int(scene2['files'][0]['duration']):
|
if isSignificantTimeDiff(scene1['files'][0]['duration'], scene2['files'][0]['duration']):
|
||||||
return False
|
return False
|
||||||
if scene1['files'][0]['width'] != scene2['files'][0]['width']:
|
if scene1['files'][0]['width'] != scene2['files'][0]['width']:
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user