Extremly simple. To obtain api_key/api_secret one has to register. User authentication (obtaining auth_token/oauth_token_secret) is performed first time the script below is executed. The credentials are stored in ./flickr/oauth-tokens.sqlite
.
I experienced an error sqlite3.OperationalError: no such table
while using genuine flickrapi (ie installed from a Debian package). Installing via pip install
fixed the problem. Also perms
should be write
not read
as in a documentation (https://stuvel.eu/flickrapi-doc/3-auth.html#non-web-applications) Thats all...
#!/usr/bin/env python
#
# pip install flickrapi
#
# https://stuvel.eu/flickrapi-doc/4-uploading.html#flickr-upload
import flickrapi
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-p", type=str, help="picture")
parser.add_argument("-t", type=str, help="title")
parser.add_argument("-k", type=str, help="keywords")
args = parser.parse_args()
pic = args.p
pictitle = args.t
pickws = args.k
##
api_key=u'#########################'
api_secret=u'####################'
flickr = flickrapi.FlickrAPI(api_key, api_secret)
flickr.authenticate_via_browser(perms='write')
###################################### ^^^^^
###
flickr.upload(filename=pic, title=pictitle, tags=pickws)
###