Alphabetize _reload_audio_metadata.

This commit is contained in:
voussoir 2022-08-13 18:09:53 -07:00
parent d15e8325aa
commit 0864572930
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -1216,6 +1216,21 @@ class Photo(ObjectBase):
new_path.assert_not_exists() new_path.assert_not_exists()
self.rename_file(new_path.absolute_path, move=True) self.rename_file(new_path.absolute_path, move=True)
def _reload_audio_metadata(self):
if not constants.ffmpeg:
return
try:
probe = constants.ffmpeg.probe(self.real_path.absolute_path)
except Exception:
traceback.print_exc()
return
if not probe or not probe.audio:
return
self.duration = probe.audio.duration
def _reload_image_metadata(self): def _reload_image_metadata(self):
try: try:
image = PIL.Image.open(self.real_path.absolute_path) image = PIL.Image.open(self.real_path.absolute_path)
@ -1243,21 +1258,6 @@ class Photo(ObjectBase):
self.height = probe.video.video_height self.height = probe.video.video_height
self.duration = probe.format.duration or probe.video.duration self.duration = probe.format.duration or probe.video.duration
def _reload_audio_metadata(self):
if not constants.ffmpeg:
return
try:
probe = constants.ffmpeg.probe(self.real_path.absolute_path)
except Exception:
traceback.print_exc()
return
if not probe or not probe.audio:
return
self.duration = probe.audio.duration
@decorators.required_feature('photo.reload_metadata') @decorators.required_feature('photo.reload_metadata')
@worms.atomic @worms.atomic
def reload_metadata(self, hash_kwargs=None) -> None: def reload_metadata(self, hash_kwargs=None) -> None: