Skip to content

Instantly share code, notes, and snippets.

@NiakmaJr
Created March 30, 2023 15:49
Show Gist options
  • Save NiakmaJr/f6dc0561b6fad4baecdd6b0bc2de4fa6 to your computer and use it in GitHub Desktop.
Save NiakmaJr/f6dc0561b6fad4baecdd6b0bc2de4fa6 to your computer and use it in GitHub Desktop.
C# youtube link converter to embed
public string ConvertEmbed(string url)
{
if (url.Contains("/watch?v="))
{
url = url.Replace("/watch?v=", "/embed/");
}
else if (url.Contains("/youtu.be"))
{
url = url.Replace("/youtu.be/", "/youtube.com/embed/");
}
return url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment