|
// Detect Browser |
|
function getBrowserInfo() { |
|
const userAgent = navigator.userAgent; |
|
let browserName = "Unknown"; |
|
|
|
if (userAgent.indexOf("Firefox") > -1) { |
|
browserName = "Mozilla Firefox"; |
|
} else if (userAgent.indexOf("Chrome") > -1) { |
|
browserName = "Google Chrome"; |
|
} else if (userAgent.indexOf("Safari") > -1) { |
|
browserName = "Apple Safari"; |
|
} else if (userAgent.indexOf("MSIE") > -1 || !!document.documentMode) { |
|
browserName = "Internet Explorer"; |
|
} |
|
|
|
return browserName; |
|
} |
|
|
|
// Detect OS |
|
function getOSInfo() { |
|
const userAgent = navigator.userAgent; |
|
let osName = "Unknown"; |
|
|
|
if (userAgent.indexOf("Win") > -1) { |
|
osName = "Windows"; |
|
} else if (userAgent.indexOf("Mac") > -1) { |
|
osName = "MacOS"; |
|
} else if (userAgent.indexOf("X11") > -1) { |
|
osName = "UNIX"; |
|
} else if (userAgent.indexOf("Linux") > -1) { |
|
osName = "Linux"; |
|
} |
|
|
|
return osName; |
|
} |
|
|
|
// Check if Streamlink is installed |
|
function isStreamlinkInstalled() { |
|
// This is a placeholder function. Actual implementation may vary. |
|
// Streamlink is a command-line tool, so checking its installation from a browser is not straightforward. |
|
// You might need to use a server-side script to check this. |
|
return false; |
|
} |
|
|
|
// Get Twitch URL and Auth Code |
|
function getTwitchInfo() { |
|
const twitchURL = prompt("Enter the Twitch URL:"); |
|
const authCode = prompt("Enter the Auth Code:"); |
|
|
|
return { twitchURL, authCode }; |
|
} |
|
|
|
// Pass information to Streamlink to record the stream |
|
function recordStream(twitchURL, authCode) { |
|
if (!isStreamlinkInstalled()) { |
|
alert("Streamlink is not installed."); |
|
return; |
|
} |
|
|
|
const command = `streamlink --twitch-api-header=Authorization=OAuth ${authCode} ${twitchURL} best`; |
|
console.log("Run the following command in your terminal to record the stream:"); |
|
console.log(command); |
|
} |
|
|
|
// Main function |
|
function main() { |
|
const browserInfo = getBrowserInfo(); |
|
const osInfo = getOSInfo(); |
|
const { twitchURL, authCode } = getTwitchInfo(); |
|
|
|
console.log(`Browser: ${browserInfo}`); |
|
console.log(`OS: ${osInfo}`); |
|
console.log(`Twitch URL: ${twitchURL}`); |
|
console.log(`Auth Code: ${authCode}`); |
|
|
|
recordStream(twitchURL, authCode); |
|
} |
|
|
|
// Run the main function |
|
main(); |