-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to import Vimeo videos #8804
base: 1.10.x
Are you sure you want to change the base?
Conversation
… api url to the call to properly download video metadata.
I think this is really wrong. If Vimeo doesn't support OEmbed then it's better to have another feature dedicated to vimeo, or just drop vimeo support altogether. |
…t changes to Youtube page markup
…there the correct api url.
// <link rel="alternate" href="http://vimeo.com/api/oembed.xml?url=http%3A%2F%2Fvimeo.com%2F23608259" type="text/xml+oembed"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// <link rel="alternate" href="http://vimeo.com/api/oembed.xml?url=http%3A%2F%2Fvimeo.com%2F23608259" type="text/xml+oembed"> |
var content = webClient.DownloadString(Server.HtmlDecode(href)); | ||
viewModel.Content = XDocument.Parse(content); | ||
} catch { | ||
// bubble exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// bubble exception | |
throw; |
source = webClient.DownloadString(url); | ||
|
||
viewModel.Content = XDocument.Parse(source); | ||
} else if (youtube) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else if (youtube) { | |
} | |
else if (youtube) { |
source = webClient.DownloadString(url); | ||
|
||
viewModel.Content = XDocument.Parse(source); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | |
} | |
else { |
try { | ||
var content = webClient.DownloadString(Server.HtmlDecode(href)); | ||
viewModel.Content = XDocument.Parse(content); | ||
} catch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} catch { | |
} | |
catch { |
@@ -137,8 +165,7 @@ public ActionResult IndexPOST(string folderPath, string url, string type, string | |||
root.El("description", description); | |||
} | |||
Response.AddHeader("X-XSS-Protection", "0"); // Prevents Chrome from freaking out over embedded preview | |||
} | |||
catch { | |||
} catch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} catch { | |
} | |
catch { |
@@ -167,8 +194,7 @@ public ActionResult Import(string folderPath, string url, string document) { | |||
|
|||
if (oembed.Element("title") != null) { | |||
part.Title = oembed.Element("title").Value; | |||
} | |||
else { | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | |
} | |
else { |
@@ -213,8 +239,7 @@ public ActionResult Replace(int replaceId, string url, string document) { | |||
|
|||
if (oembed.Element("title") != null) { | |||
replaceMedia.Title = oembed.Element("title").Value; | |||
} | |||
else { | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | |
} | |
else { |
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myUri); | ||
// Send the request and wait for response. | ||
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); | ||
|
||
if (!myUri.Equals(myHttpWebResponse.ResponseUri)) { | ||
myUri = myHttpWebResponse.ResponseUri; | ||
} | ||
|
||
// Release resources of response object. | ||
myHttpWebResponse.Close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myUri); | |
// Send the request and wait for response. | |
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); | |
if (!myUri.Equals(myHttpWebResponse.ResponseUri)) { | |
myUri = myHttpWebResponse.ResponseUri; | |
} | |
// Release resources of response object. | |
myHttpWebResponse.Close(); | |
var myHttpWebRequest = WebRequest.Create(myUri) as HttpWebRequest; | |
// Send the request and wait for response. | |
using (var myHttpWebResponse = myHttpWebRequest.GetResponse() as HttpWebResponse) { | |
if (!myUri.Equals(myHttpWebResponse.ResponseUri)) { | |
myUri = myHttpWebResponse.ResponseUri; | |
} | |
} |
@sebastienros what do you think? BTW I tested the YouTube import (but couldn't test Vimeo), works fine. |
Let's keep oembed as is, it's oembed. Add some other option called youtube, another one for vimeo and they are dedicated. Or a single one called "video" which would support whatever we want. Copy as much as you want from the current oembed. |
In reference to #8803 , added a fix to avoid the scraping of the "vimeo.com/xxxx" page (which replies with a 429 http error) by forcing the direct api call if Vimeo domain is recognized.