2016-05-24 22:53:03 -04:00
|
|
|
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
|
|
|
|
#
|
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 16:33:16 -05:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2011-09-20 18:40:27 -04:00
|
|
|
|
2016-05-30 22:27:59 -04:00
|
|
|
import os.path as op
|
|
|
|
|
|
|
|
from core.app import DupeGuru as DupeGuruBase, AppMode, cmp_value
|
2011-09-21 10:26:58 -04:00
|
|
|
from core import prioritize
|
2016-05-29 22:37:38 -04:00
|
|
|
import core_me.fs
|
|
|
|
import core_me.prioritize
|
|
|
|
import core_me.result_table
|
|
|
|
import core_me.scanner
|
2016-05-30 22:27:59 -04:00
|
|
|
import core_pe.photo
|
|
|
|
import core_pe.prioritize
|
|
|
|
import core_pe.result_table
|
|
|
|
import core_pe.scanner
|
|
|
|
from core_pe.photo import get_delta_dimensions
|
2016-05-24 22:53:03 -04:00
|
|
|
from . import __appname__, fs, scanner
|
2011-11-27 12:47:00 -05:00
|
|
|
from .result_table import ResultTable
|
2011-09-20 18:40:27 -04:00
|
|
|
|
|
|
|
class DupeGuru(DupeGuruBase):
|
2011-09-21 10:35:34 -04:00
|
|
|
NAME = __appname__
|
2016-05-24 22:53:03 -04:00
|
|
|
|
2013-10-12 13:54:13 -04:00
|
|
|
def __init__(self, view):
|
|
|
|
DupeGuruBase.__init__(self, view)
|
2016-05-29 17:15:55 -04:00
|
|
|
self.folderclass = fs.Folder
|
2016-05-30 22:27:59 -04:00
|
|
|
self.options['cache_path'] = op.join(self.appdata, 'cached_pictures.db')
|
2016-05-24 22:53:03 -04:00
|
|
|
|
2016-05-29 22:37:38 -04:00
|
|
|
def _get_dupe_sort_key(self, dupe, get_group, key, delta):
|
2016-05-30 22:27:59 -04:00
|
|
|
if self.app_mode in (AppMode.Music, AppMode.Picture):
|
2016-05-29 22:37:38 -04:00
|
|
|
if key == 'folder_path':
|
|
|
|
dupe_folder_path = getattr(dupe, 'display_folder_path', dupe.folder_path)
|
|
|
|
return str(dupe_folder_path).lower()
|
2016-05-30 22:27:59 -04:00
|
|
|
if self.app_mode == AppMode.Picture:
|
|
|
|
if delta and key == 'dimensions':
|
|
|
|
r = cmp_value(dupe, key)
|
|
|
|
ref_value = cmp_value(get_group().ref, key)
|
|
|
|
return get_delta_dimensions(r, ref_value)
|
2016-05-29 22:37:38 -04:00
|
|
|
return DupeGuruBase._get_dupe_sort_key(self, dupe, get_group, key, delta)
|
|
|
|
|
|
|
|
def _get_group_sort_key(self, group, key):
|
2016-05-30 22:27:59 -04:00
|
|
|
if self.app_mode in (AppMode.Music, AppMode.Picture):
|
2016-05-29 22:37:38 -04:00
|
|
|
if key == 'folder_path':
|
|
|
|
dupe_folder_path = getattr(group.ref, 'display_folder_path', group.ref.folder_path)
|
|
|
|
return str(dupe_folder_path).lower()
|
|
|
|
return DupeGuruBase._get_group_sort_key(self, group, key)
|
|
|
|
|
2011-09-21 10:26:58 -04:00
|
|
|
def _prioritization_categories(self):
|
2016-05-30 22:27:59 -04:00
|
|
|
if self.app_mode == AppMode.Picture:
|
|
|
|
return core_pe.prioritize.all_categories()
|
|
|
|
elif self.app_mode == AppMode.Music:
|
|
|
|
return core_me.prioritize.all_categories()
|
2016-05-29 22:37:38 -04:00
|
|
|
else:
|
|
|
|
return prioritize.all_categories()
|
2016-05-24 22:53:03 -04:00
|
|
|
|
2012-01-13 16:34:21 -05:00
|
|
|
def _create_result_table(self):
|
2016-05-30 22:27:59 -04:00
|
|
|
if self.app_mode == AppMode.Picture:
|
|
|
|
return core_pe.result_table.ResultTable(self)
|
|
|
|
elif self.app_mode == AppMode.Music:
|
2016-05-29 22:37:38 -04:00
|
|
|
return core_me.result_table.ResultTable(self)
|
|
|
|
else:
|
|
|
|
return ResultTable(self)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def fileclasses(self):
|
2016-05-30 22:27:59 -04:00
|
|
|
if self.app_mode == AppMode.Picture:
|
|
|
|
return [core_pe.photo.PLAT_SPECIFIC_PHOTO_CLASS]
|
|
|
|
elif self.app_mode == AppMode.Music:
|
2016-05-29 22:37:38 -04:00
|
|
|
return [core_me.fs.MusicFile]
|
|
|
|
else:
|
|
|
|
return [fs.File]
|
|
|
|
|
|
|
|
@property
|
|
|
|
def SCANNER_CLASS(self):
|
2016-05-30 22:27:59 -04:00
|
|
|
if self.app_mode == AppMode.Picture:
|
|
|
|
return core_pe.scanner.ScannerPE
|
|
|
|
elif self.app_mode == AppMode.Music:
|
2016-05-29 22:37:38 -04:00
|
|
|
return core_me.scanner.ScannerME
|
|
|
|
else:
|
|
|
|
return scanner.ScannerSE
|
|
|
|
|
|
|
|
@property
|
|
|
|
def METADATA_TO_READ(self):
|
2016-05-30 22:27:59 -04:00
|
|
|
if self.app_mode == AppMode.Picture:
|
|
|
|
return ['size', 'mtime', 'dimensions', 'exif_timestamp']
|
|
|
|
elif self.app_mode == AppMode.Music:
|
2016-05-29 22:37:38 -04:00
|
|
|
return [
|
|
|
|
'size', 'mtime', 'duration', 'bitrate', 'samplerate', 'title', 'artist',
|
|
|
|
'album', 'genre', 'year', 'track', 'comment'
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
return ['size', 'mtime']
|
2016-05-24 22:53:03 -04:00
|
|
|
|