Skip to content

Commit

Permalink
schema.org: add uploadDate for VideoObject serialization [+]
Browse files Browse the repository at this point in the history
This is the remnant of a dead-end in providing more VideoObject structured
data per https://developers.google.com/search/docs/appearance/structured-data/video
since we were getting 'chided' by Google search console. Unfortunately, the
reality is that a record page is not a video watch page (it may contain multiple
videos + focus of page is on wider metadata) and a generic instance doesn't
have video thumbnails and perhaps doesn't want to expose video content file too
much. All of this resulted in only implementing the uploadDate field 🤷 .
  • Loading branch information
fenekku authored and tmorrell committed Feb 26, 2025
1 parent 4a2bc5d commit b0eab8d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion invenio_rdm_records/resources/serializers/schemaorg/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class SchemaorgSchema(BaseSerializerSchema, CommonFieldsMixin):
# Fields that are specific to certain resource types.
measurementTechnique = fields.Method("get_measurement_techniques")
distribution = fields.Method("get_distribution")
uploadDate = fields.Method("get_upload_date")

def get_id(self, obj):
"""Get id. Use the DOI expressed as a URL."""
Expand Down Expand Up @@ -425,7 +426,7 @@ def get_sameAs(self, obj):
return ids or missing

def get_url(self, obj):
"""Get Zenodo URL of the record."""
"""Get URL of the record."""
self_url = py_.get(obj, "links.self_html")
return self_url or missing

Expand Down Expand Up @@ -504,3 +505,17 @@ def _filter_related_identifier_type(self, identifiers, relation_types):
lambda x: x.get("relation_type", {}).get("id") in relation_types,
identifiers,
)

# Fields specific to https://schema.org/VideoObject
# Useful for video crawlers per
# https://developers.google.com/search/docs/appearance/structured-data/video
def _is_video(self, obj):
return self.get_type(obj) == "https://schema.org/VideoObject"

def get_upload_date(self, obj):
"""Get uploadDate."""
if not self._is_video(obj):
return missing

# Creation date is closest in meaning to when video was uploaded
return self.get_creation_date(obj)

0 comments on commit b0eab8d

Please sign in to comment.