The Flickr upload API allows to specify dedup_check parameter with value either 1 or 2. This is actually what the official Flickr Uploadr app is using by default. When a duplicate photo is detected, the response returns the ID of the original photo. The photo being duplicate does not seem like a hard error to me, that's why this change proposes to add FlickrDuplicate exception that stores the photo ID.
This way it is possible to construct a piece of code that always returns photo ID:
with open(file_path, 'rb') as fp:
try:
rsp = flickr_handle.upload(file_path, fileobj=fp,
**params)
logger.debug(ElementTree.tostring(rsp, 'utf-8'))
photo_id = rsp.find('photoid')
if photo_id is not None:
res = photo_id.text
except flickrapi.exceptions.FlickrDuplicate as e:
logger.info("Duplicate photo '{}' with ID {}".
format(file_path, e.duplicate_photo_id))
res = e.duplicate_photo_id
which is particularly useful when uploading set of photos and adding them to an album.
I was not able to get parse_json() to work with flickr_handle.upload() - even though the flickr handle was constructed with format='parsed-json', the parse_json() still received XML as input. So I left it unchanged.
The Flickr upload API allows to specify
dedup_check
parameter with value either 1 or 2. This is actually what the official Flickr Uploadr app is using by default. When a duplicate photo is detected, the response returns the ID of the original photo. The photo being duplicate does not seem like a hard error to me, that's why this change proposes to addFlickrDuplicate
exception that stores the photo ID.This way it is possible to construct a piece of code that always returns photo ID:
which is particularly useful when uploading set of photos and adding them to an album.
I was not able to get
parse_json()
to work withflickr_handle.upload()
- even though the flickr handle was constructed withformat='parsed-json'
, theparse_json()
still received XML as input. So I left it unchanged.