Skip to content

Commit

Permalink
added override to assign media types by media use
Browse files Browse the repository at this point in the history
  • Loading branch information
ajstanley committed Oct 27, 2024
1 parent 49e9aea commit fe5d256
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions WorkbenchConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def get_default_config(self):
"csv_value_templates_rand_length": 5,
"allow_csv_value_templates_if_field_empty": [],
"remind_user_to_run_check": False,
"media_type_by_media_use": False,
}

# Tests validity and existence of configuration file path.
Expand Down
7 changes: 7 additions & 0 deletions i7Import/i7ImportUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, config_location):
"start": 0,
"rows": 100000,
"secure_ssl_only": True,
"pids": False,
}

def get_config(self):
Expand Down Expand Up @@ -181,6 +182,12 @@ def get_default_metadata_solr_request(self):
fedora_collections.append(f'{fedora_prefix}"{collection}"')
fq_string = "&fq=" + " or ".join(fedora_collections)
query = f"{query}{fq_string}"
if self.config["pids"]:
pids_to_use = []
for candidate in self.config["pids"]:
pids_to_use.append(f"PID:{candidate}")
fq_string = "&fq=" + " or ".join(pids_to_use)
query = f"{query}{fq_string}"

# Get the populated CSV from Solr, with the object namespace and field list filters applied.
return query
Expand Down
8 changes: 8 additions & 0 deletions workbench_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ def set_media_type(config, filepath, file_fieldname, csv_row):
"""
if "media_type" in config:
return config["media_type"]
if config["media_type_by_media_use"] and len(config["media_type_by_media_use"]) > 0:
additional_files = get_additional_files_config(config)
media_url = additional_files.get(file_fieldname)
if file_fieldname in additional_files:
for entry in config["media_type_by_media_use"]:
for key, value in entry.items():
if key == media_url:
return value

# Determine if the incomtimg filepath matches a registered eEmbed media type.
oembed_media_type = get_oembed_url_media_type(config, filepath)
Expand Down

0 comments on commit fe5d256

Please sign in to comment.