Skip to content

Commit

Permalink
Don't add videos to podcast until they are done streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubery committed Sep 26, 2024
1 parent a0d8f92 commit 1c0f08b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/media_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def fill_missing_details

if %r{\Ahttps://(www\.)?(youtube|vimeo)\.com/} =~ url || %r{\Ahttps://youtu\.be/} =~ url
info = Youtube::Video.new(url).get_information
if info.present?
if info.present? && !info["is_live"]
success = !!info["id"]
if success && info['extractor'] == 'youtube'
video = Youtube::Video.from_id(info["id"])
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/media_items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ xss_article:
title: evil
description: <script>alert("injection")</script>

live_video:
feed: one
url: https://www.youtube.com/watch?v=PRWclJd_sIQ
guid: https://www.youtube.com/watch?v=PRWclJd_sIQ

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions test/models/media_item_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class MediaItemTest < ActiveSupport::TestCase
assert_not yt.reachable
end

test "fill_missing_info waits until video is done streaming" do
yt = media_items(:live_video)
assert_equal '', yt.title
yt.fill_missing_details
assert_equal '', yt.title
end

test "embedding images and resolving links" do
original_html = File.read("test/fixtures/articles/substack_email.html")
VCR.use_cassette("embedded-images-test", record: :new_episodes) do
Expand Down

0 comments on commit 1c0f08b

Please sign in to comment.