2023-11-04 22:37:28 +00:00
|
|
|
import flickrapi
|
2023-11-05 14:22:32 +00:00
|
|
|
import load_config
|
2023-11-04 22:37:28 +00:00
|
|
|
|
2023-11-05 14:22:32 +00:00
|
|
|
print("Authenticating with Flickr")
|
2023-11-05 14:42:08 +00:00
|
|
|
flickr = flickrapi.FlickrAPI(load_config.config['flickr']['app_api'], load_config.config['flickr']['app_secret'])
|
2023-11-05 14:22:32 +00:00
|
|
|
flickr.authenticate_via_browser(perms='write')
|
2023-11-04 22:37:28 +00:00
|
|
|
|
2023-11-05 14:22:32 +00:00
|
|
|
def upload(file_data: list):
|
|
|
|
for file in file_data:
|
|
|
|
print(file)
|
|
|
|
flickr.upload(
|
|
|
|
filename = file['path'],
|
|
|
|
title = file['title'],
|
|
|
|
description = file['description'],
|
|
|
|
tags = prepareTags(file['tags']),
|
|
|
|
is_public = 1,
|
|
|
|
format = 'rest'
|
|
|
|
)
|
2023-11-05 14:42:08 +00:00
|
|
|
print("Uploading to Flickr")
|
2023-11-04 22:37:28 +00:00
|
|
|
|
2023-11-05 14:22:32 +00:00
|
|
|
def prepareTags(input_list: list):
|
|
|
|
output_list = []
|
|
|
|
for item in input_list:
|
|
|
|
if ' ' in item:
|
|
|
|
output_list.append(f"'{item}'")
|
|
|
|
else:
|
|
|
|
output_list.append(item)
|
|
|
|
return ' '.join(output_list)
|