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.01
- Requires: Livestreamer (livestreamer.tanuki.se) & json.ahk (https://raw2.github.com/cocobelgica/AutoHotkey-JSON/master/JSON.ahk)
- Modify and distribute as you please.
- Changelog:
- v1.0
- Initial release
- v1.01
- Added a MsgBox when no streams are found.
- v1.1
- Removed hotkeys and persistence
- Run hotkeys in another script or just launch the script with a shortcut or something
- To run it in quick-mode (skipping the GUI) just pass the script any command line parameter
- Example hotkeys:
- PrintScreen::RunWait, Livestreamer.ahk ; Launch GUI
- *PrintScreen::Runwait, Livestreamer.ahk true ; Quick-Mode (No GUI)
- */
- #Include %A_ScriptDir%
- #Include json.ahk ;https://raw2.github.com/cocobelgica/AutoHotkey-JSON/master/JSON.ahk
- #SingleInstance ignore
- #LTrim
- favoritestreams =
- (
- riotgames
- TSM_TheOddOne
- TSM_Dyrus
- wingsofdeath
- TSM_Reginald
- TSM_Bjergsen
- imaqtpie
- TSM_WildTurtle
- Trick2g
- PhantomL0rd
- dandinh
- Westrice
- TSM_Xpecial
- )
- variablefiledir := A_ScriptDir . "\Livestreamer"
- variablefile := variablefiledir . "\stream"
- Loop, Parse, favoritestreams, `n
- {
- if streams
- streams := streams . "|twitch.tv/" . A_LoopField
- else
- streams := "twitch.tv/" . A_LoopField
- }
- FileRemoveDir, %variablefiledir%, 1
- FileCreateDir, %variablefiledir%
- validstreams :=
- foundone := false
- haystack := Clipboard
- needle := "^(?:https?:\/\/)?(?:www\.)?((?:(?:twitch\.tv\/)|(?:youtube\.com\/))\S+?)(?:\d\ds)?$"
- matched := RegExMatch(haystack, needle, URL)
- if matched
- streams := URL1 . "|" . streams
- Loop, Parse, streams, |
- {
- jsonfile := variablefiledir . "\templog" . A_Index . ".txt"
- Run %comspec% /c livestreamer -j %A_LoopField% best > "%jsonfile%" ,,Hide, PID%A_Index%
- }
- Loop, Parse, streams, |
- {
- jsonfile := variablefiledir . "\templog" . A_Index . ".txt"
- Process, WaitClose, % PID%A_Index%
- FileRead, Contents, %jsonfile%
- if not ErrorLevel
- {
- j := JSON.parse(Contents)
- if not j.error
- if %1%
- {
- Run %comspec% /c livestreamer %A_LoopField% best,,Hide
- foundone := true
- break
- }
- else 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
- }
- else if !foundone
- {
- MsgBox, No streams found online
- ExitApp
- }
- ButtonLaunchLivestreamer:
- Gui, Submit
- Run %comspec% /c livestreamer %selectedstream% best,,Hide
- ExitApp
- return
- GuiClose:
- GuiEscape:
- Gui, Destroy
- ExitApp
- return
Add Comment
Please, Sign In to add comment