Skip to content

Commit

Permalink
update file naming
Browse files Browse the repository at this point in the history
  • Loading branch information
alec-bertoy committed Oct 20, 2023
1 parent 4ae1068 commit 7de32e9
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def audio_processor_main():
# json filename should use the filename found in the inventory
json_file_abspath = os.path.join(
meta_folder_abspath,
inventory_filename + "-" + metadata_identifier + ".json",
inventory_filename + "_s" + ".json",
)

# generate ffprobe metadata from input
Expand Down Expand Up @@ -281,7 +281,7 @@ def audio_processor_main():
"1920",
"-o",
os.path.join(
meta_folder_abspath, base_filename + "spectrogram" + ".png"
meta_folder_abspath, base_filename + "spectrogram_s.png"
),
]
subprocess.run(sox_spectrogram_command)
Expand Down
14 changes: 7 additions & 7 deletions AV/Video/aja_mov2ffv1/aja_mov2ffv1/mov2ffv1mainfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def aja_mov2ffv1_main():
# identifier appended to the end of the MKV preservation file
# Replace with "None" to keep the name the same as the input
if not args.keep_filename:
pm_filename_identifier = "-p"
pm_filename_identifier = "_p"
else:
pm_filename_identifier = None
inventoryName = "transcode_inventory.csv"
Expand Down Expand Up @@ -96,16 +96,16 @@ def aja_mov2ffv1_main():
)
mkvFilename = mkvBaseFilename + ".mkv"
outputAbsPath = os.path.join(pmOutputFolder, mkvFilename)
tempMasterFile = os.path.join(pmOutputFolder, baseFilename + "-tmp.mkv")
tempMasterFile = os.path.join(pmOutputFolder, baseFilename + "_tmp.mkv")
framemd5File = mkvBaseFilename + ".framemd5"
framemd5AbsPath = os.path.join(pmOutputFolder, framemd5File)
acOutputFolder = os.path.join(baseOutput, ac_identifier)
acAbsPath = os.path.join(
acOutputFolder, baseFilename + "-" + ac_identifier + ".mp4"
acOutputFolder, baseFilename + "_" + ac_identifier + ".mp4"
)
metaOutputFolder = os.path.join(baseOutput, metadata_identifier)
jsonAbsPath = os.path.join(
metaOutputFolder, baseFilename + "-" + metadata_identifier + ".json"
metaOutputFolder, baseFilename + "_s" + ".json"
)
pmMD5AbsPath = os.path.join(pmOutputFolder, mkvBaseFilename + ".md5")

Expand Down Expand Up @@ -230,21 +230,21 @@ def aja_mov2ffv1_main():
acHash = corefuncs.hashlib_md5(acAbsPath)
with open(
os.path.join(
acOutputFolder, baseFilename + "-" + ac_identifier + ".md5"
acOutputFolder, baseFilename + "_" + ac_identifier + ".md5"
),
"w",
newline="\n",
) as f:
print(
acHash,
"*" + baseFilename + "-" + ac_identifier + ".mp4",
"*" + baseFilename + "_" + ac_identifier + ".mp4",
file=f,
)

# log access copy filename if access copy was created
# TO DO: verify that access copy runtime matches pm runtime?
if os.path.isfile(acAbsPath):
acFilename = baseFilename + "-" + ac_identifier + ".mp4"
acFilename = baseFilename + "_" + ac_identifier + ".mp4"
else:
acFilename = "No access copy found"

