aveyo

Streamlink

Oct 28th, 2017
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 6.99 KB | None | 0 0
  1. goto="Streamlink.Init" /*
  2. ::     url input + stream choice dialogs and hidecmd launcher v8 final
  3. :: Save as Streamlink.bat in Streamlink folder, can be called using [Win+R] Run-menu after first launch
  4. :: streamlink                             = with no arguments shows url input-dialog
  5. :: streamlink dreamleague                 = with just the url or twitch channel name shows stream choice-dialog  
  6. :: streamlink twitch.tv/dreamleague 720p  = with both url and stream choice launches video player directly
  7. :: streamlink dreamleague+chat            = with +chat added to the url also opens twitch chat in browser tab  
  8. :: streamlink --twitch-oauth-authenticate = with any python options shows cmd window and keeps it open
  9. :"Streamlink.Batch"
  10. rem set "TWITCH_OAUTH_TOKEN=--twitch-oauth-token YourTwitchOauthToken"
  11. set "CONFIG=--config streamlinkrc %TWITCH_OAUTH_TOKEN%"
  12. set "DEFAULT=--default-stream "720p,480p,best""
  13. set "RTMPDUMP=--rtmp-rtmpdump rtmpdump\rtmpdump.exe"
  14. set "PYTHONIOENCODING=cp65001" & chcp 65001 >NUL
  15. set "STREAMLINK=python\python.exe streamlink-script.py %FFMPEG% %RTMPDUMP% %CONFIG%"
  16. set "URL=%~1"
  17. set "STREAM=%~2"
  18. if not defined URL echo  Input empty, insert url & call :input "STREAMLINK: Insert url" "OK" URL
  19. if not defined URL echo  [X] Input empty & timeout /t 4 & exit/b
  20. if /i "%URL:~0,2%"=="--" echo  Input contains options & call :showcmd cmd /k %STREAMLINK% %DEFAULT% %URL% & exit/b
  21. if "%URL: --=%"=="%URL%" ( echo  %URL% loading, wait.. ) else call :showcmd cmd /k %STREAMLINK% %DEFAULT% %URL% & exit/b
  22. for /f "tokens=1,2,3* delims= " %%U in ("%URL%") do set "INPUT.URL=%%~U" & set "INPUT.STREAM=%%~V" & set "INPUT.NONE=%%~W"
  23. if not defined STREAM if not defined INPUT.NONE if defined INPUT.STREAM set "URL=%INPUT.URL%" & set "STREAM=%INPUT.STREAM%"
  24. if "%URL:/=%"=="%URL%" echo  Input non-url, assume twitch.tv/%URL% & set "URL=http://twitch.tv/%URL%"
  25. if /i "%URL:~-5%"=="+chat" ( set "URL=%URL:~0,-5%" & set "OPEN_CHAT=1" ) else set "OPEN_CHAT="
  26. if defined OPEN_CHAT start %URL%/chat
  27. set "--QUERYONLY--=--player QUERYONLY ^| find.exe /i "Available streams" 2^>nul" & set "LIST="
  28. if not defined STREAM for /f "usebackq tokens=2* delims=:" %%Q in (`%STREAMLINK% "%URL%" %--QUERYONLY--%`) do set "LIST=%%Q"
  29. if defined LIST call set "LIST=%%LIST:(=,%%" &call set "LIST=%%LIST:)=%%" &call set "LIST=%%LIST: =%%"
  30. if defined LIST echo  Available streams: %LIST% & call :choice "%URL%" "%LIST%" STREAM
  31. if defined LIST if not defined STREAM set "STREAMLINK=echo  [X] No choice selected & rem"
  32. %STREAMLINK% --default-stream "%STREAM%,720p,480p,best" "%URL%"
  33. call set "TSTPATH=%%path:%~dp0=%%" & rem add Streamlink directory to current user environment without duplicating entries
  34. if "%TSTPATH%"=="%path%" ( reg add HKEY_CURRENT_USER\Environment /v PATH /t REG_SZ /f /d "%path%;%~dp0;" >nul 2>nul &setx OS %OS% )
  35. exit/b
  36. ::----------------------------------------------------------------------------------------------------------------------------------
  37. :"Streamlink.Utils"
  38. :input %1:title %2:button %3:output_variable                                      ||:example: call :input "Enter stream" "OK" result
  39. setlocal & call :_header "%~1" input
  40. set "input=%input%<div><input class='button edit' name='in' type='text'><button id='ok' class='button ok'>%~2</button></div></body>"
  41. for /f "usebackq tokens=* delims=" %%# in (`mshta "%input%"`) do set "input_var=%%#"
  42. endlocal & call set "%~3=%input_var%" & exit /b                                                    
  43. :choice %1:title %2:options %3:output_variable                                  ||:example: call :choice Choose "op1,op2,op3" result
  44. setlocal & call :_header "%~1" choice
  45. set "choice=%choice% <div id='buttons' class='content'/><input type='hidden' name='options' value='%~2'></body>"
  46. for /f "usebackq tokens=* delims=" %%# in (`mshta "%choice%"`) do set "choice_var=%%#"
  47. endlocal & call set "%~3=%choice_var%" & exit /b                                                    
  48. :_header %1:title %2:type["input" or "choice"]                                    ||:i used internally by input and choice functions
  49. setlocal & set "h=about:<title>%~1</title><head><hta:application innerborder='no' sysmenu='yes' scroll='no'><style>body {"
  50. set "h=%h% background-color:#17141F;} .button {background-color:#7D5BBE;border:0.1em solid #392E5C;color:white;padding:0.1em 0.1em;"
  51. set "h=%h% text-align:center;text-decoration:none;display:inline-block;font-size:1em;cursor:pointer;width:99%%;display:block;}"
  52. if "%~2"=="input" set "h=%h% .ok {margin:0 0.1em;padding:0 0;width:18%%;display:inline-block}"
  53. set "h=%h% .edit {background-color:#392E5C;width:80%%;display:inline-block}</style></head>"
  54. set "h=%h% <body onload='%~2()'><script language='javascript' src='file://%~f0'></script>"
  55. endlocal & set "%~2=%h%" & exit /b                                                    
  56. :hidecmd %*:arguments
  57. setlocal & set "--arguments--=%*" & wscript //nologo /E:JScript "%~f0" RunCMD --arguments-- 0 & endlocal & exit/b
  58. :showcmd %*:arguments
  59. setlocal & set "--arguments--=%*" & wscript //nologo /E:JScript "%~f0" RunCMD --arguments-- 1 & endlocal & exit/b
  60. ::----------------------------------------------------------------------------------------------------------------------------------
  61. :"Streamlink.Init" Hybrid initialization with HideCmd and arguments pass-trough after self-restart
  62. @echo off & pushd "%~dp0" & if "%1"=="--self--restart--" call :"Streamlink.Batch" "%--init--%" & exit/b  
  63. set "--init--=%*" & call :hidecmd "%~f0" --self--restart-- & exit/b  
  64. ::----------------------------------------------------------------------------------------------------------------------------------
  65. :"Streamlink.JScript" */
  66. function input(){
  67.   window.onerror = function(){ close(); }; var input = document.getElementById('in'), ok = document.getElementById('ok');
  68.   window.moveTo(parseInt(window.parent.screen.availWidth/3),parseInt(window.parent.screen.availHeight/6));window.resizeTo(512,128);
  69.   ok.onclick = function() { close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(input.value)); };  
  70. }
  71. function choice(){
  72.   window.onerror = function(){ close(); }; var opt=document.getElementById('options').value.split(','), wh=(opt.length+1)*64;  
  73.   window.moveTo(parseInt(window.parent.screen.availWidth/3),parseInt(window.parent.screen.availHeight/6));window.resizeTo(512,512);
  74.     var buttons = document.getElementById('buttons'); for (o in opt) {
  75.     var i = document.createElement('button'); i.setAttribute('className', 'button'); i.className='button';
  76.     i.onclick = function() { close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(this.value)); };
  77.     i.appendChild(document.createTextNode(opt[o])); buttons.appendChild(i); buttons.appendChild(document.createElement('br'));
  78.   }
  79. }
  80. function RunCMD(arguments, show) { WScript.CreateObject('WScript.Shell').Run('%'+ arguments +'%', show, 'False'); }
  81. if (typeof window != 'object' && WScript.Arguments(0)=='RunCMD') RunCMD(WScript.Arguments(1), WScript.Arguments(2));
  82. // end of hybrid batch script by AveYo
Add Comment
Please, Sign In to add comment