Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Joshua T's profile on WallpaperFusion.com
Here's a quick macro to shorten a YouTube video from the full https://www.youtube.com/watch?v=<id> to the shortened youtu.be version.

I've attached the .cfmacro file below for easy importing into ClipboardFusion, or here's the source.

Code

using System;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        Regex youtubeRegex = new Regex(@"https://www\.youtube\.com\/watch\?v\=(?<id>[^\&]*)(?:\&.*)?");
        Match match = youtubeRegex.Match(text);

        if (!match.Success) {
            // If this isn't a YouTube video, don't do anything to it
            return text;
        }

        Group idGroup = match.Groups["id"];
        string idText = idGroup.Value;
        return "https://youtu.be/" + idText;
    }
}


If there's a better place to submit this, please let me know and I can re-submit. :)

Hopefully someone can find this useful!
• Attachment: Shorten YouTube link.cfmacro [4,274 bytes]
Dec 30, 2016  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Thanks for sharing that! I've posted it to the online repository as well, which is accessible via the "Download Pre-Made Macros" button in the ClipboardFusion settings :)
Jan 4, 2017  • #2
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)