Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "_Initialize"
- {
- // Configuration .ini file
- global $g_ConfigurationFile;
- $g_ConfigurationFile = "<xyscripts>\Twitch.ini";
- // Execution and buffer files
- global $g_ExecutionFile;
- $g_ExecutionFile = "<xyscripts>\Twitch.bat";
- // Configuration keys
- global $g_ScriptVersion;
- $g_ScriptVersion = '0.6';
- global $g_Vlc;
- global $g_Rtmp;
- global $g_User;
- if (exists("$g_ConfigurationFile") == '1' && $g_ScriptVersion == getkey('ScriptVersion', 'Configuration', "$g_ConfigurationFile", )){
- // Load keys
- $g_Vlc = getkey ('Vlc', 'Configuration', "$g_ConfigurationFile", );
- $g_Rtmp = getkey ('Rtmp', 'Configuration', "$g_ConfigurationFile", );
- $g_User = getkey ('User', 'Configuration', "$g_ConfigurationFile", );
- } else {
- msg <<<#
- Script is not configured.
- The configuration wizard will assist you.
- #;
- sub "_Configure";
- }
- }
- "_Configure"
- {
- global $g_ConfigurationFile;
- msg <<<#
- This wizard configures the script for first use. To edit the configuration file click "Edit Configuration" after launching the script. If the configuration file is not found or you upgrade to a new version of this script the wizard will appear automatically.
- The configuration file is located at:
- $g_ConfigurationFile
- #;
- // Delete old configuration file
- delete (0, 0, "$g_ConfigurationFile");
- // Define parameters
- global $g_ScriptVersion;
- global $g_Vlc;
- global $g_Downloads;
- $g_Vlc = inputfile ('C:\', 'exe', 'Select vlc.exe');
- $g_Rtmp = inputfile ('C:\', 'exe', 'Select rtmp.exe');
- $g_User = input ('Enter your Twitch.tv user name');
- // Write configuration to disk
- $Configuration = <<<#
- [Configuration]
- ScriptVersion=$g_ScriptVersion
- Vlc=$g_Vlc
- Rtmp=$g_Rtmp
- User=$g_User
- [RecentlyWatched]
- Count=0
- #;
- writefile ("$g_ConfigurationFile", "$Configuration", o, t);
- msg <<<#
- Configuration completed.
- #;
- }
- "Show 50 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 100 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 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=50';
- 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, 1);
- $g_SelectedGame = replace ($g_SelectedGame, ':', '%3A', , );
- $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.r0115b78b21bb98fce53f2221edac6932395f8a59.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"" -";
- $g_RunCmd = """$g_Rtmp"" -r ""$g_Connect/$g_Play"" --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, );
- $g_A++;
- if(strlen($g_Return) > '25'){
- break;
- }
- }
- }
- "_Add-Recently-Played"
- {
- global $g_ConfigurationFile;
- global $g_SelectedChannel;
- $Count = getkey ('Count', 'RecentlyWatched', $g_ConfigurationFile, );
- $Count++;
- setkey ($Count, Count, 'RecentlyWatched', $g_ConfigurationFile, );
- setkey ($g_SelectedChannel, $Count, 'RecentlyWatched', $g_ConfigurationFile, );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement