From 89eb0fa7ffd564ce41e27734d07fedf5cc235369 Mon Sep 17 00:00:00 2001 From: Sam Davies Date: Thu, 12 Oct 2023 11:59:39 +0100 Subject: [PATCH] WEB-6559: Extract the vimeo_id from metadata, add to model, and push --- app/lib/parser/video_metadata.rb | 2 ++ app/models/video.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/lib/parser/video_metadata.rb b/app/lib/parser/video_metadata.rb index ec6fd08..9fedd50 100644 --- a/app/lib/parser/video_metadata.rb +++ b/app/lib/parser/video_metadata.rb @@ -18,6 +18,8 @@ def initialize(video, metadata) def apply! check_captions_path video.assign_attributes(simple_attributes) + # Need to extract the ID from the URL, if one has been provided + video.vimeo_id = metadata[:vimeo_id]&.to_s&.match(/(\d+)$/)&.values_at(1)&.first video.authors += authors if authors.present? end diff --git a/app/models/video.rb b/app/models/video.rb index 42053fa..e9c8600 100644 --- a/app/models/video.rb +++ b/app/models/video.rb @@ -8,7 +8,7 @@ class Video include Concerns::MarkdownRenderable attr_accessor :title, :ordinal, :free, :description_md, :short_description, :authors_notes_md, - :authors, :script_file, :root_path, :captions_file, :ref + :authors, :script_file, :root_path, :captions_file, :ref, :vimeo_id attr_markdown :description, source: :description_md, file: false attr_markdown :authors_notes, source: :authors_notes_md, file: false @@ -40,7 +40,7 @@ def segment_type # Used for serialisation def attributes { title: nil, ordinal: nil, free: false, description: nil, short_description: nil, authors_notes: nil, - authors: [], transcript: nil, ref: nil, episode_type:, segment_type: }.stringify_keys + authors: [], transcript: nil, ref: nil, vimeo_id: nil, episode_type:, segment_type: }.stringify_keys end # Used for linting