Skip to content

Commit

Permalink
feat: add mediafile as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
boosterl committed Sep 2, 2024
1 parent bc6102c commit db697b3
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/elody/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,17 @@ def create_ticket(self, mediafile_name):
return req.text.strip().replace('"', "")

def __get_upload_location(
self, entity_id, filename, is_public=True, identifiers=None
self,
entity_id,
filename,
is_public=True,
identifiers=None,
mediafile_object=None,
):
if not identifiers:
identifiers = list()
if not mediafile_object:
mediafile_object = dict()
metadata = []
if is_public:
metadata = [
Expand All @@ -69,9 +76,12 @@ def __get_upload_location(
}
]
mediafile = {
"filename": filename,
"metadata": metadata,
"identifiers": identifiers,
**{
"filename": filename,
"metadata": metadata,
"identifiers": identifiers,
},
**mediafile_object,
}
return self.__create_mediafile(entity_id, mediafile)

Expand Down Expand Up @@ -174,13 +184,14 @@ def upload_file_from_url(
file_url,
identifiers=None,
upload_location_replace_map=None,
mediafile_object=None,
):
if not identifiers:
identifiers = list()
if not upload_location_replace_map:
upload_location_replace_map = dict()
upload_location = self.__get_upload_location(
entity_id, filename, True, identifiers
entity_id, filename, True, identifiers, mediafile_object
)
for current_location, new_location in upload_location_replace_map.items():
upload_location = upload_location.replace(current_location, new_location)
Expand Down

0 comments on commit db697b3

Please sign in to comment.