Skip to content
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

Vimeo fix #1900

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions funnel/assets/js/utils/embedvideo.js
Original file line number Diff line number Diff line change
@@ -8,14 +8,22 @@ const Video = {
*/
getVideoTypeAndId(url) {
const regexMatch = url.match(
/(http:|https:|)\/\/(player.|www.)?(y2u\.be|vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|live\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(&\S+)?/
/(http:|https:|)\/\/(player.|www.)?(?<service>y2u\.be|vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|live\/|watch\?v=|v\/)?(?<videoId>[A-Za-z0-9._%-]*)(&\S+)?((\?h=)(?<paramId>[^&]+))?/
);
let type = '';
if (regexMatch && regexMatch.length > 5) {
if (regexMatch[3].indexOf('youtu') > -1 || regexMatch[3].indexOf('y2u') > -1) {
if (
regexMatch.groups.service.indexOf('youtu') > -1 ||
regexMatch.groups.service.indexOf('y2u') > -1
) {
type = 'youtube';
} else if (regexMatch[3].indexOf('vimeo') > -1) {
} else if (regexMatch.groups.service.indexOf('vimeo') > -1) {
type = 'vimeo';
return {
type,
videoId: regexMatch.groups.videoId,
paramId: regexMatch.groups.paramId,
};
}
return {
type,
@@ -29,11 +37,13 @@ const Video = {
},
embedIframe(videoWrapper, videoUrl) {
let videoEmbedUrl = '';
const { type, videoId } = this.getVideoTypeAndId(videoUrl);
const { type, videoId, paramId } = this.getVideoTypeAndId(videoUrl);
if (type === 'youtube') {
videoEmbedUrl = `<iframe src='//www.youtube.com/embed/${videoId}' frameborder='0' allowfullscreen></iframe>`;
} else if (type === 'vimeo') {
videoEmbedUrl = `<iframe src='https://player.vimeo.com/video/${videoId}' frameborder='0' allowfullscreen></iframe>`;
videoEmbedUrl = `<iframe src='https://player.vimeo.com/video/${videoId}${
paramId ? `?h=${paramId}` : ''
}' frameborder='0' allowfullscreen></iframe>`;
}
if (videoEmbedUrl) {
videoWrapper.innerHTML = videoEmbedUrl;
1 change: 1 addition & 0 deletions funnel/forms/project.py
Original file line number Diff line number Diff line change
@@ -167,6 +167,7 @@ class ProjectLivestreamForm(forms.Form):
'y2u.be',
'www.vimeo.com',
'vimeo.com',
'player.vimeo.com',
),
message_schemes=__("A https:// URL is required"),
message_domains=__("Livestream must be on YouTube or Vimeo"),