diff --git a/src/photini/flickr.py b/src/photini/flickr.py index 751db7f4..c35886ce 100644 --- a/src/photini/flickr.py +++ b/src/photini/flickr.py @@ -248,16 +248,19 @@ def set_notes(self, params, photo_id): return 'Failed to delete note' # add new notes for note in params['notes']: - if not note['is_person']: - rsp = self.api_call( - 'flickr.photos.notes.add', post=True, photo_id=photo_id, - note_x=note['x'], note_y=note['y'], note_w=note['w'], - note_h=note['h'], note_text=note['content']) - elif note['content'] == self.user_data['fullname']: + if (note['is_person'] and + note['content'] == self.user_data['fullname']): rsp = self.api_call( 'flickr.photos.people.add', post=True, photo_id=photo_id, person_x=note['x'], person_y=note['y'], person_w=note['w'], person_h=note['h'], user_id=self.user_data['user_nsid']) + if rsp is None: + return 'Failed to add person' + # flickr.photos.people.add doesn't show a box, so do it separately + rsp = self.api_call( + 'flickr.photos.notes.add', post=True, photo_id=photo_id, + note_x=note['x'], note_y=note['y'], note_w=note['w'], + note_h=note['h'], note_text=note['content']) if rsp is None: return 'Failed to add note' return '' @@ -650,11 +653,6 @@ def get_params(self, image, upload_prefs, replace_prefs, photo_id): params['notes'] = [] for note in image.metadata.image_region.to_notes(image, 500): params['notes'].append(note) - if note['is_person']: - # Flickr doesn't show box around person, so add one - note = dict(note) - note['is_person'] = False - params['notes'].append(note) return params def replace_dialog(self, image): diff --git a/src/photini/types.py b/src/photini/types.py index 9b6dc4ca..6201e097 100644 --- a/src/photini/types.py +++ b/src/photini/types.py @@ -2335,20 +2335,18 @@ def to_notes(self, image, target_size): for region, note in self.to_note_boundary(image, target_size): note['content'] = '' note['is_person'] = False - if region.has_type('human'): - if 'Iptc4xmpExt:PersonInImage' in region: - note['content'] = ', '.join( - region['Iptc4xmpExt:PersonInImage']) + if region.has_type('human') or region.has_type('Face'): + note['content'] = ', '.join(region['Iptc4xmpExt:PersonInImage']) note['is_person'] = True elif not any(region.has_role(x) for x in ( 'subjectArea', 'mainSubjectArea', 'areaOfInterest')): continue - if 'dc:description' in region and not note['content']: - note['content'] = MD_LangAlt( - region['dc:description']).best_match() - if 'Iptc4xmpExt:Name' in region and not note['content']: - note['content'] = MD_LangAlt( - region['Iptc4xmpExt:Name']).best_match() + if not note['content']: + note['content'] = region['dc:description'].best_match() + if not note['content']: + note['content'] = ', '.join(region['Iptc4xmpExt:PersonInImage']) + if not note['content']: + note['content'] = region['Iptc4xmpExt:Name'].best_match() if not note['content']: continue result.append(note)