Permalink
Browse files

Merge b94372b into 91bf181

  • Loading branch information...
DZamataev committed Dec 28, 2018
2 parents 91bf181 + b94372b commit 0905892f53d50e116488cc812a43cb826513e577
Showing with 43 additions and 4 deletions.
  1. +4 −0 Readme.md
  2. +1 −0 config.ini-sample
  3. +4 −1 elodie.py
  4. +3 −0 elodie/constants.py
  5. +7 −2 elodie/filesystem.py
  6. +24 −1 elodie/geolocation.py
@@ -282,6 +282,8 @@ You can, of course, ask me to change the location and time. I'll happily update
./elodie.py update --location="Las Vegas, NV" --time="2015-04-15" /where/i/want/my/photos/to/go/2015-09-Sep/Unknown\ Location/2015-09-27_01-41-38-_dsc8705.dng /where/i/want/my/photos/to/go/2015-09-Sep/Unknown\ Location/2015-09-27_01-41-38-_dsc8705.nef
```

To put media according to it's type to a folder like 'Audio', 'Video' or 'Photo' at it's final destination add `--separate-media-folders`.

## What about photos I take in the future?

Organizing your existing photos is great. But I'd be lying if I said I was the only one who could help you with that. Unlike other programs I put the same effort into keeping your library organized into the future as I have in getting it organized in the first place.
@@ -342,6 +344,8 @@ cp config.ini-sample ~/.elodie/config.ini
# now you're ready to add your MapQuest key
```

If you're an english speaker then you will probably want to add `prefer_english_names=True` to the `[MapQuest]` section else you'll have cities named using the local language.

## Questions, comments or concerns?

The best ways to provide feedback is by opening a [GitHub issue](https://github.com/jmathai/elodie/issues) or emailing me at [jaisen@jmathai.com](mailto:jaisen@jmathai.com).
@@ -1,2 +1,3 @@
[MapQuest]
key=your-api-key-goes-here
prefer_english_names=False
@@ -85,11 +85,14 @@ def import_file(_file, destination, album_from_folder, trash, allow_duplicates):
help='Import the file even if it\'s already been imported.')
@click.option('--debug', default=False, is_flag=True,
help='Override the value in constants.py with True.')
@click.option('--separate-media-folders', default=False, is_flag=True,
help='Separate folders for audio and video at their final destination. Overrides the value in constants.py with True.')
@click.argument('paths', nargs=-1, type=click.Path())
def _import(destination, source, file, album_from_folder, trash, allow_duplicates, debug, paths):
def _import(destination, source, file, album_from_folder, trash, allow_duplicates, debug, separate_media_folders, paths):
"""Import files or directories by reading their EXIF and organizing them accordingly.
"""
constants.debug = debug
constants.separate_media_folders = separate_media_folders
has_errors = False
result = Result()

@@ -28,3 +28,6 @@

# check python version, required in filesystem.py to trigger appropriate method
python_version = version_info.major

# Separate folders for audio and video at their final destination.
separate_media_folders = False
@@ -14,6 +14,7 @@
from elodie import compatability
from elodie import geolocation
from elodie import log
from elodie import constants
from elodie.config import load_config
from elodie.localstorage import Db
from elodie.media.base import Base, get_all_subclasses
@@ -215,7 +216,7 @@ def get_folder_path_definition(self):

return self.cached_folder_path_definition

def get_folder_path(self, metadata):
def get_folder_path(self, metadata, media_name=None):
"""Given a media's metadata this function returns the folder path as a string.
:param metadata dict: Metadata dictionary.
@@ -258,6 +259,9 @@ def get_folder_path(self, metadata):
elif part.startswith('"') and part.endswith('"'):
path.append(part[1:-1])

if (constants.separate_media_folders and media_name):
path.append(media_name)

return os.path.join(*path)

def parse_mask_for_location(self, mask, location_parts, place_name):
@@ -335,8 +339,9 @@ def process_file(self, _file, destination, media, **kwargs):

media.set_original_name()
metadata = media.get_metadata()
media_name = media.__name__

directory_name = self.get_folder_path(metadata)
directory_name = self.get_folder_path(metadata, media_name)

dest_directory = os.path.join(destination, directory_name)
file_name = self.get_file_name(media)
@@ -20,6 +20,7 @@

__KEY__ = None
__DEFAULT_LOCATION__ = 'Unknown Location'
__PREFER_ENGLISH_NAMES__ = None


def coordinates_by_name(name):
@@ -114,6 +115,24 @@ def get_key():
__KEY__ = config['MapQuest']['key']
return __KEY__

def get_prefer_english_names():
global __PREFER_ENGLISH_NAMES__
if __PREFER_ENGLISH_NAMES__ is not None:
return __PREFER_ENGLISH_NAMES__

config_file = '%s/config.ini' % constants.application_directory
if not path.exists(config_file):
return False

config = load_config()
if('MapQuest' not in config):
return False

if('prefer_english_names' not in config['MapQuest']):
return False

__PREFER_ENGLISH_NAMES__ = bool(config['MapQuest']['prefer_english_names'])
return __PREFER_ENGLISH_NAMES__

def place_name(lat, lon):
lookup_place_name_default = {'default': __DEFAULT_LOCATION__}
@@ -167,6 +186,7 @@ def lookup(**kwargs):
return None

key = get_key()
prefer_english_names = get_prefer_english_names()

if(key is None):
return None
@@ -181,7 +201,10 @@ def lookup(**kwargs):
path,
urllib.parse.urlencode(params)
)
r = requests.get(url)
headers = {}
if(prefer_english_names):
headers = {'Accept-Language':'en-EN,en;q=0.8'}
r = requests.get(url, headers=headers)
return parse_result(r.json())
except requests.exceptions.RequestException as e:
log.error(e)

0 comments on commit 0905892

Please sign in to comment.