mitodl / ocw-hugo-themes

A Hugo theme for building OCW websites
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

offline video player not loaded for newly uploaded videos with no archive_url #1193

Closed gumaerc closed 1 year ago

gumaerc commented 1 year ago

Videos in legacy courses generally have a URL to an archived version of the video on archive.org in the video_files.archive_url property in the video metadata. Videos in new courses synced from Google Drive in ocw-studio do not set this property and instead set the file property to a root-relative path indicating where to find the video file relative to the site root.

Expected Behavior

When building a site with Hugo using the course-offline theme, if a video has the file property and the video file is found to exist, the local video player should be used instead.

Current Behavior

The YouTube player is loaded even though the above conditions are met.

Steps to Reproduce

  1. Create a new site in ocw-studio
  2. Upload a video to the videos_final folder in Google Drive, then run a sync from the Resources page
  3. Wait for the transcoding process to finish
  4. Embed the video in a page
  5. Publish your site
  6. Go to the published site and click the buttons to download the ZIP archive
  7. Extract the ZIP and open the index.html file in browser, then browse to the page where the video is embedded, as well as the video page itself

Possible Solution

In https://github.com/mitodl/ocw-hugo-themes/blob/main/base-offline/layouts/partials/video.html, only .Params.video_files.archive_url is checked and passed as the archiveUrl argument to video_player.html. Since this value is blank for videos uploaded with the process described above, the archive video is never found during the build and the YouTube player is rendered instead. The file property should also be checked, and the actual existence of the video file checked in the same manner as with archive_url.