Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Assets with Digital Instantiation of media type "Sound" and Physical Instantiation of media type "Moving Image" use <video> tag instead of <audio> #2735

Open
afred opened this issue Mar 22, 2024 · 1 comment
Labels

Comments

@afred
Copy link
Contributor

afred commented Mar 22, 2024

Reproduce

  1. Log into VPN to simulate presence i the GBH office for access to on-premises records.
  2. Go to https://americanarchive.org/catalog/cpb-aacip-338cf0f565b
  3. View source of the page

Expected behavior

  1. media plays
  2. HTML rendered using <audio> tag, and not a <video> tag

Actual behavior

  1. media does not play
  2. HTML is rendered using <video> tag instad of <audio> tag

Background

The logic that determines the media type will return "Moving Image" before "Sound" if both are found among the media types of the Asset's instantiations. However, it's not filtering out the Physical instantiations.

It's not that common for an Asset to have both a "Moving Image" instantiation and a "Sound" instantiation, however, there are some cases where there is a "Moving Image" Physical Instantiation and a "Sound" Digital Instantiation. In this case, we want to render an <audio> element to play the sound. The Physical Instantiation in the example record of this ticket (and others presumably) came in from the original metadata submitted by the station.

@afred afred added the bug 🐛 label Mar 22, 2024
@owencking
Copy link
Contributor

I believe the right way to address this is to narrow down to just the pbcoreInstantiation elements that include instantiationDigital as a sub-element. In the (very few) cases where there are multiple digital instantiations but they do not have the same media type, it's probably(?) safe to assume that the media type is "Moving Image", if that's an option, else "Sound", if that's an option.

Here's how I'm doing it in Python

import xml.etree.ElementTree as ET

tree = ET.parse(xml_filepath)
root = tree.getroot()
ns = {"pbcore": "http://www.pbcore.org/PBCore/PBCoreNamespace.html"}

insts = root.findall(".//pbcore:pbcoreInstantiation",ns)
dig_mts = []  # create list of media types for digial instantiations
for inst in insts:
    if inst.find("pbcore:instantiationDigital",ns) is not None:
        mte = inst.find("pbcore:instantiationMediaType",ns)
        if mte is not None:
            dig_mts.append(mte.text)

if len(dig_mts) == 0:
    media_type = ''
elif 'Moving Image' in dig_mts:
    media_type = 'Moving Image'
elif 'Sound' in dig_mts:
    media_type = 'Sound'
else:
    media_type = dig_mts[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants