-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathDailyMotion.cs
More file actions
39 lines (31 loc) · 1.33 KB
/
DailyMotion.cs
File metadata and controls
39 lines (31 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Xml;
using Umbraco.Cms.Core.Serialization;
namespace Umbraco.Cms.Core.Media.EmbedProviders;
/// <summary>
/// Embed Provider for Dailymotion the popular online video-sharing platform.
/// </summary>
public class DailyMotion : OEmbedProviderBase
{
public DailyMotion(IJsonSerializer jsonSerializer)
: base(jsonSerializer)
{
}
public override string ApiEndpoint => "https://www.dailymotion.com/services/oembed";
public override string[] UrlSchemeRegex => new[] { @"dailymotion.com/video/.*" };
public override Dictionary<string, string> RequestParams => new()
{
// ApiUrl/?format=xml
{ "format", "xml" },
};
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
XmlDocument xmlDocument = await base.GetXmlResponseAsync(requestUrl, cancellationToken);
return GetXmlProperty(xmlDocument, "/oembed/html");
}
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
}