You've already forked photo-importer
mirror of
https://github.com/sashacmc/photo-importer.git
synced 2025-10-06 21:57:04 +02:00
Add add_orig_name option
Add /etc/photo-importer.cfg as additional default config Update config comments
This commit is contained in:
8
debian/changelog
vendored
8
debian/changelog
vendored
@@ -1,3 +1,11 @@
|
|||||||
|
photo-importer (1.2.2) stable; urgency=medium
|
||||||
|
|
||||||
|
* Add /etc/photo-importer.cfg as additional default config
|
||||||
|
* Add add_orig_name option
|
||||||
|
* Update config comments
|
||||||
|
|
||||||
|
-- Alexander Bushnev <Alexander@Bushnev.pro> Tue, 20 Dec 2022 01:01:34 +0100
|
||||||
|
|
||||||
photo-importer (1.2.1) stable; urgency=medium
|
photo-importer (1.2.1) stable; urgency=medium
|
||||||
|
|
||||||
* Handle server pmount errors
|
* Handle server pmount errors
|
||||||
|
@@ -20,40 +20,44 @@ file_ext_audio = mp3,3gpp,m4a,wav,aac
|
|||||||
file_ext_garbage = thm,ctg
|
file_ext_garbage = thm,ctg
|
||||||
file_ext_ignore = ini,zip,db
|
file_ext_ignore = ini,zip,db
|
||||||
|
|
||||||
# Thread count
|
# Thread count (int, count)
|
||||||
threads_count = 2
|
threads_count = 2
|
||||||
|
|
||||||
# Remove garbage files (photo config, thumbnails, etc.) 0/1
|
# Remove garbage files (photo config, thumbnails, etc.) (bool, 0/1)
|
||||||
remove_garbage = 1
|
remove_garbage = 1
|
||||||
|
|
||||||
# Remove empty directories
|
# Remove empty directories (bool, 0/1)
|
||||||
remove_empty_dirs = 1
|
remove_empty_dirs = 1
|
||||||
|
|
||||||
# Remove source files (in case of out_path specified) 0/1
|
# Remove source files (in case of out_path specified) (bool, 0/1)
|
||||||
move_mode = 1
|
move_mode = 1
|
||||||
|
|
||||||
# umask for new folder and copied files
|
# Umask for new folder and copied files (int, octal)
|
||||||
umask = 0o000
|
umask = 0o000
|
||||||
|
|
||||||
# use jpegtran in place of exiftran 0/1
|
# Use jpegtran in place of exiftran (bool, 0/1)
|
||||||
use_jpegtran = 1
|
use_jpegtran = 1
|
||||||
|
|
||||||
# use shutil libarary in place of system calls 0/1
|
# Use shutil libarary in place of system calls (bool, 0/1)
|
||||||
# slower but provide more cross platform compatibility
|
# slower but provide more cross platform compatibility
|
||||||
use_shutil = 1
|
use_shutil = 1
|
||||||
|
|
||||||
|
# Add original filename, if it does not contain a timestamp (bool, 0/1)
|
||||||
|
# (Useful if filename contains some notable information)
|
||||||
|
add_orig_name = 0
|
||||||
|
|
||||||
[server]
|
[server]
|
||||||
# server port
|
# Server port
|
||||||
port = 8080
|
port = 8080
|
||||||
|
|
||||||
# path to html files
|
# Path to html files
|
||||||
web_path = ..\web
|
web_path = ..\web
|
||||||
|
|
||||||
# imported output path
|
# Imported output path
|
||||||
out_path = C:\
|
out_path = C:\
|
||||||
|
|
||||||
# fixed input path
|
# Fixed input path
|
||||||
in_path =
|
in_path =
|
||||||
|
|
||||||
# log file
|
# Log file
|
||||||
log_file = ..\photo-importer-server.log
|
log_file = ..\photo-importer-server.log
|
||||||
|
@@ -20,40 +20,44 @@ file_ext_audio = mp3,3gpp,m4a,wav,aac
|
|||||||
file_ext_garbage = thm,ctg
|
file_ext_garbage = thm,ctg
|
||||||
file_ext_ignore = ini,zip,db
|
file_ext_ignore = ini,zip,db
|
||||||
|
|
||||||
# Thread count
|
# Thread count (int, count)
|
||||||
threads_count = 2
|
threads_count = 2
|
||||||
|
|
||||||
# Remove garbage files (photo config, thumbnails, etc.) 0/1
|
# Remove garbage files (photo config, thumbnails, etc.) (bool, 0/1)
|
||||||
remove_garbage = 1
|
remove_garbage = 1
|
||||||
|
|
||||||
# Remove empty directories
|
# Remove empty directories (bool, 0/1)
|
||||||
remove_empty_dirs = 1
|
remove_empty_dirs = 1
|
||||||
|
|
||||||
# Remove source files (in case of out_path specified) 0/1
|
# Remove source files (in case of out_path specified) (bool, 0/1)
|
||||||
move_mode = 1
|
move_mode = 1
|
||||||
|
|
||||||
# umask for new folder and copied files
|
# Umask for new folder and copied files (int, octal)
|
||||||
umask = 0o000
|
umask = 0o000
|
||||||
|
|
||||||
# use jpegtran in place of exiftran 0/1
|
# Use jpegtran in place of exiftran (bool, 0/1)
|
||||||
use_jpegtran = 0
|
use_jpegtran = 0
|
||||||
|
|
||||||
# use shutil libarary in place of system calls 0/1
|
# Use shutil libarary in place of system calls (bool, 0/1)
|
||||||
# slower but provide more cross platform compatibility
|
# slower but provide more cross platform compatibility
|
||||||
use_shutil = 0
|
use_shutil = 0
|
||||||
|
|
||||||
|
# Add original filename, if it does not contain a timestamp (bool, 0/1)
|
||||||
|
# (Useful if filename contains some notable information)
|
||||||
|
add_orig_name = 0
|
||||||
|
|
||||||
[server]
|
[server]
|
||||||
# server port
|
# Server port
|
||||||
port = 8080
|
port = 8080
|
||||||
|
|
||||||
# path to html files
|
# Path to html files
|
||||||
web_path = /usr/share/photo-importer/web/
|
web_path = /usr/share/photo-importer/web/
|
||||||
|
|
||||||
# imported output path
|
# Imported output path
|
||||||
out_path = /mnt/multimedia/NEW/
|
out_path = /mnt/multimedia/NEW/
|
||||||
|
|
||||||
# fixed input path
|
# Fixed input path
|
||||||
in_path =
|
in_path =
|
||||||
|
|
||||||
# log file
|
# Log file
|
||||||
log_file = /var/log/photo-importer-server.log
|
log_file = /var/log/photo-importer-server.log
|
||||||
|
@@ -5,7 +5,10 @@ import configparser
|
|||||||
|
|
||||||
|
|
||||||
class Config(object):
|
class Config(object):
|
||||||
DEFAULT_CONFIG_FILE = os.path.expanduser('~/.photo-importer.cfg')
|
DEFAULT_CONFIG_FILES = (
|
||||||
|
os.path.expanduser('~/.photo-importer.cfg'),
|
||||||
|
'/etc/photo-importer.cfg',
|
||||||
|
)
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
'main': {
|
'main': {
|
||||||
'out_time_format': '%%Y-%%m-%%d_%%H-%%M-%%S',
|
'out_time_format': '%%Y-%%m-%%d_%%H-%%M-%%S',
|
||||||
@@ -28,6 +31,7 @@ class Config(object):
|
|||||||
'umask': '0o000',
|
'umask': '0o000',
|
||||||
'use_jpegtran': 0,
|
'use_jpegtran': 0,
|
||||||
'use_shutil': 0,
|
'use_shutil': 0,
|
||||||
|
'add_orig_name': 0,
|
||||||
},
|
},
|
||||||
'server': {
|
'server': {
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
@@ -40,7 +44,9 @@ class Config(object):
|
|||||||
|
|
||||||
def __init__(self, filename=None, create=False):
|
def __init__(self, filename=None, create=False):
|
||||||
if filename is None:
|
if filename is None:
|
||||||
filename = self.DEFAULT_CONFIG_FILE
|
for f in self.DEFAULT_CONFIG_FILES:
|
||||||
|
if os.path.exists(f):
|
||||||
|
filename = f
|
||||||
|
|
||||||
self.__config = configparser.ConfigParser()
|
self.__config = configparser.ConfigParser()
|
||||||
self.__config.read_dict(self.DEFAULTS)
|
self.__config.read_dict(self.DEFAULTS)
|
||||||
@@ -54,10 +60,10 @@ class Config(object):
|
|||||||
self.__create_if_not_exists()
|
self.__create_if_not_exists()
|
||||||
|
|
||||||
def __create_if_not_exists(self):
|
def __create_if_not_exists(self):
|
||||||
if os.path.exists(self.DEFAULT_CONFIG_FILE):
|
if os.path.exists(self.DEFAULT_CONFIG_FILES[0]):
|
||||||
return
|
return
|
||||||
|
|
||||||
with open(self.DEFAULT_CONFIG_FILE, 'w') as conffile:
|
with open(self.DEFAULT_CONFIG_FILES[0], 'w') as conffile:
|
||||||
self.__config.write(conffile)
|
self.__config.write(conffile)
|
||||||
|
|
||||||
def __getitem__(self, sect):
|
def __getitem__(self, sect):
|
||||||
|
@@ -43,6 +43,8 @@ class FileProp(object):
|
|||||||
(re.compile('\d{8}'), '%Y%m%d'),
|
(re.compile('\d{8}'), '%Y%m%d'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
SPACE_REGEX = re.compile(r'\s+')
|
||||||
|
|
||||||
TIME_SRC_CFG = {
|
TIME_SRC_CFG = {
|
||||||
IMAGE: 'time_src_image',
|
IMAGE: 'time_src_image',
|
||||||
VIDEO: 'time_src_video',
|
VIDEO: 'time_src_video',
|
||||||
@@ -156,6 +158,15 @@ class FileProp(object):
|
|||||||
except (FileNotFoundError, KeyError) as ex:
|
except (FileNotFoundError, KeyError) as ex:
|
||||||
logging.warning('time by attr (%s) exception: %s' % (fullname, ex))
|
logging.warning('time by attr (%s) exception: %s' % (fullname, ex))
|
||||||
|
|
||||||
|
def __calc_orig_name(self, fname):
|
||||||
|
if not int(self.__config['main']['add_orig_name']):
|
||||||
|
return ''
|
||||||
|
for exp, fs in self.DATE_REGEX:
|
||||||
|
mat = exp.findall(fname)
|
||||||
|
if len(mat):
|
||||||
|
return ''
|
||||||
|
return '_' + self.SPACE_REGEX.sub('_', fname)
|
||||||
|
|
||||||
def _out_name_full(self, path, out_name, ext):
|
def _out_name_full(self, path, out_name, ext):
|
||||||
res = os.path.join(path, out_name) + ext
|
res = os.path.join(path, out_name) + ext
|
||||||
|
|
||||||
@@ -177,7 +188,9 @@ class FileProp(object):
|
|||||||
ftime = self.__time(fullname, fname, tp)
|
ftime = self.__time(fullname, fname, tp)
|
||||||
|
|
||||||
if ftime:
|
if ftime:
|
||||||
out_name = ftime.strftime(self.__config['main']['out_time_format'])
|
out_name = ftime.strftime(
|
||||||
|
self.__config['main']['out_time_format']
|
||||||
|
) + self.__calc_orig_name(fname)
|
||||||
else:
|
else:
|
||||||
out_name = None
|
out_name = None
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@@ -14,7 +14,7 @@ def get_long_description():
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='photo-importer',
|
name='photo-importer',
|
||||||
version='1.2.1',
|
version='1.2.2',
|
||||||
description='Photo importer tool',
|
description='Photo importer tool',
|
||||||
author='Alexander Bushnev',
|
author='Alexander Bushnev',
|
||||||
author_email='Alexander@Bushnev.pro',
|
author_email='Alexander@Bushnev.pro',
|
||||||
|
Reference in New Issue
Block a user