flame: fixing padding in collection ranges

This commit is contained in:
Jakub Jezek 2022-05-12 13:37:34 +02:00
parent 05faaaa638
commit dd77f7cd9b
No known key found for this signature in database
GPG key ID: 730D7C02726179A7

View file

@ -848,9 +848,10 @@ class MediaInfoFile(object):
# we expect only one collection # we expect only one collection
collection = collections[0] collection = collections[0]
self.log.debug("__ collection: {}".format(collection))
if collection.is_contiguous(): if collection.is_contiguous():
# if no holes then return collection return self._format_collection(collection)
return collection.format("{head}[{range}]{tail}")
# add `[` in front to make sure it want capture # add `[` in front to make sure it want capture
# shot name with the same number # shot name with the same number
@ -858,11 +859,25 @@ class MediaInfoFile(object):
# convert to multiple collections # convert to multiple collections
_continues_colls = collection.separate() _continues_colls = collection.separate()
for _coll in _continues_colls: for _coll in _continues_colls:
coll_to_text = _coll.format("{head}[{range}]{tail}") coll_to_text = self._format_collection(_coll)
self.log.debug("__ coll_to_text: {}".format(coll_to_text)) self.log.debug("__ coll_to_text: {}".format(coll_to_text))
if number_from_path in coll_to_text: if number_from_path in coll_to_text:
return coll_to_text return coll_to_text
@staticmethod
def _format_collection(collection):
# if no holes then return collection
head = collection.format("{head}")
tail = collection.format("{tail}")
range_template = "[{{:0{0}d}}-{{:0{0}d}}]".format(
len(str(max(collection.indexes))))
ranges = range_template.format(
min(collection.indexes),
max(collection.indexes)
)
# if no holes then return collection
return "{}{}{}".format(head, ranges, tail)
def _separate_file_head(self, basename, extension): def _separate_file_head(self, basename, extension):
""" Get only head with out sequence and extension """ Get only head with out sequence and extension