Created
March 30, 2023 15:49
-
-
Save NiakmaJr/f6dc0561b6fad4baecdd6b0bc2de4fa6 to your computer and use it in GitHub Desktop.
C# youtube link converter to embed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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