-
Notifications
You must be signed in to change notification settings - Fork 4
/
transferSettings.ps1
38 lines (32 loc) · 1.34 KB
/
transferSettings.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Path to the old ini config
$iniFilePath = "$env:appdata\obs-studio\global.ini"
try {
# try to get variables from obs global.ini file (old location)
$server_password = (Select-String -Path $iniFilePath -List -Pattern "(?<=ServerPassword=)\S+").Matches[0].Value
$server_port = (Select-String -Path $iniFilePath -List -Pattern "(?<=ServerPort=)\S+").Matches[0].Value
} catch {
Write-Output "No configuration data found at old location"
}
# Path to the new JSON file location
$jsonFilePath = "$env:appdata\obs-studio\plugin_config\obs-websocket\config.json"
# Check if the json file exists
if (Test-Path -Path $jsonFilePath) {
try {
# Read the file
$jsonContent = Get-Content -Path $jsonFilePath -Raw | ConvertFrom-Json
$server_port = $jsonContent.server_port
$server_password = $jsonContent.server_password
Write-Output "Read data from new location"
} catch {
Write-Output "Error reading from new json file"
}
}
# print out variables
Write-Host $server_password
Write-Host $server_port
$destinationFile = "OBSliveTally.html"
# replace text in html with new values
$controller = Get-Content -Path $destinationFile
$controller = $controller -creplace "YourPasswordHERE", $server_password
$controller = $controller -creplace "4455", $server_port
$controller | Set-Content -Path $destinationFile