Advertisement
AnarchyOnline

Youtube.xys 0.6

May 29th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 17.62 KB | None | 0 0
  1. /* MAIN SCRIPT FUNCTIONS
  2.  * Main functions contain minimal unique code and are designed to chain smaller script modules
  3.  * to generate a desired output.
  4.  *
  5.  * FOR VLC MAIN FUNCTIONS:
  6.  * VLC sometimes parses a command line internally. Documentation on this is poor. This will result
  7.  * in buggy behavior. During testing most coming bugs have been worked around (mainly URL parsing).
  8.  * More specific bugs may still appear. Please post on the forum if you encounter odd behavior.
  9.  */
  10.  
  11. "_Initialize"
  12.  {
  13.  global $g_Vlc;
  14.  global $g_Downloads;
  15.  global $g_INIFile;
  16.  global $g_BATFile;
  17.  
  18.  $g_INIFile = "<xyscripts>\YouTube.ini";
  19.  $g_BATFile = "<xyscripts>\YouTube.bat";
  20.  
  21.  
  22.  if (exists($g_INIFile)){
  23.  
  24.   $g_Vlc = getkey ('Vlc', 'Config', $g_INIFile, );
  25.   $g_Downloads = getkey ('Downloads', 'Config', $g_INIFile, );
  26.  
  27.  } else {
  28.  
  29.   msg <<<#
  30. This is your first time running YouTube.xys 0.6 or you have deleted your configuration file. This configuration wizard helps you quickly configure the script for use. If you wish to change the configuration at a later stage you can do so by editing this file:
  31.  
  32. <xyscripts>\YouTube.ini
  33.  
  34. This wizard will configure the script through these steps:
  35.  
  36. 1. Select vlc.exe
  37. 2. Select download location
  38.  
  39. #;
  40.  
  41.   $g_Vlc = inputfile ('C:', 'exe', 'Select vlc.exe');
  42.   $g_Downloads = inputfolder ('C:', 'Select download location');
  43.  
  44.   $Configuration = <<<#
  45. [Config]  
  46. Vlc=$g_Vlc
  47. Downloads=$g_Downloads
  48. #;
  49.   writefile ($g_INIFile, $Configuration, o, t);
  50.   msg <<<#
  51. The script is now configured.
  52. #;
  53.  }
  54.  }
  55. "Decode to CDN Link"
  56.  {
  57.  global $g_YoutubeSourceUrl;
  58.  global $g_YoutubeSourceContent;
  59.  
  60.  $g_YoutubeSourceUrl = "<clipboard>";
  61.  sub "_Youtube-Get-SourceData";
  62.  
  63.  global $g_MetaTitle;
  64.  global $g_MetaDescription;
  65.  sub "_SourceData-Get-MetaData";
  66.  
  67.  global $g_StreamMap;
  68.  sub "_SourceData-Get-StreamMap";
  69.  sub "_StreamMap-Decode";
  70.  
  71.  global $g_Itags;
  72.  sub "_StreamMap-Get-Versions";
  73.  
  74.  global $g_VersionsMenuList;
  75.  global $g_VersionsMenuChoice;
  76.  sub "_Versions-Get-Choice";
  77.  
  78.  global $g_PlayableUrl;
  79.  sub "_Choice-Create-PlayableUrl";
  80.  
  81.  text $g_PlayableUrl;
  82.  }
  83.  
  84. "1 Link - XY"
  85.  {
  86.  global $g_Downloads;
  87.  global $g_MetaTitle;
  88.  global $g_VersionsMenuChoiceExt;
  89.  global $g_PlayableUrl;
  90.  
  91.  sub "_Return-Playable-Url";
  92.  download ($g_PlayableUrl, "$g_Downloads\$g_MetaTitle$g_VersionsMenuChoiceExt", o);
  93.  }
  94.  
  95. "1 Link - VLC"
  96.  {
  97.  global $g_Vlc;
  98.  global $g_Downloads;
  99.  global $g_BATFile;
  100.  global $g_MetaTitle;
  101.  global $g_VersionsMenuChoiceExt;
  102.  global $g_PlayableUrl;
  103.  
  104.  sub "_Return-Playable-Url";
  105.  
  106.  $VlcCmd = '"'.$g_Vlc.'" "'.$g_PlayableUrl.'" :sout=#file{dst="'.$g_Downloads.'\'.$g_MetaTitle.$g_VersionsMenuChoiceExt.'"} :sout-keep --play-and-exit';
  107. text $VlcCmd;
  108. writefile ($g_BATFile, $VlcCmd."<crlf>del ".'"'.$g_BATFile.'"', o, t);
  109. run ($VlcCmd, , 0, 0);
  110. }
  111.  
  112. "1 Link - VLC (Audio only)"
  113. {
  114. global $g_Vlc;
  115. global $g_Downloads;
  116. global $g_BATFile;
  117. global $g_MetaTitle;
  118. global $g_VersionsMenuChoiceExt;
  119. global $g_PlayableUrl;
  120.  
  121. sub "_Return-Playable-Url";
  122.  
  123. $VlcCmd = '"'.$g_Vlc.'" "'.$g_PlayableUrl.'" :sout=#transcode{vcodec=none}:file{dst="'.$g_Downloads.'\'.$g_MetaTitle.$g_VersionsMenuChoiceExt.'"} :sout-keep --play-and-exit';
  124. writefile ($g_BATFile, $VlcCmd."<crlf>del ".'"'.$g_BATFile.'"', o, t);
  125. run ($VlcCmd, , 0, 0);
  126. }
  127.  
  128. "1 Link - VLC (Video only)"
  129. {
  130. global $g_Vlc;
  131. global $g_Downloads;
  132. global $g_BATFile;
  133. global $g_MetaTitle;
  134. global $g_VersionsMenuChoiceExt;
  135. global $g_PlayableUrl;
  136.  
  137. sub "_Return-Playable-Url";
  138.  
  139. $VlcCmd = '"'.$g_Vlc.'" "'.$g_PlayableUrl.'" :sout=#transcode{acodec=none}:file{dst="'.$g_Downloads.'\'.$g_MetaTitle.$g_VersionsMenuChoiceExt.'"} :sout-keep --play-and-exit';
  140. text $VlcCmd;
  141. writefile ($g_BATFile, $VlcCmd."<crlf>del ".'"'.$g_BATFile.'"', o, t);
  142. run ($VlcCmd, , 0, 0);
  143. }
  144.  
  145. "Multiple Links - XY"
  146. {
  147. global $g_Downloads;
  148. $YoutubeSourceContentArray = '';
  149. $DownloadQueue = '';
  150.  
  151. $Urls = input ("Download Multiple Links - XY", "Paste 1 Youtube link per line followed by Enter", , m, , , );
  152.  
  153. //Load all Youtube sources into $YoutubeSourceContentArray
  154. foreach ($Url, $Urls, "<crlf>"){
  155.  global $g_YoutubeSourceUrl;
  156.  global $g_YoutubeSourceContent;
  157.  
  158.  $g_YoutubeSourceUrl = $Url;
  159.  sub "_Youtube-Get-SourceData";
  160.  //List delimiter must be multiple characters as sourcecode may contain all unicode characters
  161.  //|159@@@@@753|
  162.  $YoutubeSourceContentArray = $YoutubeSourceContentArray.'|159@@@@@753|'.$g_YoutubeSourceContent;
  163. }
  164.  
  165. $YoutubeSourceContentArray = formatlist ($YoutubeSourceContentArray, e, '|159@@@@@753|', );
  166.  
  167. //Ask the user what quality to download per video and store the result in $DownloadQueue
  168.  
  169. foreach ($a, $YoutubeSourceContentArray, '|159@@@@@753|'){
  170. //Can not use $g_YoutubeSourceContent directly instead use $a as intermediate
  171. $g_YoutubeSourceContent = $a;
  172.  
  173. global $g_MetaTitle;
  174. global $g_MetaDescription;
  175. sub "_SourceData-Get-MetaData";
  176.  
  177. global $g_StreamMap;
  178. sub "_SourceData-Get-StreamMap";
  179. sub "_StreamMap-Decode";
  180.  
  181. global $g_Itags;
  182. sub "_StreamMap-Get-Versions";
  183.  
  184. global $g_VersionsMenuList;
  185. global $g_VersionsMenuChoice;
  186. global $g_VersionsMenuChoiceExt;
  187. sub "_Versions-Get-Choice";
  188.  
  189. global $g_PlayableUrl;
  190. sub "_Choice-Create-PlayableUrl";
  191.  
  192. //Smuggle filename with into URL. We regex out the filename later and delete it leaving only the URL
  193. //This code needs clean-up at some point.
  194. //This could be done in a cleaner way by using buffer files.
  195. $Filename = "$g_MetaTitle$g_VersionsMenuChoiceExt";
  196. $DownloadQueue = $DownloadQueue.'|'.$g_PlayableUrl.">$Filename>";
  197. }
  198.  
  199. $DownloadQueue = formatlist ($DownloadQueue, e, '|', );
  200.  
  201. foreach ($Link, $DownloadQueue, '|'){
  202. $Filename = regexmatches ($Link, '[>][^>]+[>]', , 0);
  203. $Filename = replace ($Filename, '>', '', , , );
  204. $Link = regexreplace ($Link, '[>][^>]+[>]', '', );
  205. download ($Link, "$g_Downloads\$Filename", o);
  206. }
  207. }
  208.  
  209. "Multiple Links - VLC"
  210. {
  211. global $g_Vlc;
  212. global $g_Downloads;
  213. global $g_BATFile;
  214. global $g_YoutubeSourceUrl;
  215. global $g_MetaTitle;
  216. global $g_VersionsMenuChoiceExt;
  217. global $g_PlayableUrl;
  218.  
  219. writefile ($g_BATFile, '', o, t);
  220.  
  221. $Urls = input ("Download Multiple Links - VLC", "Paste 1 Youtube link per line followed by Enter", , m, , , );
  222. foreach ($Url, $Urls, "<crlf>"){
  223.  
  224. $g_YoutubeSourceUrl = $Url;
  225. sub "_Youtube-Get-SourceData";
  226.  
  227. global $g_MetaTitle;
  228. global $g_MetaDescription;
  229. sub "_SourceData-Get-MetaData";
  230.  
  231. global $g_StreamMap;
  232. sub "_SourceData-Get-StreamMap";
  233. sub "_StreamMap-Decode";
  234.  
  235. global $g_Itags;
  236. sub "_StreamMap-Get-Versions";
  237.  
  238. global $g_VersionsMenuList;
  239. global $g_VersionsMenuChoice;
  240. global $g_VersionsMenuChoiceExt;
  241. sub "_Versions-Get-Choice";
  242.  
  243. global $g_PlayableUrl;
  244. sub "_Choice-Create-PlayableUrl";
  245.  
  246.  $VlcCmd = '"'.$g_Vlc.'" "'.$g_PlayableUrl.'" :sout=#file{dst="'.$g_Downloads.'\'.$g_MetaTitle.$g_VersionsMenuChoiceExt.'"} --play-and-exit';
  247.  
  248.  //For unknown reasons the parameter %2C causes VLC to quit when multiple files are queued up in a batch file. When only a single file is present the batch file will run. As a countermeasure I'm replace %2C by comma. If anyone knows why this behavior occurs please let me know.
  249.  $VlcCmd = replace ($VlcCmd, '%2C', ',', , , );
  250.  writefile ($g_BATFile, $VlcCmd."<crlf>", a, t);
  251. }
  252. writefile ($g_BATFile, "del ".'"'.$g_BATFile.'"', a, t);
  253. run ($g_BATFile, , 0, 0);
  254. }
  255.  
  256. "Multiple Links - VLC (Audio only)"
  257. {
  258. global $g_Vlc;
  259. global $g_Downloads;
  260. global $g_BATFile;
  261. global $g_YoutubeSourceUrl;
  262. global $g_MetaTitle;
  263. global $g_VersionsMenuChoiceExt;
  264. global $g_PlayableUrl;
  265.  
  266. writefile ($g_BATFile, '', o, t);
  267.  
  268. $Urls = input ("Download Multiple Links - VLC", "Paste 1 Youtube link per line followed by Enter", , m, , , );
  269. foreach ($Url, $Urls, "<crlf>"){
  270.  
  271. $g_YoutubeSourceUrl = $Url;
  272. sub "_Youtube-Get-SourceData";
  273.  
  274. global $g_MetaTitle;
  275. global $g_MetaDescription;
  276. sub "_SourceData-Get-MetaData";
  277.  
  278. global $g_StreamMap;
  279. sub "_SourceData-Get-StreamMap";
  280. sub "_StreamMap-Decode";
  281.  
  282. global $g_Itags;
  283. sub "_StreamMap-Get-Versions";
  284.  
  285. global $g_VersionsMenuList;
  286. global $g_VersionsMenuChoice;
  287. global $g_VersionsMenuChoiceExt;
  288. sub "_Versions-Get-Choice";
  289.  
  290. global $g_PlayableUrl;
  291. sub "_Choice-Create-PlayableUrl";
  292.  
  293.  $VlcCmd = '"'.$g_Vlc.'" "'.$g_PlayableUrl.'" :sout=#transcode{vcodec=none}:file{dst="'.$g_Downloads.'\'.$g_MetaTitle.$g_VersionsMenuChoiceExt.'"} :sout-keep --play-and-exit';  
  294.  //For unknown reasons the parameter %2C causes VLC to quit when multiple files are queued up in a batch file. When only a single file is present the batch file will run. As a countermeasure I'm replace %2C by comma. If anyone knows why this behavior occurs please let me know.
  295.  $VlcCmd = replace ($VlcCmd, '%2C', ',', , , );
  296.  writefile ($g_BATFile, $VlcCmd."<crlf>", a, t);
  297. }
  298. writefile ($g_BATFile, "del ".'"'.$g_BATFile.'"', a, t);
  299. run ($g_BATFile, , 0, 0);
  300. }
  301.  
  302. "Multiple Links - VLC (Video only)"
  303. {
  304. global $g_Vlc;
  305. global $g_Downloads;
  306. global $g_BATFile;
  307. global $g_YoutubeSourceUrl;
  308. global $g_MetaTitle;
  309. global $g_VersionsMenuChoiceExt;
  310. global $g_PlayableUrl;
  311.  
  312. writefile ($g_BATFile, '', o, t);
  313.  
  314. $Urls = input ("Download Multiple Links - VLC", "Paste 1 Youtube link per line followed by Enter", , m, , , );
  315. foreach ($Url, $Urls, "<crlf>"){
  316.  
  317. $g_YoutubeSourceUrl = $Url;
  318. sub "_Youtube-Get-SourceData";
  319.  
  320. global $g_MetaTitle;
  321. global $g_MetaDescription;
  322. sub "_SourceData-Get-MetaData";
  323.  
  324. global $g_StreamMap;
  325. sub "_SourceData-Get-StreamMap";
  326. sub "_StreamMap-Decode";
  327.  
  328. global $g_Itags;
  329. sub "_StreamMap-Get-Versions";
  330.  
  331. global $g_VersionsMenuList;
  332. global $g_VersionsMenuChoice;
  333. global $g_VersionsMenuChoiceExt;
  334. sub "_Versions-Get-Choice";
  335.  
  336. global $g_PlayableUrl;
  337. sub "_Choice-Create-PlayableUrl";
  338.  
  339.  $VlcCmd = '"'.$g_Vlc.'" "'.$g_PlayableUrl.'" :sout=#transcode{acodec=none}:file{dst="'.$g_Downloads.'\'.$g_MetaTitle.$g_VersionsMenuChoiceExt.'"} :sout-keep --play-and-exit';
  340.  //For unknown reasons the parameter %2C causes VLC to quit when multiple files are queued up in a batch file. When only a single file is present the batch file will run. As a countermeasure I'm replace %2C by comma. If anyone knows why this behavior occurs please let me know.
  341.  $VlcCmd = replace ($VlcCmd, '%2C', ',', , , );
  342.  writefile ($g_BATFile, $VlcCmd."<crlf>", a, t);
  343. }
  344. writefile ($g_BATFile, "del ".'"'.$g_BATFile.'"', a, t);
  345. run ($g_BATFile, , 0, 0);
  346. }
  347.  
  348. /* SUPPORT SCRIPT FUNCTIONS
  349. * Support functions are designed to perform stand-alone tasks only and return results to the main script functions
  350. */
  351.  
  352. //------------------------------------Youtube Support scripts------------------------------------//
  353. "_Return-Playable-Url"
  354. {
  355. global $g_YoutubeSourceUrl;
  356. global $g_YoutubeSourceContent;
  357.  
  358. $g_YoutubeSourceUrl = "<clipboard>";
  359. sub "_Youtube-Get-SourceData";
  360.  
  361. global $g_MetaTitle;
  362. global $g_MetaDescription;
  363. sub "_SourceData-Get-MetaData";
  364.  
  365. global $g_StreamMap;
  366. sub "_SourceData-Get-StreamMap";
  367. sub "_StreamMap-Decode";
  368.  
  369. global $g_Itags;
  370. sub "_StreamMap-Get-Versions";
  371.  
  372. global $g_VersionsMenuList;
  373. global $g_VersionsMenuChoice;
  374. sub "_Versions-Get-Choice";
  375.  
  376. global $g_PlayableUrl;
  377. sub "_Choice-Create-PlayableUrl";
  378. }
  379.  
  380. "_Youtube-Get-SourceData"
  381. {
  382. global $g_YoutubeSourceUrl;
  383. global $g_YoutubeSourceContent;
  384.  
  385. if (regexmatches ($g_YoutubeSourceUrl, "http[s]?://www\.youtube\.com[^ ]+", , 0)){  
  386.  } else {
  387.   $g_YoutubeSourceUrl = input ("Youtube.com", "Paste Youtube video URL here:", , s, , 300, 200);  
  388.  }
  389.   $g_YoutubeSourceContent = readurl ($g_YoutubeSourceUrl, 0, 0, 4);  
  390.  }
  391.  
  392. "_SourceData-Get-MetaData"
  393.  {
  394.  global $g_YoutubeSourceContent;
  395.  global $g_MetaTitle;
  396.  global $g_MetaDescription;
  397.  
  398.  $g_MetaTitle = regexmatches ($g_YoutubeSourceContent, '"og:title" content="[^"]+', , 0);
  399.  $g_MetaTitle = replace ($g_MetaTitle, '"og:title" content="', , , );
  400.  
  401.  $g_MetaDescription = regexmatches ($g_YoutubeSourceContent, '"og:description" content="[^"]+', , 0);
  402.  $g_MetaDescription = replace ($g_MetaDescription, '"og:description" content="', , , );
  403.  
  404.  //Convert HTML character codes
  405.  //Remove &#38;|&apos; because they interfere with VLC
  406.  $g_MetaTitle = replacelist ($g_MetaTitle, '&quot;|&#34;|&amp;|&#38;|&apos;|&#39;|&lt;|&#60;|&gt;|&#62;', "||&|&|||<|<|>|>", '|', 0);
  407.  $g_MetaDescription = replacelist ($g_MetaDescription, '&quot;|&#34;|&amp;|&#38;|&apos;|&#39;|&lt;|&#60;|&gt;|&#62;', "||&|&|||<|<|>|>", '|', 0);
  408.  
  409.  //Remove all NTFS filename illegal characters.
  410.  //Remove comma because it interferes with VLC
  411.  $g_MetaTitle = replacelist ($g_MetaTitle, '/-,-\-:-*-?-<->-"-|', , "-", 0);
  412.  $g_MetaDescription = replacelist ($g_MetaDescription, '/-,-\-:-*-?-<->-"-|', , "-", 0);
  413.  }
  414.  
  415. "_SourceData-Get-StreamMap"
  416.  {
  417.  global $g_RegEx_Haystack;
  418.  global $g_RegEx_Needles;
  419.  global $g_RegEx_Marker;
  420.  global $g_RegEx_Result;
  421.  
  422.  global $g_YoutubeSourceContent;
  423.  global $g_StreamMap;
  424.  
  425.  $g_RegEx_Haystack = $g_YoutubeSourceContent;
  426.  $g_RegEx_Needles = '"url_encoded_fmt_stream_map": "[^"]+~\w+=[^,]+';
  427.  $g_RegEx_Marker = '~';
  428.  sub "_RegEx_Iso";
  429.  
  430.  $g_StreamMap = $g_RegEx_Result;
  431.  }
  432.  
  433. "_StreamMap-Decode"
  434.  {
  435.  global $g_StreamMap;
  436.  $Streams = '';
  437.  
  438.  foreach ($Map, $g_StreamMap, "|"){
  439.   $Map = urldecode ($Map, 1);
  440.   $Map = replacelist ($Map, '\u0026,sig', '&,signature', ",", 0);  
  441.   $Streams = $Streams.$Map.'|';
  442.  }
  443.  $g_StreamMap = formatlist ($Streams, "e", "|", );
  444.  }
  445.  
  446. "_StreamMap-Get-Versions"
  447.  {
  448.  global $g_StreamMap;
  449.  global $g_Itags;
  450.  
  451.  $g_Itags = regexmatches ($g_StreamMap, 'itag=\d+', '|', 0);
  452.  $g_Itags = replace ($g_Itags, 'itag=', , , , );
  453.  $g_Itags = formatlist ($g_Itags, d, '|', );
  454.  }
  455.  
  456. "_Versions-Get-Choice"
  457.  {
  458.  global $g_VersionsDatabase;
  459.  
  460.  global $g_VersionsMenuList;
  461.  global $g_VersionsMenuChoice;
  462.  global $g_VersionsMenuChoiceExt;
  463.  global $g_Itags;
  464.  
  465.  global $g_MetaTitle;
  466.  global $g_MetaDescription;
  467.  
  468.  $g_VersionsDatabase = <<<#
  469. [036] 240p - 3GP
  470. [017] 144p - 3GP
  471. [013] Unknown - 3GP
  472. [035] 480p - FLV
  473. [034] 360p - FLV
  474. [006] 270p - FLV
  475. [005] 240p - FLV
  476. [102] 360p - WebM (3D)
  477. [101] 360p - WebM (3D)
  478. [100] 720p - WebM (3D)
  479. [046] 1080p - WebM
  480. [045] 720p - WebM
  481. [044] 480p - WebM
  482. [043] 360p - WebM
  483. [085] 520p - MP4 (3D)
  484. [084] 720p - MP4 (3D)
  485. [083] 240p - MP4 (3D)
  486. [082] 360p - MP4 (3D)
  487. [038] 3072p - MP4
  488. [037] 1080p - MP4
  489. [022] 720p - MP4
  490. [018] 360p - MP4
  491. #;
  492.  
  493.  // Loop compares tag numbers found in the Youtube source to a database of corresponding quality levels
  494.  // and creates list $g_VersionsMenuList that allows users to choose which video quality they want to download.
  495.  $g_VersionsMenuList = '';
  496.  foreach ($Tag, $g_Itags, '|'){
  497.   $Tag = format ($Tag, '000');
  498.   $g_VersionsMenuList = $g_VersionsMenuList.regexmatches($g_VersionsDatabase, "\[$Tag\][^\[]+", , 0).'|';
  499.  }
  500.  
  501.  $g_VersionsMenuChoice = inputselect ("Choose video quality:<crlf 2>$g_MetaTitle", $g_VersionsMenuList, "|", 0, , , , );
  502.  $g_VersionsMenuChoiceExt = '.'.recase(regexmatches ($g_VersionsMenuChoice, "3GP|FLV|MP4|WebM", , 0), l, );
  503.  
  504.  // After selecting a quality we retrieve the itag numerical value to use it in the PlayableUrl
  505.  $g_VersionsMenuChoice = regexmatches ($g_VersionsMenuChoice, "\[\d+\]", , 0);
  506.  $g_VersionsMenuChoice = replacelist ($g_VersionsMenuChoice, '[,]', , ',', );
  507.  $g_VersionsMenuChoice = trim ($g_VersionsMenuChoice, "0", "L");
  508.  }
  509.  
  510. "_Choice-Create-PlayableUrl"
  511.  {
  512.  global $g_StreamMap;
  513.  global $g_VersionsMenuChoice;
  514.  global $g_PlayableUrl;
  515.  
  516.  $g_PlayableUrl = regexmatches ($g_StreamMap, "[^|]+([&]?itag=$g_VersionsMenuChoice[^|]+)", , 0);
  517.  
  518.  $HttpFront = regexmatches ($g_PlayableUrl, "http[s]?:[^&]+", , 0);
  519.  $g_PlayableUrl = regexreplace ($g_PlayableUrl, "[&]?(type|quality|itag|fallback_host|url)=[^&]+", , 0);
  520.  $g_PlayableUrl = regexreplace ($g_PlayableUrl, "[?][&]", '?', 0);
  521.  $g_PlayableUrl = $HttpFront.'&'.$g_PlayableUrl."&itag=$g_VersionsMenuChoice";
  522.  
  523.  //Prevents && appearing in the URL
  524.  $g_PlayableUrl = replace ($g_PlayableUrl, '&&', '&', , , );
  525.  }
  526.  
  527. //------------------------------------Regular Expression Engine------------------------------------//  
  528. "_RegEx_Iso"
  529.  {
  530.  /*
  531.  _RegEx_Iso is a sub script that will recursively search a text source.
  532.  By using sequenced regular expressions it is able to isolate embedded text that you
  533.  can not isolate using just a single regular expression.
  534.  
  535.  You must define global variables Haystack, Needles, and Marker in your script as the "arguments"
  536.  to the "method" _RegEx_Iso.
  537.  
  538.  E.g:
  539.  
  540.  $g_RegEx_Haystack = $Source;
  541.  $g_RegEx_Needles = "www\.youtube\.com\/user\/[^""]+"."~"."[^\/]+$";
  542.  $g_RegEx_Marker = "~";
  543.  sub "_RegEx_Iso";
  544.  
  545.  text $g_RegEx_Result;
  546.  */  
  547.  
  548.  global $g_RegEx_Haystack;                      // Text source to search in
  549.  global $g_RegEx_Needles;                       // List of recursive regex to be used
  550.  global $g_RegEx_Marker;                        // Delimiting character used to sequence list of regex
  551.  global $g_RegEx_Result;                        // Result of the search are demarked by "|"
  552.  
  553.  $j = $g_RegEx_Haystack;
  554.  $k = $g_RegEx_Needles;
  555.  $l = $g_RegEx_Marker;
  556.  
  557.  foreach ($i, $k, $l){
  558.   $j = regexmatches ("$j", "$i", "|", "0");
  559.  }
  560.  $g_RegEx_Result = $j;
  561.  
  562.  }
  563.  
  564. "_DEBUGRegEx_Iso"
  565.  {
  566.  /*
  567.  _DEBUGRegEx_Iso will do exactly the same as "_RegEx_Iso".
  568.  In addition it will show the Haystack, Needle, Marker and Result for each
  569.  recursive regular expression cycle. Useful to identify buggy behavior.
  570.  */  
  571.  
  572.  global $g_RegEx_Haystack;
  573.  global $g_RegEx_Needles;
  574.  global $g_RegEx_Marker;
  575.  global $g_RegEx_Result;
  576.  
  577.  $j = $g_RegEx_Haystack;
  578.  $k = $g_RegEx_Needles;
  579.  $l = $g_RegEx_Marker;
  580.  
  581.  foreach ($i, $k, $l){
  582.   text "$j";
  583.   $j = regexmatches ("$j", "$i", "|", "0");
  584.   text "$j <crlf 2>$i <crlf 2>$l";
  585.  }
  586.  $g_RegEx_Result = $j;  
  587.  
  588.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement