Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Title: Livestreamer GUI
- Author: Scott Grossman
- Author Contact: scott DOT grossman AT me DOT com
- Version: 1.0
- Requires: Livestreamer (livestreamer.tanuki.se) & json.ahk (https://raw2.github.com/cocobelgica/AutoHotkey-JSON/master/JSON.ahk)
- Modify and distribute as you please.
- */
- #Include %A_ScriptDir%
- #Include json.ahk ;https://raw2.github.com/cocobelgica/AutoHotkey-JSON/master/JSON.ahk
- #Persistent
- variablefiledir := A_ScriptDir . "\jsonfiles"
- variablefile := variablefiledir . "\stream"
- favoritestreams = tsm_TheOddOne|TSM_Dyrus|TSM_Reginald|TSM_Bjergsen|Trick2g|imaqtpie|PhantomL0rd|tsm_wildturtle|riotgames|DanDihn|Westrice|TSM_Xpecial
- Loop, Parse, favoritestreams, |
- {
- if streams
- streams := streams . "|twitch.tv/" . A_LoopField
- else
- streams := "twitch.tv/" . A_LoopField
- }
- ;Launch Livestreamer GUI with valid streams
- *PrintScreen::
- {
- FileRemoveDir, %variablefiledir%, 1
- FileCreateDir, %variablefiledir%
- checkstreams := streams
- validstreams :=
- haystack := Clipboard
- needle := "^(?:https?:\/\/)?(?:www\.)?((?:(?:twitch\.tv\/)|(?:youtube\.com\/))\S+?)(?:\d\ds)?$"
- matched := RegExMatch(haystack, needle, URL)
- if matched
- checkstreams := URL1 . "|" . streams
- Loop, Parse, checkstreams, |
- {
- jsonfile := variablefile . A_Index . ".json"
- Run %comspec% /c livestreamer -j %A_LoopField% best > "%jsonfile%" ,,Hide, PID%A_Index%
- }
- Loop, Parse, checkstreams, |
- {
- jsonfile := variablefile . A_Index . ".json"
- Process, WaitClose, % PID%A_Index%
- FileRead, Contents, %jsonfile%
- if not ErrorLevel
- {
- j := JSON.parse(Contents)
- if not j.error
- if validstreams
- validstreams := validstreams . "|" . A_LoopField
- else
- validstreams := A_LoopField
- }
- }
- FileRemoveDir, %variablefiledir%, 1
- if validstreams
- {
- Gui, Add, DropDownList, x43 y57 w280 h21 r10 vselectedstream +Choose1, %validstreams%
- Gui, Add, Text, x43 y17 w280 h30 , Select stream to open.
- Gui, Add, Button, x108 y107 w150 h30 , Launch Livestreamer
- ; Generated using SmartGUI Creator 4.0
- Gui, Show, h162 w371, Livestreamer GUI
- Return
- ButtonLaunchLivestreamer:
- Gui, Submit
- Run %comspec% /c livestreamer %selectedstream% best,,Hide
- return
- GuiClose:
- GuiEscape:
- Gui, Destroy
- return
- }
- }
- return
- ;Check for valid streams and launch the first valid one in our list
- *ScrollLock::
- {
- FileRemoveDir, %variablefiledir%, 1
- FileCreateDir, %variablefiledir%
- checkstreams := streams
- validstreams :=
- haystack := Clipboard
- needle := "^(?:https?:\/\/)?(?:www\.)?((?:(?:twitch\.tv\/)|(?:youtube\.com\/))\S+?)(?:\d\ds)?$"
- matched := RegExMatch(haystack, needle, URL)
- if matched
- checkstreams := URL1 . "|" . streams
- Loop, Parse, checkstreams, |
- {
- jsonfile := variablefile . A_Index . ".json"
- Run %comspec% /c livestreamer -j %A_LoopField% best > "%jsonfile%" ,,Hide, PID%A_Index%
- }
- Loop, Parse, checkstreams, |
- {
- jsonfile := variablefile . A_Index . ".json"
- Process, WaitClose, % PID%A_Index%
- FileRead, Contents, %jsonfile%
- if not ErrorLevel
- {
- j := JSON.parse(Contents)
- if not j.error
- {
- Run %comspec% /c livestreamer %A_LoopField% best,,Hide
- break
- }
- }
- }
- FileRemoveDir, %variablefiledir%, 1
- }
- return
Add Comment
Please, Sign In to add comment