Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "_Initialize"
- {
- global $g_Rtmp;
- global $g_Vlc;
- global $g_User;
- global $g_Recents;
- global $g_INIFile;
- $g_INIFile = "<xyscripts>\TwitchTV.ini";
- if (exists($g_INIFile) == 1){
- $g_Rtmp = getkey ("Rtmp", "Config", $g_INIFile, );
- $g_Vlc = getkey ("Vlc", "Config", $g_INIFile, );
- $g_User = getkey ("User", "Config", $g_INIFile, );
- $g_Recents = getkey ('Count', 'RecentlyWatched', $g_INIFile, );
- } else {
- msg <<<#
- 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.
- 1. Select the location of rtmpdump.exe
- 2. Select the location of vlc.exe
- 3. Enter your Twitch user name only (NO PASSWORD!!!)
- #;
- $g_Rtmp = inputfile ("C:", "exe", "Configuration on first script run - Select rtmpdump.exe");
- $g_Vlc = inputfile ("C:", "exe", "Configuration on first script run - Select vlc.exe");
- $g_User = input ("Configuration on first script run - Enter your Twitch.tv account user name");
- $Configuration = <<<#
- [Config]
- Rtmp=$g_Rtmp
- Vlc=$g_Vlc
- User=$g_User
- [RecentlyWatched]
- Count=0
- #;
- writefile ($g_INIFile, $Configuration, o, t);
- msg <<<#
- The script is now configured for use!
- #;
- }
- }
- "Show 25 Top Games"
- {
- global $g_A;
- global $g_Games;
- sub "_API-Games-Get-Top";
- global $g_SelectedGame;
- $g_SelectedGame = inputselect("[$g_A] Games are listed based on viewer count", "$g_Games", "|", "0", , "200","500", );
- global $g_Channels;
- global $g_SelectedChannel;
- sub "_API-Channels-Get-Game";
- $g_SelectedChannel = inputselect("[$g_A] Channels are listed based on viewer count", "$g_Channels", "|", "0", , "200", "500", );
- global $g_UsherXml;
- sub "_USHER-XML-Get";
- global $g_Qualities;
- global $g_SelectedQuality;
- sub "_USHER-XML-Get-Qualities";
- $g_SelectedQuality = inputselect("[$g_A] $g_SelectedChannel", "$g_Qualities", "|", "0", , "200", "500", );
- global $g_Connect;
- global $g_Play;
- global $g_Token;
- sub "_USHER-Qualities-Param";
- global $g_RunCmd;
- sub "_PARSE-Construct";
- writefile ("<xyscripts>\TwitchTV.bat", "$g_RunCmd<crlf>del ""<xyscripts>\TwitchTV.bat""", "o", "t");
- run ("<xyscripts>\TwitchTV.bat", , 0, 0);
- sub "_Add-Recently-Played";
- }
- "Show 50 Top Channels"
- {
- global $g_A;
- global $g_Channels;
- global $g_SelectedChannel;
- sub "_API-Channels-Get-All";
- $g_SelectedChannel = inputselect("[$g_A] Channels are listed based on viewer count", "$g_Channels", "|", "0", , "200", "500", );
- global $g_UsherXml;
- sub "_USHER-XML-Get";
- global $g_Qualities;
- global $g_SelectedQuality;
- sub "_USHER-XML-Get-Qualities";
- $g_SelectedQuality = inputselect("[$g_A] $g_SelectedChannel", "$g_Qualities", "|", "0", , "200", "500", );
- global $g_Connect;
- global $g_Play;
- global $g_Token;
- sub "_USHER-Qualities-Param";
- global $g_RunCmd;
- sub "_PARSE-Construct";
- writefile ("<xyscripts>\TwitchTV.bat", "$g_RunCmd<crlf>del ""<xyscripts>\TwitchTV.bat""", "o", "t");
- run ("<xyscripts>\TwitchTV.bat", , 0, 0);
- sub "_Add-Recently-Played";
- }
- "Show Recently Played"
- {
- global $g_A;
- global $g_INIFile;
- $Count = getkey ('Count', 'RecentlyWatched', $g_INIFile, );
- $b = '1';
- $RecentlyPlayed = '';
- while ($b <= $Count){
- $RecentlyPlayed = $RecentlyPlayed.getkey($b, 'RecentlyWatched', $g_INIFile, ).'|';
- $b++
- }
- $RecentlyPlayed = formatlist ($RecentlyPlayed, dve, |, );
- global $g_SelectedChannel;
- $g_SelectedChannel = inputselect("[$g_A] Channels are listed based on last played", "$RecentlyPlayed", "|", "0", , "200", "500", );
- global $g_UsherXml;
- sub "_USHER-XML-Get";
- global $g_Qualities;
- global $g_SelectedQuality;
- sub "_USHER-XML-Get-Qualities";
- $g_SelectedQuality = inputselect("[$g_A] $g_SelectedChannel", "$g_Qualities", "|", "0", , "200", "500", );
- global $g_Connect;
- global $g_Play;
- global $g_Token;
- sub "_USHER-Qualities-Param";
- global $g_RunCmd;
- sub "_PARSE-Construct";
- writefile ("<xyscripts>\TwitchTV.bat", "$g_RunCmd<crlf>del ""<xyscripts>\TwitchTV.bat""", "o", "t");
- run ("<xyscripts>\TwitchTV.bat", , 0, 0);
- sub "_Add-Recently-Played";
- }
- "Show Followed Channels"
- {
- global $g_A;
- global $g_Channels;
- global $g_SelectedChannel;
- sub "_API-Channels-Get-Followed";
- //sub "_API-Channels-Get-Followed-Status";
- $g_SelectedChannel = inputselect("[$g_A] Channels are listed randomly", "$g_Channels", "|", "0", , "200", "500", );
- global $g_UsherXml;
- sub "_USHER-XML-Get";
- global $g_Qualities;
- global $g_SelectedQuality;
- sub "_USHER-XML-Get-Qualities";
- $g_SelectedQuality = inputselect("[$g_A] $g_SelectedChannel", "$g_Qualities", "|", "0", , "200", "500", );
- global $g_Connect;
- global $g_Play;
- global $g_Token;
- sub "_USHER-Qualities-Param";
- global $g_RunCmd;
- sub "_PARSE-Construct";
- writefile ("<xyscripts>\TwitchTV.bat", "$g_RunCmd<crlf>del ""<xyscripts>\TwitchTV.bat""", "o", "t");
- run ("<xyscripts>\TwitchTV.bat", , 0, 0);
- sub "_Add-Recently-Played";
- }
- "Enter Channel Name"
- {
- global $g_A;
- global $g_SelectedChannel;
- $g_SelectedChannel = input ("Type the channel name as it appears in the Twitch.tv URL", , "towelliee", "s", , , );
- global $g_UsherXml;
- sub "_USHER-XML-Get";
- global $g_Qualities;
- global $g_SelectedQuality;
- sub "_USHER-XML-Get-Qualities";
- $g_SelectedQuality = inputselect("[$g_A] $g_SelectedChannel", "$g_Qualities", "|", "0", , "200", "500", );
- global $g_Connect;
- global $g_Play;
- global $g_Token;
- sub "_USHER-Qualities-Param";
- global $g_RunCmd;
- sub "_PARSE-Construct";
- writefile ("<xyscripts>\TwitchTV.bat", "$g_RunCmd<crlf>del ""<xyscripts>\TwitchTV.bat""", o, t);
- run ("<xyscripts>\TwitchTV.bat", , 0, 0);
- sub "_Add-Recently-Played";
- }
- "_API-Games-Get-Top"
- {
- global $g_Games;
- global $g_A;
- global $g_Url;
- global $g_Return;
- $g_Url = 'https://api.twitch.tv/kraken/games/top?limit=25';
- sub "_ReadUrl-Loop";
- $APIGames = $g_Return;
- $RegEx = '["][A-Z0-9][^"]*["]';
- $g_Games = regexmatches($APIGames, $RegEx, '|', 1);
- $g_Games = formatlist ($g_Games, 'u', '|', );
- }
- "_API-Channels-Get-Game"
- {
- global $g_SelectedGame;
- global $g_Channels;
- global $g_A;
- global $g_Url;
- global $g_Return;
- $g_SelectedGame = urlencode ($g_SelectedGame, 0);
- $g_SelectedGame = replace ($g_SelectedGame, ':', '%58', , );
- $g_Url = "https://api.twitch.tv/kraken/streams?game=$g_SelectedGame";
- sub "_ReadUrl-Loop";
- $APIChannels = $g_Return;
- $RegEx = '["]url["]:["][^"]+["]';
- $g_Channels = regexmatches ($APIChannels, $RegEx, |, 0);
- $g_Channels = formatlist ($g_Channels, 'u', '|', );
- $g_Channels = replace ($g_Channels, 'url":"http://www.twitch.tv/', , , );
- }
- "_API-Channels-Get-All"
- {
- global $g_Channels;
- global $g_A;
- global $g_Url;
- global $g_Return;
- $g_Url = 'https://api.twitch.tv/kraken/streams';
- sub "_ReadUrl-Loop";
- $APIChannels = $g_Return;
- $RegEx = '["]url["]:["][^"]+["]';
- $g_Channels = regexmatches ($APIChannels, $RegEx, |, 0);
- $g_Channels = formatlist ($g_Channels, u, |, );
- $g_Channels = replace ($g_Channels, 'url":"http://www.twitch.tv/', , , );
- }
- "_API-Channels-Get-Followed"
- {
- global $g_User;
- global $g_Channels;
- global $g_A;
- global $g_Url;
- global $g_Return;
- $g_Url = "https://api.twitch.tv/kraken/users/$g_User/follows/channels?limit=50";
- sub "_ReadUrl-Loop";
- $APIChannels = $g_Return;
- $regEx = "[""]url[""]:[""][^""]+[""]";
- $g_Channels = regexmatches ($APIChannels, $regEx, "|", "1");
- $g_Channels = formatlist ($g_Channels, "u", "|", );
- $g_Channels = replace ($g_Channels, 'url":"http://www.twitch.tv/', , , );
- }
- "_API-Channels-Get-Followed-Status"
- {
- global $g_Channels;
- $List = '';
- foreach ($Channel, $g_Channels, "|"){
- $g_Url = "https://api.twitch.tv/kraken/streams/$Channel";
- sub "_ReadUrl-Loop";
- $Data = $g_Return;
- if (regexmatches($Data, '"stream":null,', "", "0")){
- } else {$List = $List.$Channel."|";}
- }
- $g_Channels = $List;
- formatlist ($g_Channels, e, |, );
- }
- "_USHER-XML-Get"
- {
- global $g_SelectedChannel;
- global $g_UsherXml;
- global $g_A;
- global $g_Url;
- global $g_Return;
- $g_Url = "http://usher.twitch.tv/find/$g_SelectedChannel.xml?type=any";
- sub "_ReadUrl-Loop";
- $g_UsherXml = $g_Return;
- }
- "_USHER-XML-Get-Qualities"
- {
- global $g_UsherXml;
- global $g_Qualities;
- $RegEx = '<live>|<1080p>|<720p>|<480p>|<360p>|<iphonehigh>|<iphonelow>';
- $g_Qualities = regexmatches ($g_UsherXml, $RegEx, |, 0);
- $g_Qualities = replacelist ($g_Qualities, '<>');
- }
- "_USHER-Qualities-Param"
- {
- global $g_UsherXml;
- global $g_Qualities;
- global $g_SelectedQuality;
- global $g_Connect;
- global $g_Play;
- global $g_Token;
- $RegEx = "<$g_SelectedQuality>.+<\/$g_SelectedQuality>";
- $Data = regexmatches ($g_UsherXml, $RegEx, |, 0);
- $RegEx = "<connect>.+<\/connect>";
- $g_Connect = regexmatches ($Data, $RegEx, |, 0);
- $g_Connect = replacelist ($g_Connect, "<connect>,</connect>", , ',');
- $RegEx = "<play>.+<\/play>";
- $g_Play = regexmatches ($Data, $RegEx, |, 0);
- $g_Play = replacelist ($g_Play, "<play>,</play>", , ',');
- $RegEx = "<token>.+<\/token>";
- $g_Token = regexmatches ($Data, $RegEx, |, 0);
- $g_Token = replacelist ($g_Token, "<token>,</token>", , ',');
- }
- "_PARSE-Construct"
- {
- global $g_Rtmp;
- global $g_Vlc;
- global $g_SelectedChannel;
- global $g_Connect;
- global $g_Play;
- global $g_Token;
- global $g_RunCmd;
- $Swf = "http://www-cdn.jtvnw.net/widgets/live_embed_player.r0608eb1adc726dde8f9321d2ad7935146c0f38e6.swf?channel=$g_SelectedChannel&referer=&userAgent=&channel=$g_SelectedChannel";
- $g_Token = replace ($g_Token, '"', '\"', , );
- $g_RunCmd = """$g_Rtmp"" -r ""$g_Connect/$g_Play"" -j ""$g_Token"" --swfVfy ""$Swf"" -v -o - | ""$g_Vlc"" -";
- }
- "_ReadUrl-Loop"
- {
- global $g_A;
- global $g_Url;
- global $g_Return;
- $g_A = '0';
- $g_Return = '';
- while(strlen($g_Return) < '25'){
- $g_Return = readurl($g_Url, 0, 0, 2);
- $g_A++;
- if(strlen($g_Return) > '25'){
- break;
- }
- }
- }
- "_Add-Recently-Played"
- {
- global $g_INIFile;
- global $g_SelectedChannel;
- $Count = getkey ('Count', 'RecentlyWatched', $g_INIFile, );
- $Count++;
- setkey ($Count, Count, 'RecentlyWatched', $g_INIFile, );
- setkey ($g_SelectedChannel, $Count, 'RecentlyWatched', $g_INIFile, );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement