Add interactive bulk metadata editor with GPS input
This commit is contained in:
1 parent
5842d52784
commit
6f0fcdaaca
3 files changed
+378
No files matched your search
@@ -15,6 +15,7 @@ from tools.audio_batch import (
|
||||
universal_containers,
|
||||
)
|
||||
from tools.audio_settings import parse_bitrate, resolve_output_dir
|
||||
from tools.metadata_editor import Field, REMOVE, parse_gps_coordinates, write_arguments
|
||||
|
||||
|
||||
class AudioBatchTests(unittest.TestCase):
|
||||
@@ -67,6 +68,33 @@ class AudioBatchTests(unittest.TestCase):
|
||||
self.assertEqual(second, output_dir / "song-1.opus")
|
||||
|
||||
|
||||
class MetadataEditorTests(unittest.TestCase):
|
||||
def test_decimal_and_ascii_dms_gps_are_equivalent(self) -> None:
|
||||
self.assertEqual(parse_gps_coordinates("58.660600, 16.448300"), (58.6606, 16.4483))
|
||||
latitude, longitude = parse_gps_coordinates("58 39 38.16 N, 16:26:53.88E")
|
||||
self.assertAlmostEqual(latitude, 58.6606)
|
||||
self.assertAlmostEqual(longitude, 16.4483)
|
||||
|
||||
def test_negative_decimal_coordinates_mean_south_and_west(self) -> None:
|
||||
self.assertEqual(parse_gps_coordinates("-58.5, -16.25"), (-58.5, -16.25))
|
||||
with self.assertRaisesRegex(ValueError, "cannot use N"):
|
||||
parse_gps_coordinates("-58.5 N, 16.25 E")
|
||||
|
||||
def test_gps_writes_use_decimal_values_and_hemisphere_refs(self) -> None:
|
||||
field = Field("GPS coordinates", (), "gps", pending="58.660600, -16.448300")
|
||||
self.assertEqual(
|
||||
write_arguments([field]),
|
||||
[
|
||||
"-EXIF:GPSLatitude=58.66060000",
|
||||
"-EXIF:GPSLatitudeRef=N",
|
||||
"-EXIF:GPSLongitude=16.44830000",
|
||||
"-EXIF:GPSLongitudeRef=W",
|
||||
],
|
||||
)
|
||||
|
||||
def test_remove_gps_removes_coordinate_and_ref_tags(self) -> None:
|
||||
field = Field("GPS coordinates", (), "gps", pending=REMOVE)
|
||||
self.assertEqual(len(write_arguments([field])), 4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user