Expand Down
2 changes: 1 addition & 1 deletion AV/Video/aja_mov2ffv1/aja_mov2ffv1/mov2ffv1supportfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def generate_spectrogram(input, channel_layout_list, outputFolder, outputName):
"""
spectrogram_resolution = "1920x1080"
for index, item in enumerate(channel_layout_list):
output = os.path.join(outputFolder, outputName + "_0a" + str(index) + ".png")
output = os.path.join(outputFolder, outputName + "_spectrogram0" + str(index) + "_s.png")
spectrogram_args = [args.ffmpeg_path]
spectrogram_args += ["-loglevel", "error", "-y"]
spectrogram_args += ["-i", input, "-lavfi"]
Expand Down
2 changes: 0 additions & 2 deletions Image/Inventory/inventory_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ def proj_name_check_again():
"filename",
"label",
"description",
"Checked in? (yes/no)"
"Packing & Shipping Check in? (yes/no)"
"Capture date",
"Staff Initials",
"Container number ex. Box Number",
Expand Down
92 changes: 39 additions & 53 deletions Meadow/mig_av/mig_av/mig_av.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ def mig_av_main():
"file_builder": "_supplementary_",
},
"spectrogram": {
"identifiers": [".png", ".PNG"],
"type": "extension",
"identifiers": ["spectrogram"],
"type": "pattern",
"role": "S",
"label": "spectrogram file",
"file_builder": "_supplementary_",
Expand All @@ -274,7 +274,6 @@ def mig_av_main():
"_am_",
"-am-",
"-am_",
".mp4",
"_access",
],
"type": "pattern",
Expand All @@ -291,38 +290,18 @@ def mig_av_main():
"_pm_",
"-pm-",
"-pm_",
".mkv",
"_preservation",
],
"type": "pattern",
"role": "P",
"label": None,
"file_builder": "_preservation_",
},
"auxiliary": {
"identifiers": [".jpg", ".JPG"],
"type": "extension",
"role": "X",
"label": "image",
"file_builder": "_auxiliary_",
},
}
if not args.aux_parse:
aux_dict = {
"auxiliary": {
"identifiers": None,
"type": None,
"role": None,
"label": None,
"file_builder": None,
}
}
# add empty aux_dict as generic catch-all to the end of role_dict
role_dict.update(aux_dict)
else:
if args.aux_parse:
if "extension" in args.aux_parse:
aux_dict = {
"auxiliay": {
"auxiliary": {
"identifiers": [".jpg", ".JPG"],
"type": "extension",
"role": "X",
Expand All @@ -332,38 +311,45 @@ def mig_av_main():
}
elif "parse" in args.aux_parse:
aux_dict = {
"auxiliary": {
"identifiers": [
"_Asset",
"-Asset",
"_Can",
"-Can",
"Front.",
"Back.",
"_Ephemera",
"-Ephemera",
],
"type": "xparse",
"front": {
"identifiers": ["Front."],
"type": "pattern",
"role": "X",
"label": None,
"label": "asset front",
"file_builder": "_auxiliary_",
}
},
"back": {
"identifiers": ["Back."],
"type": "pattern",
"role": "X",
"label": "asset back",
"file_builder": "_auxiliary_",
},
"asset": {
"identifiers": ["_Asset", "-Asset"],
"type": "pattern",
"role": "X",
"label": "asset",
"file_builder": "_auxiliary_",
},
"can": {
"identifiers": ["_Can", "-Can"],
"type": "pattern",
"role": "X",
"label": "can",
"file_builder": "_auxiliary_",
},
"ephemera": {
"identifiers": ["_Ephemera", "-Ephemera"],
"type": "pattern",
"role": "X",
"label": "ephemera",
"file_builder": "_auxiliary_",
},
}
# add the aux_dict to the beginning of the role_dict
# this will catch X files that also have a/p identifiers in the filename
role_dict = {**aux_dict, **role_dict}
# add generic catch-all for unexpected file types to the end of role_dict
role_dict.update(
{
"other": {
"identifiers": None,
"type": None,
"role": None,
"label": None,
"file_builder": None,
}
}
)

header_names = [
"work_type",
Expand Down Expand Up @@ -519,8 +505,8 @@ def mig_av_main():
# allow user to add the file anyway
if not any(item in file for item in filename_list):
print(
'''"+++ WARNING: No entry matching " + file + " was found
in your inventory +++"'''
"+++ WARNING: No entry matching " + file +
" was found in your inventory +++"
)

# TODO final check that all ihidden files and folderstems from filename list are accounted for in the final inventory
Expand Down
50 changes: 20 additions & 30 deletions Meadow/mig_av/mig_av/mig_av_parser_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,29 @@

def get_label(role_dict, filename, inventory_label):
# run through each key in role_dict
# if it matches on extension, it should be removed and passed to the next check
label = None
role_index = -1
for i in role_dict:
if not label:
if role_dict[i]["type"] == "extension":
if filename.endswith(tuple(role_dict[i]["identifiers"])):
role = role_dict[i]["role"]
if not role == "X" and not inventory_label:
label = role_dict[i]["label"]
elif inventory_label:
label = inventory_label + " " + role_dict[i]["label"]
else:
label = "Asset " + role_dict[i]["label"]
file_builder = role_dict[i]["file_builder"]
elif role_dict[i]["type"] == "xparse":
if any(ext in filename for ext in role_dict[i]["identifiers"]):
label = xparser(
filename, role_dict[i]["identifiers"], inventory_label
)
role = role_dict[i]["role"]
file_builder = role_dict[i]["file_builder"]
elif role_dict[i]["type"] == "pattern":
if any(ext in filename for ext in role_dict[i]["identifiers"]):
label = label_creator(filename, inventory_label)
role = role_dict[i]["role"]
file_builder = role_dict[i]["file_builder"]
elif not label:
label = filename
role = "S"
file_builder = "_supplementary_"
return label, role, file_builder
if any(ext in filename for ext in role_dict[i]["identifiers"]):
role_index = i
break

# base case if role not found
if role_index == -1:
label = filename
role = "S"
file_builder = "_supplementary_"
else:
role = role_dict[role_index]["role"]
file_builder = role_dict[i]["file_builder"]
label = label_creator(filename, inventory_label)

#append label if role has extra info
if role_dict[role_index]["label"]:
label += " " + role_dict[role_index]["label"]

return label, role, file_builder

# no longer necessary
def xparser(filename, pattern_list, inventory_label):
# TODO use regex instead so numbers could be extracted
parser_dict = {
Expand Down

0 comments on commit 7de32e9

Please sign in to comment.