Advertisement
AnarchyOnline

Twitch.xys 0.5

Apr 23rd, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 10.38 KB | None | 0 0
  1. "_Initialize"
  2.  {
  3.  global $g_Rtmp;
  4.  global $g_Vlc;
  5.  global $g_User;
  6.  global $g_Recents;
  7.  global $g_INIFile;
  8.  
  9.  $g_INIFile = "<xyscripts>\TwitchTV.ini";
  10.  
  11.  if (exists($g_INIFile) == 1){
  12.   $g_Rtmp = getkey ("Rtmp", "Config", $g_INIFile, );
  13.   $g_Vlc = getkey ("Vlc", "Config", $g_INIFile, );
  14.   $g_User = getkey ("User", "Config", $g_INIFile, );
  15.   $g_Recents = getkey ('Count', 'RecentlyWatched', $g_INIFile, );
  16.  } else {
  17.  
  18.   msg <<<#
  19. This is your first time running Twitch.xys 0.5 or you have deleted your configuration file. This configuration wizard helps you quickly configure the script for use. You can later edit your configuration file through the script.
  20.  
  21. 1. Select the location of rtmpdump.exe
  22. 2. Select the location of vlc.exe
  23. 3. Enter your Twitch user name only (NO PASSWORD!!!)
  24. #;
  25.  
  26.   $g_Rtmp = inputfile ("C:", "exe", "Configuration on first script run - Select rtmpdump.exe");
  27.   $g_Vlc = inputfile ("C:", "exe", "Configuration on first script run - Select vlc.exe");
  28.   $g_User = input ("Configuration on first script run - Enter your Twitch.tv account user name");
  29.  
  30.   $Configuration = <<<#
  31. [Config]  
  32. Rtmp=$g_Rtmp
  33. Vlc=$g_Vlc
  34. User=$g_User
  35.  
  36. [RecentlyWatched]
  37. Count=0
  38. #;
  39.   writefile ($g_INIFile, $Configuration, o, t);
  40.   msg <<<#
  41. The script is now configured for use!
  42. #;
  43.  }
  44.  }
  45.  
  46. "Show 25 Top Games"
  47.  {
  48.  global $g_A;
  49.  
  50.  global $g_Games;
  51.  sub "_API-Games-Get-Top";
  52.  
  53.  global $g_SelectedGame;
  54.  $g_SelectedGame = inputselect("[$g_A] Games are listed based on viewer count", "$g_Games", "|", "0", , "200","500", );
  55.  
  56.  global $g_Channels;
  57.  global $g_SelectedChannel;
  58.  sub "_API-Channels-Get-Game";
  59.  $g_SelectedChannel = inputselect("[$g_A] Channels are listed based on viewer count", "$g_Channels", "|", "0", , "200", "500", );
  60.  
  61.  global $g_UsherXml;
  62.  sub "_USHER-XML-Get";
  63.  
  64.  global $g_Qualities;
  65.  global $g_SelectedQuality;
  66.  sub "_USHER-XML-Get-Qualities";
  67.  $g_SelectedQuality = inputselect("[$g_A] $g_SelectedChannel", "$g_Qualities", "|", "0", , "200", "500", );
  68.  
  69.  global $g_Connect;
  70.  global $g_Play;
  71.  global $g_Token;
  72.  sub "_USHER-Qualities-Param";
  73.  
  74.  global $g_RunCmd;
  75.  sub "_PARSE-Construct";
  76.  
  77.  writefile ("<xyscripts>\TwitchTV.bat", "$g_RunCmd<crlf>del ""<xyscripts>\TwitchTV.bat""", "o", "t");
  78.  run ("<xyscripts>\TwitchTV.bat", , 0, 0);
  79.  
  80.  sub "_Add-Recently-Played";
  81.  }
  82.  
  83. "Show 50 Top Channels"
  84.  {
  85.  global $g_A;
  86.  
  87.  global $g_Channels;
  88.  global $g_SelectedChannel;
  89.  sub "_API-Channels-Get-All";
  90.  $g_SelectedChannel = inputselect("[$g_A] Channels are listed based on viewer count", "$g_Channels", "|", "0", , "200", "500", );
  91.  
  92.  global $g_UsherXml;
  93.  sub "_USHER-XML-Get";
  94.  
  95.  global $g_Qualities;
  96.  global $g_SelectedQuality;
  97.  sub "_USHER-XML-Get-Qualities";
  98.  $g_SelectedQuality = inputselect("[$g_A] $g_SelectedChannel", "$g_Qualities", "|", "0", , "200", "500", );
  99.  
  100.  global $g_Connect;
  101.  global $g_Play;
  102.  global $g_Token;
  103.  sub "_USHER-Qualities-Param";
  104.  
  105.  global $g_RunCmd;
  106.  sub "_PARSE-Construct";
  107.  
  108.  writefile ("<xyscripts>\TwitchTV.bat", "$g_RunCmd<crlf>del ""<xyscripts>\TwitchTV.bat""", "o", "t");
  109.  run ("<xyscripts>\TwitchTV.bat", , 0, 0);  
  110.  
  111.  sub "_Add-Recently-Played";
  112.  }
  113.  
  114. "Show Recently Played"
  115.  {
  116.  global $g_A;
  117.  
  118.  global $g_INIFile;
  119.  $Count = getkey ('Count', 'RecentlyWatched', $g_INIFile, );
  120.  
  121.  $b = '1';
  122.  $RecentlyPlayed = '';
  123.  
  124.  while ($b <= $Count){
  125.   $RecentlyPlayed = $RecentlyPlayed.getkey($b, 'RecentlyWatched', $g_INIFile, ).'|';
  126.   $b++
  127.  }
  128.  $RecentlyPlayed = formatlist ($RecentlyPlayed, dve, |, );
  129.  
  130.  global $g_SelectedChannel;
  131.  $g_SelectedChannel = inputselect("[$g_A] Channels are listed based on last played", "$RecentlyPlayed", "|", "0", , "200", "500", );
  132.  
  133.  global $g_UsherXml;
  134.  sub "_USHER-XML-Get";
  135.  
  136.  global $g_Qualities;
  137.  global $g_SelectedQuality;
  138.  sub "_USHER-XML-Get-Qualities";
  139.  $g_SelectedQuality = inputselect("[$g_A] $g_SelectedChannel", "$g_Qualities", "|", "0", , "200", "500", );
  140.  
  141.  global $g_Connect;
  142.  global $g_Play;
  143.  global $g_Token;
  144.  sub "_USHER-Qualities-Param";
  145.  
  146.  global $g_RunCmd;
  147.  sub "_PARSE-Construct";
  148.  
  149.  writefile ("<xyscripts>\TwitchTV.bat", "$g_RunCmd<crlf>del ""<xyscripts>\TwitchTV.bat""", "o", "t");
  150.  run ("<xyscripts>\TwitchTV.bat", , 0, 0);  
  151.  
  152.  sub "_Add-Recently-Played";
  153.  }
  154.  
  155. "Show Followed Channels"
  156.  {
  157.  global $g_A;
  158.  
  159.  global $g_Channels;
  160.  global $g_SelectedChannel;
  161.  sub "_API-Channels-Get-Followed";
  162.  //sub "_API-Channels-Get-Followed-Status";
  163.  
  164.  $g_SelectedChannel = inputselect("[$g_A] Channels are listed randomly", "$g_Channels", "|", "0", , "200", "500", );
  165.  
  166.  global $g_UsherXml;
  167.  sub "_USHER-XML-Get";
  168.  
  169.  global $g_Qualities;
  170.  global $g_SelectedQuality;
  171.  sub "_USHER-XML-Get-Qualities";
  172.  $g_SelectedQuality = inputselect("[$g_A] $g_SelectedChannel", "$g_Qualities", "|", "0", , "200", "500", );
  173.  
  174.  global $g_Connect;
  175.  global $g_Play;
  176.  global $g_Token;
  177.  sub "_USHER-Qualities-Param";
  178.  
  179.  global $g_RunCmd;
  180.  sub "_PARSE-Construct";
  181.  
  182.  writefile ("<xyscripts>\TwitchTV.bat", "$g_RunCmd<crlf>del ""<xyscripts>\TwitchTV.bat""", "o", "t");
  183.  run ("<xyscripts>\TwitchTV.bat", , 0, 0);  
  184.  
  185.  sub "_Add-Recently-Played";
  186.  }
  187.  
  188. "Enter Channel Name"
  189.  {
  190.  global $g_A;
  191.  
  192.  global $g_SelectedChannel;
  193.  $g_SelectedChannel = input ("Type the channel name as it appears in the Twitch.tv URL", , "towelliee", "s", , , );
  194.  
  195.  global $g_UsherXml;
  196.  sub "_USHER-XML-Get";
  197.  
  198.  global $g_Qualities;
  199.  global $g_SelectedQuality;
  200.  sub "_USHER-XML-Get-Qualities";
  201.  $g_SelectedQuality = inputselect("[$g_A] $g_SelectedChannel", "$g_Qualities", "|", "0", , "200", "500", );
  202.  
  203.  global $g_Connect;
  204.  global $g_Play;
  205.  global $g_Token;
  206.  sub "_USHER-Qualities-Param";
  207.  
  208.  global $g_RunCmd;
  209.  sub "_PARSE-Construct";
  210.  
  211.  writefile ("<xyscripts>\TwitchTV.bat", "$g_RunCmd<crlf>del ""<xyscripts>\TwitchTV.bat""", o, t);
  212.  run ("<xyscripts>\TwitchTV.bat", , 0, 0);
  213.  
  214.  sub "_Add-Recently-Played";
  215.  }
  216.  
  217. "_API-Games-Get-Top"
  218.  {
  219.  global $g_Games;
  220.  
  221.  global $g_A;
  222.  global $g_Url;
  223.  global $g_Return;
  224.  
  225.  $g_Url = 'https://api.twitch.tv/kraken/games/top?limit=25';
  226.  sub "_ReadUrl-Loop";
  227.  $APIGames = $g_Return;
  228.  
  229.  $RegEx = '["][A-Z0-9][^"]*["]';
  230.  $g_Games = regexmatches($APIGames, $RegEx, '|', 1);
  231.  $g_Games = formatlist ($g_Games, 'u', '|', );
  232.  }
  233.  
  234. "_API-Channels-Get-Game"
  235.  {
  236.  global $g_SelectedGame;
  237.  global $g_Channels;
  238.  
  239.  global $g_A;
  240.  global $g_Url;
  241.  global $g_Return;
  242.  
  243.  $g_SelectedGame = urlencode ($g_SelectedGame, 0);
  244.  $g_SelectedGame = replace ($g_SelectedGame, ':', '%58', , );
  245.  
  246.  $g_Url = "https://api.twitch.tv/kraken/streams?game=$g_SelectedGame";
  247.  sub "_ReadUrl-Loop";
  248.  $APIChannels = $g_Return;
  249.  
  250.  $RegEx = '["]url["]:["][^"]+["]';
  251.  $g_Channels = regexmatches ($APIChannels, $RegEx, |, 0);
  252.  $g_Channels = formatlist ($g_Channels, 'u', '|', );  
  253.  $g_Channels = replace ($g_Channels, 'url":"http://www.twitch.tv/', , , );
  254.  }
  255.  
  256. "_API-Channels-Get-All"
  257.  {
  258.  global $g_Channels;
  259.  
  260.  global $g_A;
  261.  global $g_Url;
  262.  global $g_Return;
  263.  
  264.  $g_Url = 'https://api.twitch.tv/kraken/streams';
  265.  sub "_ReadUrl-Loop";
  266.  $APIChannels = $g_Return;
  267.  
  268.  $RegEx = '["]url["]:["][^"]+["]';
  269.  $g_Channels = regexmatches ($APIChannels, $RegEx, |, 0);
  270.  $g_Channels = formatlist ($g_Channels, u, |, );  
  271.  $g_Channels = replace ($g_Channels, 'url":"http://www.twitch.tv/', , , );
  272.  }
  273.  
  274. "_API-Channels-Get-Followed"
  275.  {
  276.  global $g_User;
  277.  global $g_Channels;
  278.  
  279.  global $g_A;
  280.  global $g_Url;
  281.  global $g_Return;
  282.  
  283.  $g_Url = "https://api.twitch.tv/kraken/users/$g_User/follows/channels?limit=50";
  284.  sub "_ReadUrl-Loop";
  285.  $APIChannels = $g_Return;
  286.  
  287.  $regEx = "[""]url[""]:[""][^""]+[""]";
  288.  $g_Channels = regexmatches ($APIChannels, $regEx, "|", "1");
  289.  $g_Channels = formatlist ($g_Channels, "u", "|", );  
  290.  $g_Channels = replace ($g_Channels, 'url":"http://www.twitch.tv/', , , );
  291.  }
  292.  
  293. "_API-Channels-Get-Followed-Status"
  294.  {
  295.  global $g_Channels;
  296.  $List = '';
  297.  
  298.  foreach ($Channel, $g_Channels, "|"){
  299.   $g_Url = "https://api.twitch.tv/kraken/streams/$Channel";
  300.   sub "_ReadUrl-Loop";
  301.   $Data = $g_Return;
  302.    if (regexmatches($Data, '"stream":null,', "", "0")){
  303.    } else {$List = $List.$Channel."|";}
  304.  }
  305.  $g_Channels = $List;
  306.  formatlist ($g_Channels, e, |, );
  307.  }
  308.  
  309. "_USHER-XML-Get"
  310.  {
  311.  global $g_SelectedChannel;
  312.  global $g_UsherXml;
  313.  
  314.  global $g_A;
  315.  global $g_Url;
  316.  global $g_Return;
  317.  
  318.  $g_Url = "http://usher.twitch.tv/find/$g_SelectedChannel.xml?type=any";
  319.  sub "_ReadUrl-Loop";
  320.  $g_UsherXml = $g_Return;  
  321.  }
  322.  
  323. "_USHER-XML-Get-Qualities"
  324.  {
  325.  global $g_UsherXml;
  326.  global $g_Qualities;
  327.    
  328.  $RegEx = '<live>|<1080p>|<720p>|<480p>|<360p>|<iphonehigh>|<iphonelow>';
  329.  $g_Qualities = regexmatches ($g_UsherXml, $RegEx, |, 0);
  330.  $g_Qualities = replacelist ($g_Qualities, '<>');
  331.  }
  332.  
  333. "_USHER-Qualities-Param"
  334.  {
  335.  global $g_UsherXml;
  336.  global $g_Qualities;
  337.  global $g_SelectedQuality;
  338.  
  339.  global $g_Connect;
  340.  global $g_Play;
  341.  global $g_Token;
  342.  
  343.  $RegEx = "<$g_SelectedQuality>.+<\/$g_SelectedQuality>";
  344.  $Data = regexmatches ($g_UsherXml, $RegEx, |, 0);
  345.  
  346.  $RegEx = "<connect>.+<\/connect>";
  347.  $g_Connect = regexmatches ($Data, $RegEx, |, 0);
  348.  $g_Connect = replacelist ($g_Connect, "<connect>,</connect>", , ',');
  349.  
  350.  $RegEx = "<play>.+<\/play>";
  351.  $g_Play = regexmatches ($Data, $RegEx, |, 0);
  352.  $g_Play = replacelist ($g_Play, "<play>,</play>", , ',');
  353.  
  354.  $RegEx = "<token>.+<\/token>";
  355.  $g_Token = regexmatches ($Data, $RegEx, |, 0);
  356.  $g_Token = replacelist ($g_Token, "<token>,</token>", , ',');  
  357.  }
  358.  
  359. "_PARSE-Construct"
  360.  {
  361.  global $g_Rtmp;
  362.  global $g_Vlc;
  363.  global $g_SelectedChannel;
  364.  
  365.  global $g_Connect;
  366.  global $g_Play;
  367.  global $g_Token;
  368.  
  369.  global $g_RunCmd;
  370.  
  371.  $Swf = "http://www-cdn.jtvnw.net/widgets/live_embed_player.r0608eb1adc726dde8f9321d2ad7935146c0f38e6.swf?channel=$g_SelectedChannel&referer=&userAgent=&channel=$g_SelectedChannel";
  372.  $g_Token = replace ($g_Token, '"', '\"', , );
  373.  
  374.  $g_RunCmd = """$g_Rtmp"" -r ""$g_Connect/$g_Play"" -j ""$g_Token"" --swfVfy ""$Swf"" -v -o - | ""$g_Vlc"" -";
  375.  }
  376.  
  377. "_ReadUrl-Loop"
  378.  {
  379.  global $g_A;
  380.  global $g_Url;
  381.  global $g_Return;
  382.  
  383.  $g_A = '0';
  384.  $g_Return = '';
  385.  
  386.  while(strlen($g_Return) < '25'){
  387.   $g_Return = readurl($g_Url, 0, 0, 2);
  388.   $g_A++;
  389.   if(strlen($g_Return) > '25'){
  390.    break;
  391.   }
  392.  }
  393.  }
  394.  
  395. "_Add-Recently-Played"
  396.  {
  397.  global $g_INIFile;
  398.  global $g_SelectedChannel;
  399.  
  400.  $Count = getkey ('Count', 'RecentlyWatched', $g_INIFile, );
  401.  $Count++;
  402.  setkey ($Count, Count, 'RecentlyWatched', $g_INIFile, );
  403.  setkey ($g_SelectedChannel, $Count, 'RecentlyWatched', $g_INIFile, );
  404.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement