allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] branch master updated: Youtube oembed needs to go on https now; handle any HTTP error more specifically; 404s encounter OEmbedError mime-type error first
Date Tue, 15 Dec 2020 19:56:28 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git


The following commit(s) were added to refs/heads/master by this push:
     new 050d8e5  Youtube oembed needs to go on https now; handle any HTTP error more specifically;
404s encounter OEmbedError mime-type error first
050d8e5 is described below

commit 050d8e563392d97169d677d48418f6fe019568ab
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
AuthorDate: Tue Dec 15 14:54:33 2020 -0500

    Youtube oembed needs to go on https now; handle any HTTP error more specifically; 404s
encounter OEmbedError mime-type error first
---
 Allura/allura/lib/macro.py          | 5 +++--
 Allura/allura/tests/test_globals.py | 4 +++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py
index 3e58278..bd9e250 100644
--- a/Allura/allura/lib/macro.py
+++ b/Allura/allura/lib/macro.py
@@ -453,7 +453,7 @@ def members(limit=20):
 @macro()
 def embed(url=None):
     consumer = oembed.OEmbedConsumer()
-    endpoint = oembed.OEmbedEndpoint('http://www.youtube.com/oembed',
+    endpoint = oembed.OEmbedEndpoint('https://www.youtube.com/oembed',
                                      [str('http://*.youtube.com/*'), str('https://*.youtube.com/*'),
                                       str('http://*.youtube-nocookie.com/*'), str('https://*.youtube-nocookie.com/*'),
                                       ])
@@ -473,7 +473,8 @@ def embed(url=None):
             if e.code == 404:
                 return 'Video not available'
             else:
-                raise
+                log.exception('Could not embed: {}'.format(url))
+                return 'Could not embed: {}'.format(url)
 
     if html:
         # youtube has a trailing ")" at the moment
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index a811247..ddc0d94 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -349,8 +349,10 @@ def test_macro_embed(oembed_fetch):
 
 
 def test_macro_embed_video_gone():
+    # this does a real fetch
     r = g.markdown_wiki.convert('[[embed url=https://www.youtube.com/watch?v=OWsFqPZ3v-0]]')
-    assert_equal(r, '<div class="markdown_content"><p>Video not available</p></div>')
+    assert_equal(r, '<div class="markdown_content"><p>Could not embed: '
+                    'https://www.youtube.com/watch?v=OWsFqPZ3v-0</p></div>')
 
 
 @patch('oembed.OEmbedEndpoint.fetch')


Mime
View raw message