1
0
mirror of https://github.com/sashacmc/photo-importer.git synced 2024-11-24 08:02:14 +02:00

* Improve removable device detection

* Add video time metadata reading (by mean of exiftool)
  * Improve audio time detection
  * Add umask option
This commit is contained in:
sashacmc 2020-11-30 10:56:33 +01:00
parent 3629a0dc78
commit 907b72d74a
9 changed files with 51 additions and 27 deletions

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
photo-importer (1.0.2) stable; urgency=medium
* Improve removable device detection
* Add video time metadata reading (by mean of exiftool)
* Improve audio time detection
* Add umask option
-- Alexander Bushnev <Alexander@Bushnev.ru> Fri, 29 May 2020 15:00:58 +0200
photo-importer (1.0.1) stable; urgency=medium
* Add outpath web interface option

View File

@ -1,8 +1,8 @@
[main]
# time source order
time_src_image = exif,name
time_src_video = name,attr
time_src_audio = name,attr
time_src_video = exif,name,attr
time_src_audio = exif,name,attr
# Date/Time formats
out_date_format = %%Y/%%Y-%%m-%%d
@ -14,9 +14,9 @@ out_subdir_video = Video
out_subdir_audio = Audio
# File extensions
file_ext_image = jpeg,jpg
file_ext_video = mp4,mpg,mpeg,mov,avi,mts
file_ext_audio = mp3,3gp,3gpp,m4a,wav
file_ext_image = jpeg,jpg,cr2
file_ext_video = mp4,mpg,mpeg,mov,avi,mts,3gp
file_ext_audio = mp3,3gpp,m4a,wav
file_ext_garbage = thm,ctg
file_ext_ignore = ini,zip,db
@ -31,6 +31,9 @@ remove_empty_dirs = 1
# Remove source files (in case of out_path specified) 0/1
move_mode = 1
# umask for new folder and copied files
umask = 0o000
[server]
# server port
@ -39,9 +42,6 @@ port = 8080
# path to html files
web_path = /usr/share/photo-importer/web/
# regexp for remote drive devices
remote_drive_reg = sd[d-z][0-9]
# imported output path
out_path = /mnt/multimedia/NEW/

View File

@ -15,16 +15,17 @@ class Config(object):
'out_subdir_audio': 'Audio',
'time_src_image': 'exif,name',
'time_src_video': 'exif,name,attr',
'time_src_audio': 'name,attr',
'time_src_audio': 'exif,name,attr',
'file_ext_image': 'jpeg,jpg',
'file_ext_video': 'mp4,mpg,mpeg,mov,avi,mts,m2ts',
'file_ext_audio': 'mp3,3gp,3gpp,m4a,wav',
'file_ext_video': 'mp4,mpg,mpeg,mov,avi,mts,m2ts,3gp',
'file_ext_audio': 'mp3,3gpp,m4a,wav',
'file_ext_garbage': 'thm,ctg',
'file_ext_ignore': 'ini,zip,db',
'remove_garbage': 1,
'remove_empty_dirs': 1,
'move_mode': 1,
'threads_count': 2,
'umask': '0o000',
},
'server': {
'port': 8080,

View File

@ -26,6 +26,8 @@ class FileProp(object):
'%Y-%m-%dT%H.%M.%S'),
(re.compile('\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}'),
'%Y-%m-%dT%H:%M:%S'),
(re.compile('\d{4}_\d{2}_\d{2}_\d{2}_\d{2}_\d{2}'),
'%Y_%m_%d_%H_%M_%S'),
(re.compile('\d{8}_\d{6}'), '%Y%m%d_%H%M%S'),
(re.compile('\d{14}'), '%Y%m%d%H%M%S'),
(re.compile('\d{8}'), '%Y%m%d'),
@ -50,7 +52,9 @@ class FileProp(object):
DATE_TAGS = [
'EXIF:DateTimeOriginal',
'H264:DateTimeOriginal',
'QuickTime:MediaCreateDate'
'QuickTime:MediaCreateDate',
'PDF:CreateDate',
'XMP:CreateDate',
]
def __init__(self, config):

View File

@ -1,14 +1,14 @@
#!/usr/bin/python3
import os
import os
import sys
import unittest
import datetime
sys.path.insert(0, os.path.abspath('..'))
from photo_importer import config
from photo_importer import fileprop
from photo_importer import config # noqa
from photo_importer import fileprop # noqa
class TestFileProp(unittest.TestCase):
@ -133,6 +133,12 @@ class TestFileProp(unittest.TestCase):
self.assertEqual(fp.time(), datetime.datetime(2017, 11, 22))
self.assertEqual(fp.ok(), False)
def test_phone4_audio(self):
fp = self.fp.get('2020_05_12_15_07_20.mp3')
self.assertEqual(fp.type(), fileprop.AUDIO)
self.assertEqual(fp.time(), datetime.datetime(2020, 5, 12, 15, 7, 20))
self.assertEqual(fp.ok(), False)
# garbage
def test_garbage(self):
fp = self.fp.get('M0101.CTG')

View File

@ -1,14 +1,17 @@
#!/usr/bin/python3
import os
import sys
import logging
import threading
from photo_importer import log
from photo_importer import mover
from photo_importer import config
from photo_importer import rotator
from photo_importer import fileprop
sys.path.insert(0, os.path.abspath('..'))
from photo_importer import log # noqa
from photo_importer import mover # noqa
from photo_importer import config # noqa
from photo_importer import rotator # noqa
from photo_importer import fileprop # noqa
class Importer(threading.Thread):
@ -118,7 +121,6 @@ class Importer(threading.Thread):
if __name__ == '__main__':
import sys
import log
log.initLogger()

View File

@ -22,10 +22,12 @@ class Mover(object):
self.__dryrun = dryrun
self.__move_mode = int(config['main']['move_mode'])
self.__remove_garbage = int(config['main']['remove_garbage'])
self.__umask = int(config['main']['umask'], 8)
self.__stat = {'total': len(filenames)}
self.__file_prop = fileprop.FileProp(self.__config)
def run(self):
os.umask(self.__umask)
self.__stat['moved'] = 0
self.__stat['copied'] = 0
self.__stat['removed'] = 0

View File

@ -9,9 +9,9 @@ import progressbar
sys.path.insert(0, os.path.abspath('..'))
from photo_importer import log
from photo_importer import config
from photo_importer import importer
from photo_importer import log # noqa
from photo_importer import config # noqa
from photo_importer import importer # noqa
class ProgressBar(threading.Thread):

View File

@ -13,9 +13,9 @@ import http.server
sys.path.insert(0, os.path.abspath('..'))
from photo_importer import log
from photo_importer import config
from photo_importer import importer
from photo_importer import log # noqa
from photo_importer import config # noqa
from photo_importer import importer # noqa
FIXED_IN_PATH_NAME = 'none'