Created
October 11, 2022 08:50
-
-
Save PakL/274bc3b58c7cbb4a1261b7f8513f3002 to your computer and use it in GitHub Desktop.
Stream Deck OBS Button downgrade from 5.3 to 5.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mainProfileFolder = getenv('APPDATA') . DIRECTORY_SEPARATOR . 'Elgato' . DIRECTORY_SEPARATOR . 'StreamDeck' . DIRECTORY_SEPARATOR . 'ProfilesV2'; | |
//$mainProfileFolder = __DIR__; | |
function downgradeOBS($action) { | |
if($action['UUID'] === 'com.elgato.obsstudio.scene') { | |
$action['UUID'] = 'com.elgato.streamdeck.obs.scene'; | |
if(!isset($action['Settings']['sceneId']) && isset($action['Settings']['scene'])) { | |
$action['Settings']['sceneId'] = $action['Settings']['scene']; | |
} | |
} else if(substr($action['UUID'], 0, 21) === 'com.elgato.obsstudio.') { | |
$action['UUID'] = 'com.elgato.streamdeck.obs.' . substr($action['UUID'], 21); | |
} | |
return $action; | |
} | |
function downgradeManifest($manifestPath) { | |
print $manifestPath . PHP_EOL; | |
$manifest = json_decode(file_get_contents($manifestPath), true); | |
foreach($manifest['Actions'] as $button => $action) { | |
if(substr($action['UUID'], 0, 21) == 'com.elgato.obsstudio.') { | |
$manifest['Actions'][$button] = downgradeOBS($action); | |
} else if(isset($action['Settings'])) { | |
if(isset($action['Settings']['Routine'])) { | |
foreach($action['Settings']['Routine'] as $i => $act) { | |
$manifest['Actions'][$button]['Settings']['Routine'][$i] = downgradeOBS($act); | |
} | |
} | |
if(isset($action['Settings']['RoutineAlt'])) { | |
foreach($action['Settings']['RoutineAlt'] as $i => $act) { | |
$manifest['Actions'][$button]['Settings']['RoutineAlt'][$i] = downgradeOBS($act); | |
} | |
} | |
} | |
} | |
rename($manifestPath, $manifestPath . '.bak'); | |
file_put_contents($manifestPath, json_encode($manifest)); | |
} | |
$profiles = scandir($mainProfileFolder); | |
foreach($profiles as $profile) { | |
if(!in_array($profile, ['.','..']) && is_dir($mainProfileFolder . DIRECTORY_SEPARATOR . $profile)) { | |
$profilePath = $mainProfileFolder . DIRECTORY_SEPARATOR . $profile . DIRECTORY_SEPARATOR; | |
if(file_exists($profilePath . 'manifest.json')) { | |
downgradeManifest($profilePath . 'manifest.json'); | |
if(file_exists($profilePath . 'Profiles')) { | |
$subprofiles = scandir($profilePath . 'Profiles'); | |
foreach($subprofiles as $subprofile) { | |
if(!in_array($subprofile, ['.','..']) && is_dir($profilePath . 'Profiles' . DIRECTORY_SEPARATOR . $profile)) { | |
$subprofilePath = $profilePath . 'Profiles' . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR; | |
if(file_exists($subprofilePath . 'manifest.json')) { | |
downgradeManifest($subprofilePath . 'manifest.json'); | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment