Skip to content

Instantly share code, notes, and snippets.

@misterdai
Last active October 30, 2015 11:39
Show Gist options
  • Save misterdai/831a2202303a2f1eb443 to your computer and use it in GitHub Desktop.
Save misterdai/831a2202303a2f1eb443 to your computer and use it in GitHub Desktop.
Youtube cfm?
<cfscript>
urls = [
'//www.youtube-nocookie.com/embed/up_lNV-yoK4?rel=0',
'http://www.youtube.com/user/Scobleizer##p/u/1/1p3vcRhsYGo',
'http://www.youtube.com/watch?v=cKZDdG9FTKY&feature=channel',
'http://www.youtube.com/watch?v=yZ-K7nCVnBI&playnext_from=TL&videos=osPknwzXEas&feature=sub',
'http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I',
'http://www.youtube.com/user/SilkRoadTheatre##p/a/u/2/6dwqZw0j_jY',
'http://youtu.be/6dwqZw0j_jY',
'http://www.youtube.com/watch?v=6dwqZw0j_jY&feature=youtu.be',
'http://youtu.be/afa-5HQHiAs',
'http://www.youtube.com/user/Scobleizer##p/u/1/1p3vcRhsYGo?rel=0',
'http://www.youtube.com/watch?v=cKZDdG9FTKY&feature=channel',
'http://www.youtube.com/watch?v=yZ-K7nCVnBI&playnext_from=TL&videos=osPknwzXEas&feature=sub',
'http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I',
'http://www.youtube.com/embed/nas1rJpm7wY?rel=0',
'http://www.youtube.com/watch?v=peFZbP64dsU',
'http://youtube.com/v/dQw4w9WgXcQ?feature=youtube_gdata_player',
'http://youtube.com/vi/dQw4w9WgXcQ?feature=youtube_gdata_player',
'http://youtube.com/?v=dQw4w9WgXcQ&feature=youtube_gdata_player',
'http://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player',
'http://youtube.com/?vi=dQw4w9WgXcQ&feature=youtube_gdata_player',
'http://youtube.com/watch?v=dQw4w9WgXcQ&feature=youtube_gdata_player',
'http://youtube.com/watch?vi=dQw4w9WgXcQ&feature=youtube_gdata_player',
'http://youtu.be/dQw4w9WgXcQ?feature=youtube_gdata_player',
'http://www.nottobematched.com/?lkajsdl=qwelkjasd'
];
ids = [];
regex = '(https?:)?\/\/(www\.)?youtu(\.be|be(-nocookie)?\.com)(\/(vi?|embed)\/|\/.*\?.*vi?=|\/user\/.*\/|\/)([a-zA-Z0-9_-]{11})($|\?|\&)';
for(i=1; i <= ArrayLen(urls); i++) {
address = urls[i];
result = ReFind(regex, address, 1, true);
if (ArrayLen(result.pos) >= 7) {
ArrayAppend(ids, mid(address, result.pos[8], result.len[8]));
}
}
WriteDump(ids);
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment