#Youtube link cleaner

1 messages Β· Page 1 of 1 (latest)

chilly dome
#

Youtube link cleaner

RegEx :

find: (?:^|(?<=[\s,:;/&]))https:\/\/www\.youtube\.com\/(?:shorts\/|watch\?)(?:(?:v=)?(?<id0>[\w-]{11,})|(?<timestamp0>t=\d+[a-z]?)|(?:(?:[^\Wvt]|[\w-]{2,})=[\w-]+))(?:(?:(?<and0>&)v=)(?<id1>[\w-]{11,})|(?<and1>&)(?<timestamp1>t=\d+[a-z]?)|(?:&(?:[^\Wvt]|[\w-]{2,})=[\w-]+)+?)??(?:(?:(?<and2>&)v=)(?<id2>[\w-]{11,})|(?<and3>&)(?<timestamp2>t=\d+[a-z]?)|(?:&(?:[^\Wvt]|[\w-]{2,})=[\w-]+)+?)??(?:(?:(?<and4>&)v=)(?<id3>[\w-]{11,})|(?<and5>&)(?<timestamp3>t=\d+[a-z]?)|(?:&(?:[^\Wvt]|[\w-]{2,})=[\w-]+)+?)??(?:(?:(?<and6>&)v=)(?<id4>[\w-]{11,})|(?<and7>&)(?<timestamp4>t=\d+[a-z]?)|(?:&(?:[^\Wvt]|[\w-]{2,})=[\w-]+)+?)??(?:(?:(?<and8>&)v=)(?<id5>[\w-]{11,})|(?<and9>&)(?<timestamp5>t=\d+[a-z]?)|(?:&(?:[^\Wvt]|[\w-]{2,})=[\w-]+)+?)??(?:(?=[\s.?!,:;/])|$)
replace: https://youtu.be/$<id0>$<id1>$<id2>$<id3>$<id4>$<id5>$<and0>$<and1>$<and2>$<and3>$<and4>$<and5>$<and6>$<and7>$<and8>$<and9>$<timestamp0>$<timestamp1>$<timestamp2>$<timestamp3>$<timestamp4>$<timestamp5>

Nerd Explanation :
I wanna unalive myself, writing a youtube link arguments parser in regex is a stupid idea, i should just write a userplugin
Regex is cool and powerful, but the limits have been hit

Example :

https://www.youtube.com/shorts/6ZE5zMnBwVc
https://www.youtube.com/watch?v=n6y-tR2E9OE
https://www.youtube.com/watch?v=n6y-tR2E9OE&t=1m
https://www.youtube.com/watch?t=1m&v=n6y-tR2E9OE
https://www.youtube.com/watch?dsf=efvdvfdfvd&t=1m&dsf=efvdvfdfvd&v=n6y-tR2E9OE&dsf=efvdvfdfvd

https://youtu.be/6ZE5zMnBwVc
https://youtu.be/n6y-tR2E9OE
https://youtu.be/n6y-tR2E9OE&t=1m
https://youtu.be/n6y-tR2E9OE&t=1m
https://youtu.be/n6y-tR2E9OE&&t=1m

@stark flicker you might be interested by it if the sneak peek looked cool

stark flicker
#

Oh hey thanks !

dark mist
#

the ClearUrls plugin in question

chilly dome
dark mist
#

that's literally useless

chilly dome
#

it's not ?
makes link shorter + force shorts to display as normal videos

stark flicker
wet hearth
#

I made this and then saw the clearurls plugin
(crossed out because this shouldn't be used, and was only sent as an example)
~~find:

https:\/\/(?:(?:www\.)?youtube\.com\/watch\?v=|youtu\.be\/)([A-z0-9_-]+)((?:[&\?]?(?!si=)[^=&>\?\s]+(?:=[^&>\?\s]+)?)*)(?:[&\?]si(?:=[^&>\?\s]+)?)?((?:&(?!si=)[^=&>\?\s]+(?:=[^&>\?\s]+)?)*)

replace:

https://youtu.be/$1$2$3
```~~
#

With the clear urls plugin, this is all that's needed...
https:\/\/(?:www\.)?youtube\.com\/watch\?v=([A-z0-9_-]+)((?:[&\?]?[^=&>\?\s]+(?:=[^&>\?\s]+)?)*)

#

wait

#

find
(?:www\.)?youtube.com\/watch\?v=
replace
youtu.be/
and don't even really need regex anymore