mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-22 10:55:15 -04:00
Add support for YouTube Shorts video embeds in HTML
This commit is contained in:
parent
9182c3d934
commit
2fd7e327a9
1 changed files with 7 additions and 1 deletions
|
@ -10,7 +10,7 @@ public partial record YouTubeVideoEmbedProjection(string VideoId)
|
|||
public partial record YouTubeVideoEmbedProjection
|
||||
{
|
||||
// Adapted from YoutubeExplode
|
||||
// https://github.com/Tyrrrz/YoutubeExplode/blob/5be164be20019783913f76fcc98f18c65aebe9f0/YoutubeExplode/Videos/VideoId.cs#L34-L64
|
||||
// https://github.com/Tyrrrz/YoutubeExplode/blob/bc700b631bd105d0be208a88116347034bdca88b/YoutubeExplode/Videos/VideoId.cs#L40-L62
|
||||
private static string? TryParseVideoId(string embedUrl)
|
||||
{
|
||||
// Regular URL
|
||||
|
@ -31,6 +31,12 @@ public partial record YouTubeVideoEmbedProjection
|
|||
if (!string.IsNullOrWhiteSpace(embedMatch))
|
||||
return embedMatch;
|
||||
|
||||
// Shorts URL
|
||||
// https://www.youtube.com/shorts/sKL1vjP0tIo
|
||||
var shortsMatch = Regex.Match(embedUrl, @"youtube\..+?/shorts/(.*?)(?:\?|&|/|$)").Groups[1].Value;
|
||||
if (!string.IsNullOrWhiteSpace(shortsMatch))
|
||||
return shortsMatch;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue