diff --git a/pandora_incoming.py b/pandora_incoming.py index de5371d..1d3321e 100644 --- a/pandora_incoming.py +++ b/pandora_incoming.py @@ -46,6 +46,20 @@ class Incoming(object): def import_media(self, f): filename = os.path.basename(f) + defaults = self.config['defaults'] + + # try to load default values from tree + folder = os.path.dirname(f) + while len(folder) > len(self.config['folder']): + defaults_json = os.path.join(folder, 'defaults.json') + if os.path.exists(defaults_json): + try: + with open(defaults_json) as fd: + defaults = json.load(fd) + break + except: + pass + folder = os.path.dirname(folder) # register file with pan.do/ra info = ox.avinfo(f) @@ -68,7 +82,7 @@ class Incoming(object): # update item with default metadata item = r['data']['item'] item_info = {'id': item} - item_info.update(self.config['defaults']) + item_info.update(defaults) self.api.edit(item_info) # upload media file