From 58f0fadc07e6543835d4c5dca8061766a09fb923 Mon Sep 17 00:00:00 2001 From: Jaisen Mathai Date: Sun, 3 Jan 2016 22:10:56 -0800 Subject: [PATCH] gh-61 Add support for audio (m4a) files and accompanying tests --- elodie.py | 7 +- elodie/geolocation.py | 3 +- elodie/media/audio.py | 21 ++++ elodie/media/video.py | 3 +- elodie/tests/files/audio.m4a | Bin 0 -> 10167 bytes elodie/tests/media/audio_test.py | 177 +++++++++++++++++++++++++++++++ 6 files changed, 206 insertions(+), 5 deletions(-) create mode 100644 elodie/media/audio.py create mode 100644 elodie/tests/files/audio.m4a create mode 100644 elodie/tests/media/audio_test.py diff --git a/elodie.py b/elodie.py index faa9977..623d6fa 100755 --- a/elodie.py +++ b/elodie.py @@ -10,6 +10,7 @@ from docopt import docopt from elodie import constants from elodie import geolocation from elodie.media.media import Media +from elodie.media.audio import Audio from elodie.media.photo import Photo from elodie.media.video import Video from elodie.filesystem import FileSystem @@ -34,7 +35,7 @@ FILESYSTEM = FileSystem() def import_file(_file, destination, album_from_folder): """Set file metadata and move it to destination. """ - media = Media.get_class_by_file(_file, (Photo, Video)) + media = Media.get_class_by_file(_file, [Audio, Photo, Video]) if not media: if constants.debug: print 'Not a supported file (%s)' % _file @@ -119,7 +120,7 @@ def _update(params): destination = os.path.expanduser(os.path.dirname(os.path.dirname( os.path.dirname(file_path)))) - media = Media.get_class_by_file(file_path, (Photo, Video)) + media = Media.get_class_by_file(file_path, [Audio, Photo, Video]) if not media: continue @@ -155,7 +156,7 @@ def _update(params): updated = True if updated: - updated_media = Media.get_class_by_file(file_path, (Photo, Video)) + updated_media = Media.get_class_by_file(file_path, [Audio, Photo, Video]) # See comments above on why we have to do this when titles # get updated. if remove_old_title_from_name and len(original_title) > 0: diff --git a/elodie/geolocation.py b/elodie/geolocation.py index 458b398..7318e99 100644 --- a/elodie/geolocation.py +++ b/elodie/geolocation.py @@ -92,7 +92,8 @@ def decimal_to_dms(decimal, signed=True): return ( pyexiv2.Rational(degrees, 1), pyexiv2.Rational(minutes, 1), - pyexiv2.Rational(subseconds_fraction.numerator, subseconds_fraction.denominator) # noqa + pyexiv2.Rational(subseconds_fraction.numerator, + subseconds_fraction.denominator) ) diff --git a/elodie/media/audio.py b/elodie/media/audio.py new file mode 100644 index 0000000..e373916 --- /dev/null +++ b/elodie/media/audio.py @@ -0,0 +1,21 @@ +""" +Author: Jaisen Mathai +Audio package that handles all audio operations +Inherits from Video package +""" + +from elodie import constants +from elodie import plist_parser +from media import Media +from video import Video + + +class Audio(Video): + __name__ = 'Audio' + extensions = ('m4a') + + """ + @param, source, string, The fully qualified path to the audio file + """ + def __init__(self, source=None): + super(Audio, self).__init__(source) diff --git a/elodie/media/video.py b/elodie/media/video.py index ea2d65e..f3d6ace 100644 --- a/elodie/media/video.py +++ b/elodie/media/video.py @@ -27,6 +27,7 @@ class Video(Media): """ @param, source, string, The fully qualified path to the video file + @param, Audio, class or none, The Audio class if being extendted by the Audio class """ def __init__(self, source=None): super(Video, self).__init__(source) @@ -375,7 +376,7 @@ class Video(Media): # Before we do anything destructive we confirm that the # file is in tact. - check_media = Video(temp_movie) + check_media = Media.get_class_by_file(temp_movie, [self.__class__]) check_metadata = check_media.get_metadata() if( ( diff --git a/elodie/tests/files/audio.m4a b/elodie/tests/files/audio.m4a new file mode 100644 index 0000000000000000000000000000000000000000..c60a808d44cfcbd152eaf26588fba1d5447912c4 GIT binary patch literal 10167 zcmZ{K1z1~4({L!op}0efyIb)KK}v9fYoQQaLvSfxptwt+Sa2)uUfi|NLUES@MQdNu z+xx!v|DNxkCzF}oot>T8o!v8go&x{?NUUK#u5K_oIsgLxP)sj7D+mCHnbFuxUta*+Gi@r4sOld_$$rD7!Jzwgo5KFew*vMUS~7oXD-O|su~^RRHYV;SRCwb5gK zt(|VD!NX$+niv`}i7IbIlh#>aea9l!Lv0Kijai@@tu@~HP+R>v#ZhE2 zKI2pZEg~SyR4?LICHza#j;K9ND%61pKynzaMH#56uNi|%#H^O*xAdU|M zg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