Embedding Peertube

Hello, I have a forum on which youtube/dailymotion links display an embed code that allow users to watch the video without leaving the page.

I have issues embedding peertube cause it’s not a common format.

Let’s say I have that js code:

embed.getSrcFramatube = function(url) {
    if (!url.includes("/videos/"))
	return;

    var videoId = url.split("/")[4];
	
    if (!videoId)
	return;


    return "https://framatube.org/videos/embed/" + videoId;


};

It doesn’t work with https://framatube.org/videos/watch/4ebfa3d2-b871-4f29-a8b5-b5d23535c8e3

But if I remove the /watch it works well : https://framatube.org/videos/4ebfa3d2-b871-4f29-a8b5-b5d23535c8e3

Any ideas of how I could fix this?

If you want videoId, it’s url.split("/")[5].

Ok it worked!
Thanks.

I pass the code I used here in case it help someone else :

embed.getSrcFramatube = function(url) {
    if (!url.includes("/watch/"))
	return;

    var videoId = url.split("/")[5];
	
    if (!videoId)
	return;


    return "https://framatube.org/videos/embed/" + videoId;


};


`embed.domainFunctionMap["framatube.org"] = embed.getSrcFramatube;`
1 « J'aime »