Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://pastebin.com/eGSUFbcs | https://forum.xentax.com/viewtopic.php?p=140570#p140570
- ####################################################################################################
- # <><><><><><><><><> [READ ME] Tom Clancy's Rainbow Six Siege - Audio Extractor <><><><><><><><><> #
- # #
- # #
- # The Tom Clancy's Rainbow Six Siege - Audio Extractor will download multiple resources in order #
- # to extract, convert and sort most of the audio files from the Ubisoft game Tom Clancy's Rainbow #
- # Six Siege. #
- # #
- # Be aware that the entire process may take several hours. For information on how to increase #
- # performance, check the documentation (see below). #
- # #
- # #
- # Note that from now on sorting is no longer directly possible as the proper names have been #
- # removed from the end of the '.bnk' files when the audio source files were changed and is now #
- # done based on file names and OasisIDs from old source files. #
- # #
- # Additionally all the '.lwav' files have been altered in a way that they are now extracted as #
- # '.wav_unknown' files and cannot be converted at the moment. #
- # #
- # #
- # Disclaimer: #
- # #
- # I did not write any of the programs or scripts that are needed for extraction and conversion. #
- # All credits belong to their authors, you may check out the links to the forum entries and #
- # websites below. #
- # #
- # QuickBMS #
- # http://aluigi.altervista.org/quickbms.htm #
- # #
- # pck_AKPK_extractor.bms #
- # http://forum.xentax.com/viewtopic.php?p=80192#p80192 #
- # #
- # func_getTYPE.bms #
- # http://forum.xentax.com/viewtopic.php?f=13&p=69577#p69577 #
- # #
- # bnk_extractor.bms #
- # http://forum.xentax.com/viewtopic.php?f=13&t=4450&p=89662#p89662 #
- # #
- # ww2ogg (includes packed_codebooks_aoTuV_603.bin) #
- # https://www.hcs64.com/vgm_ripping.html #
- # https://github.com/hcs64/ww2ogg #
- # #
- # revorb #
- # https://hydrogenaud.io/index.php/topic,64328.msg574110.html#msg574110 #
- # #
- # wwise_ima_adpcm (sound_conveter_v1.15.zip) #
- # https://bitbucket.org/zabb65/payday-2-modding-information/downloads #
- # #
- # wwise_pcm_decoder.bms #
- # http://forum.xentax.com/viewtopic.php?p=110795#p110795 #
- # #
- # #
- # Documentation: #
- # #
- # XeNTaX post #
- # http://forum.xentax.com/viewtopic.php?p=140570#p140570 #
- # #
- # Name overview #
- # https://goo.gl/PxQuCTv #
- # #
- # #
- # Feel free to contact me if you have any suggestions or feedback, as well as bugs or similar. #
- # You can do that by replying in the XeNTaX thread (see above) or emailing me (see below). #
- # #
- # #
- # <><><><><><><><><><><><><><><> Contact: FatalBulletHit@gmail.com <><><><><><><><><><><><><><><> #
- ####################################################################################################
- # Variables below may be altered by the user if desired or needed (check the documentation for more information).
- # Tom Clancy's Rainbow Six Siege installation directory (if the script cannot find it, uncomment the line below and adjust the path if needed)
- # $dirSource = "C:\Program Files (x86)\Steam\steamapps\common\Tom Clancy's Rainbow Six Siege"
- # Output directory (feel free to adjust the path)
- $dirOutput = '{0}\output' -f $PSScriptRoot
- # Remove '.wav_unknown' files when removing redundant files (don't know how to convert '.wav_unknown' (previously '.lwav'), 'wwise_ima_adpcm.exe' just produces nonsense)
- $wav_unknownRedundant = 1
- # Remove redundant files ('.00040000', '.01020000', '.wav' (before conversion) and '.wav_unknown' (if the option above is enabled))
- $removeRedundant = 1
- # Remove duplicate files (recommended as it decreases conversion duration and saves drive space)
- $removeDuplicates = 1
- # Remove all extracted files after conversion
- $removeSource = 1
- # Remove all empty directories after conversion
- $removeEmptyDir = 1
- # When moving '.Wwise' files, use ranges for OasisIDs where possible rather than certain matches
- $greedyOasisTable = 1
- # Creates a log file
- $createLog = 1
- ####################################################################################################
- # <><><><><><><><><><><><><><><><><><><><> INITIALIZATION <><><><><><><><><><><><><><><><><><><><> #
- $Version = '0.9.3'
- $OverallStart = (Get-Date)
- $ErrorActionPreference = 'Continue'
- $Global:ProgressPreference = 'SilentlyContinue'
- $RawUI = $Host.UI.RawUI
- $RawUI.WindowTitle = "Tom Clancy's Rainbow Six Siege - Audio Extractor"
- $RawUI.BackgroundColor = 'Black'
- $RawUI.ForegroundColor = 'Cyan'
- Clear-Host
- $Connection = (Test-Connection -Computer 'google.com' -Count 1 -Quiet)
- $bnkTable = New-Object System.Collections.Hashtable
- $contentTable = New-Object System.Collections.Hashtable
- $dupTable = New-Object System.Collections.Hashtable
- $nameTable_bnk = New-Object System.Collections.Hashtable
- $nameTable_pck = New-Object System.Collections.Hashtable
- $oasisTable = New-Object System.Collections.Hashtable
- $oasisTable_ext = New-Object System.Collections.Hashtable
- function Animate-Dot {
- Param (
- [Parameter(ValueFromPipeline=$true)]
- [int]$Stop
- )
- if (!$Stop) {
- Write-Host ' ' -NoNewline
- if ($createLog) {
- '... ' | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -NoNewline
- }
- return (Start-Process PowerShell {
- $ParentProcessID = (Get-WmiObject -Class win32_process | Where-Object {$_.ProcessID -eq $PID}).ParentProcessID
- while ((Get-Process -Id $ParentProcessID 2>$null) -ne $null) {
- for ($i = 0; $i -lt 4; $i++) {
- Write-Host ("""`b`b`b`b{0,-4}""" -f ('.' * $i)) -NoNewline
- Start-Sleep -Milliseconds 250
- }
- }
- } -NoNewWindow -PassThru).Id
- } else {
- Stop-Process -Id $Stop
- Write-Host "`b`b`b`b... " -NoNewline
- Write-Host -ForegroundColor Green ('Done!').ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- Write-Host (' | {0:h\:mm\:ss}' -f ((Get-Date) - $Start)).ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- }
- }
- function Stop-ChildOnExit {
- Param (
- [Parameter(ValueFromPipeline=$true)]
- [int]$monitorPID
- )
- $env:monitorPID = $monitorPID
- Start-Process PowerShell {
- while ((Get-Process -Id $env:monitorPID 2>$null) -ne $null) {
- if ((Get-Process -Id (Get-WmiObject -Class win32_process | Where-Object {$_.ProcessID -eq $PID}).ParentProcessID 2>$null) -eq $null) {
- Stop-Process -Id $env:monitorPID 2>$null
- } else {
- Start-Sleep -Milliseconds 100
- }
- }
- } -WindowStyle Hidden
- Wait-Process -Id $monitorPID
- }
- if (Test-Path -LiteralPath $env:TEMP\tc_r6s_audio_extractor_started.tmp) {
- Remove-Item -LiteralPath $env:TEMP\tc_r6s_audio_extractor_started.tmp -ErrorAction SilentlyContinue
- }
- New-Item -Path $env:TEMP\tc_r6s_audio_extractor_started.tmp -ItemType File >$null
- if ($RawUI.BufferSize.Width -lt 150) {
- [System.Console]::SetBufferSize(150, $RawUI.BufferSize.Height)
- }
- if ($RawUI.MaxPhysicalWindowSize.Width -ge 150) {
- [System.Console]::SetWindowSize(150, $RawUI.WindowSize.Height)
- [System.Console]::SetBufferSize(150, $RawUI.BufferSize.Height)
- }
- if ($RawUI.MaxPhysicalWindowSize.Height -ge 40) {
- [System.Console]::SetWindowSize($RawUI.WindowSize.Width, 40)
- }
- if (Test-Path -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt) {
- Remove-Item -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -ErrorAction SilentlyContinue
- }
- # Installing
- if ((Get-Content -LiteralPath $PSCommandPath -Tail 1).Length -eq 99 -or $PSScriptRoot -eq (Get-Item -LiteralPath $env:TEMP).FullName) {
- # Default directory
- $parentPID = (Get-WmiObject -Class win32_process | Where-Object {$_.ProcessID -eq $PID}).ParentProcessId
- if (($parentPath = (Get-WmiObject -Class win32_process | Where-Object {$_.ProcessID -eq $parentPID}).CommandLine.Split('"') | ? {$_ -match '\.bat'}).Count -gt 0 -and (Test-Path -LiteralPath $parentPath) -and ($parentItem = (Get-Item -LiteralPath $parentPath)).FullName.Substring(0,$env:TEMP.Length) -ne $env:TEMP) {
- $dirSelect = $parentItem.DirectoryName
- $toggleSwitch = $false
- } else {
- $dirSelect = '{0}\Desktop' -f $Home
- $toggleSwitch = $true
- }
- $dirSelectSub = '\tc_r6s_audio_extractor'
- # Description for FolderBrowserDialog
- $description = 'Select the directory to move and download all the required and related files in:'
- Add-Type -AssemblyName System.Windows.Forms
- $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{Description = $description}
- $CursorPositionY = $RawUI.CursorPosition.Y + 2
- Write-Host (' Destination directory for all required and related files:').ForEach({if ($createLog) {("{0}`n" -f $_) | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt; $_} else {$_}})
- if ($toggleSwitch) {
- Write-Host -ForegroundColor Magenta ("`n`t {0}{1}`n" -f $dirSelect, $dirSelectSub)
- } else {
- Write-Host -ForegroundColor Magenta ("`n`t {0}`n" -f $dirSelect)
- }
- Write-Host ' [B]rowse / [C]onfirm / ' -NoNewline
- if ($toggleSwitch) {
- Write-Host -ForegroundColor Yellow '[T]oggle pre-defined directory' -NoNewline
- } else {
- Write-Host '[T]oggle pre-defined directory' -NoNewline
- }
- while (($tempKey = [string]([System.Console]::ReadKey('NoEcho')).Key) -ne 'C') {
- if ($tempKey -eq 'T') {
- [System.Console]::SetCursorPosition(0, $CursorPositionY)
- if (($toggleSwitch = !$toggleSwitch)) {
- Write-Host -ForegroundColor Magenta ("{0}`r`t {1}{2}`n" -f (' ' * $RawUI.BufferSize.Width), $dirSelect, $dirSelectSub).Replace('\\','\')
- } else {
- Write-Host -ForegroundColor Magenta ("{0}`r`t {1}`n" -f (' ' * $RawUI.BufferSize.Width), $dirSelect).Replace('\\','\')
- }
- } elseif ($tempKey -eq 'B') {
- Write-Host -ForegroundColor Yellow "`r [B]rowse " -NoNewline
- Write-Host '/ [C]onfirm' -NoNewline
- [void]$FolderBrowser.ShowDialog()
- [System.Console]::SetCursorPosition(0, $CursorPositionY)
- if ([string]$FolderBrowser.SelectedPath -ne $null -and (Test-Path -LiteralPath $FolderBrowser.SelectedPath)) {
- $dirSelect = $FolderBrowser.SelectedPath
- }
- Write-Host -ForegroundColor Magenta ("{0}`r`t {1}{2}`n" -f (' ' * $RawUI.BufferSize.Width), $dirSelect, $dirSelectSub).Replace('\\','\')
- Write-Host ' [B]rowse / [C]onfirm' -NoNewline
- }
- [System.Console]::SetCursorPosition(24, $CursorPositionY + 2)
- if ($toggleSwitch) {
- Write-Host -ForegroundColor Yellow '[T]oggle pre-defined directory' -NoNewline
- } else {
- Write-Host '[T]oggle pre-defined directory' -NoNewline
- }
- }
- $env:dirExtractor = $dirExtractor = $dirSelect
- if ($toggleSwitch) {
- $env:dirExtractor = $dirExtractor = ('{0}{1}' -f $dirSelect, $dirSelectSub).Replace('\\','\')
- }
- Write-Host "`r [B]rowse /" -NoNewline
- Write-Host -ForegroundColor Yellow ' [C]onfirm'
- if ($createLog) {
- ("`t{0}" -f $dirExtractor) | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt
- }
- if (!(Test-Path -LiteralPath $dirExtractor)) {
- New-Item -Path $dirExtractor -ItemType Directory >$null
- } else {
- if (Test-Path -LiteralPath ('{0}\tc_r6s_audio_extractor.ps1' -f $dirExtractor)) {
- if (($tempMatch = [regex]::Matches((Get-Content -LiteralPath ('{0}\tc_r6s_audio_extractor.ps1' -f $dirExtractor)), '\$Version = ({0}|")([0-9]+\.[0-9]+\.?[0-9]*)({0}|")' -f [char]39)).Count -gt 0 -and $tempMatch.Groups[2].Value -ne $Version) {
- Rename-Item -LiteralPath ('{0}\tc_r6s_audio_extractor.ps1' -f $dirExtractor) -NewName ('tc_r6s_audio_extractor_old_{0}.ps1' -f $tempMatch.Groups[2].Value)
- } else {
- Rename-Item -LiteralPath ('{0}\tc_r6s_audio_extractor.ps1' -f $dirExtractor) -NewName 'tc_r6s_audio_extractor_old.ps1'
- }
- }
- }
- if ((Test-Path -LiteralPath $parentPath) -and ('{0}\{1}' -f $dirExtractor, $parentItem.Name) -ne $parentItem.FullName) {
- if (Test-Path -LiteralPath ('{0}\{1}' -f $dirExtractor, $parentItem.Name)) {
- Rename-Item -LiteralPath $parentItem.FullName -NewName ('{0}\{1}_old.bat' -f $parentItem.DirectoryName, $parentItem.BaseName)
- }
- Move-Item -LiteralPath $parentItem.FullName -Destination $dirExtractor -Force
- } elseif ($Connection -and !(Test-Path -LiteralPath ('{0}\Launcher.bat' -f $dirExtractor))) {
- (Invoke-WebRequest -Uri 'https://pastebin.com/raw/iC6YuYPj' -UseBasicParsing).Content | Out-File -LiteralPath ('{0}\Launcher.bat' -f $dirExtractor) -Encoding 'UTF8'
- }
- Move-Item -LiteralPath $PSCommandPath -Destination $dirExtractor -Force
- if ($dirOutput -eq ('{0}\output' -f (Get-Item -LiteralPath $env:TEMP).FullName)) {
- $dirOutput = ('{0}\output' -f $dirExtractor)
- }
- '#' | Add-Content -LiteralPath ('{0}\tc_r6s_audio_extractor.ps1' -f $dirExtractor) -NoNewline
- Set-Location -LiteralPath $dirExtractor
- Write-Host -ForegroundColor Green ("`n Installation successful!`n").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt} else {$_}})
- Write-Host ' [C]ontinue with default preferences / [E]xit' -NoNewline
- while (!('C', 'E').Contains(($tempKey = [string]([System.Console]::ReadKey('NoEcho')).Key))) {}
- if ($tempKey -eq 'E') {
- Write-Host -ForegroundColor Yellow "`b`b`b`b`b`b[E]xit`n"
- Write-Host ('Exiting!').ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt} else {$_}})
- Start-Sleep 3
- exit
- }
- Write-Host -ForegroundColor Yellow "`r [C]ontinue with default preferences`n "
- Write-Host ('Continuing!').ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt} else {$_}})
- Start-Sleep 3
- Clear-Host
- } else {
- $env:dirExtractor = $dirExtractor = $PSScriptRoot
- }
- # Moving error log if any
- Start-Process PowerShell {
- $ParentProcessID = (Get-WmiObject -Class win32_process | Where-Object {$_.ProcessID -eq $PID}).ParentProcessID
- do {
- Start-Sleep -Milliseconds 250
- if (Test-Path -LiteralPath $env:TEMP\tc_r6s_audio_extractor_error.txt) {
- if ((Get-Item -LiteralPath $env:TEMP\tc_r6s_audio_extractor_error.txt).Length -gt 0) {
- Stop-Process -Id $ParentProcessID
- New-Item -Path ('{0}\error_logs' -f $env:dirExtractor) -ItemType Directory -ErrorAction SilentlyContinue >$null
- Move-Item -LiteralPath $env:TEMP\tc_r6s_audio_extractor_error.txt -Destination ('{0}\error_logs\tc_r6s_audio_extractor_error_{1}.txt' -f $env:dirExtractor, (Get-Date).ToString('yymmddhhmmss'))
- Start-Process PowerShell {
- $Host.UI.RawUI.WindowTitle = 'Tom Clancy{0}s Rainbow Six Siege - Audio Extractor' -f ([char]39)
- $Host.UI.RawUI.BackgroundColor = 'Black'
- $Host.UI.RawUI.ForegroundColor = 'Cyan'
- Clear-Host
- Write-Host -ForegroundColor Yellow (' WARNING: An error occurred during script execution! The log has been moved to').ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- Write-Host -ForegroundColor Magenta (' {0}\error_logs' -f $env:dirExtractor).ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- Read-Host
- exit
- }
- } else {
- Remove-Item -LiteralPath $env:TEMP\tc_r6s_audio_extractor_error.txt
- }
- }
- } until ((Get-Process -Id $ParentProcessID 2>$null) -eq $null)
- if (Test-Path -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt) {
- New-Item -Path ('{0}\logs' -f $env:dirExtractor) -ItemType Directory -ErrorAction SilentlyContinue >$null
- Move-Item -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -Destination ('{0}\logs\tc_r6s_audio_extractor_log_{1}.txt' -f $env:dirExtractor, (Get-Date).ToString('yymmddhhmmss'))
- }
- Start-Sleep 5
- exit
- } -WindowStyle Hidden
- # Testing connection
- if (!$Connection) {
- Write-Host -ForegroundColor Yellow ("`n WARNING: Cannot establish internet connection!").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- } else {
- if (($AvailableVersion = (Invoke-WebRequest -Uri 'https://pastebin.com/raw/XBQPYqnz' -UseBasicParsing).Content) -ne $Version) {
- Write-Host -ForegroundColor Yellow ("`n Current version: {0} | Latest version: {1}" -f $Version, $AvailableVersion).ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- Write-Host ("`n Downloading latest version!").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- Rename-Item -LiteralPath $PSCommandPath -NewName ('{0}_old_{1}.ps1' -f (Get-Item -LiteralPath $PSCommandPath).BaseName, $Version)
- ('{0}#' -f (Invoke-WebRequest -Uri 'https://pastebin.com/raw/eGSUFbcs' -UseBasicParsing).Content) | Out-File -LiteralPath $PSCommandPath -Encoding UTF8 -NoNewline
- Write-Host ("`n Please restart manually!").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}}) -NoNewline
- Read-Host
- exit
- } else {
- Write-Host -ForegroundColor Green ("`n Current version: {0} | Latest version: {1}" -f $Version, $AvailableVersion).ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- }
- }
- # Searching for missing resources
- New-Item -Path '.\resources\aliasTables', '.\resources\applications', '.\resources\scripts', '.\resources\archives' -ItemType Directory -ErrorAction SilentlyContinue >$null
- Write-Host ("`n Searching for missing and outdated resources").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- $Start = (Get-Date)
- $animatePID = Animate-Dot
- if ((Get-ChildItem '.\resources\aliasTables' -File).Count -gt 0) {
- (Invoke-WebRequest -Uri 'https://pastebin.com/raw/zCreUdGp' -UseBasicParsing).Content | ForEach-Object {
- if (!(Test-Path ('.\resources\aliasTables\{0}' -f $_.Split(';')[0])) -or ($tempLine = (Get-Content ('.\resources\aliasTables\{0}' -f $_.Split(';')[0]) -TotalCount 1)).Substring(0,1) -ne '#' -or $tempLine.Substring(2,3) -ne $_.Split(';')[1].Substring(0,3)) {
- $outdatedAlias += ,('.\resources\aliasTables\{0}' -f $_.Split(';')[0])
- }
- }
- }
- (('.\resources\applications\quickbms.exe', '.\resources\archives\quickbms.zip'), ('https://drive.google.com/uc?export=download&id=1qfUHube-SnZJV3P5Iej62b6DbxnOogv1', 'http://aluigi.altervista.org/papers/quickbms.zip')), (('.\resources\applications\ww2ogg.exe', '.\resources\archives\ww2ogg024.zip'), ('https://drive.google.com/uc?export=download&id=1urVxXt3cKykCj7G2Wm4IYJuPLP_QoUZc', 'https://www.hcs64.com/files/ww2ogg024.zip')), (('.\resources\applications\packed_codebooks_aoTuV_603.bin', '.\resources\archives\ww2ogg024.zip'), ('https://drive.google.com/uc?export=download&id=1Tebo2-rDlnf58oXQgCDTPD3g_W-kSTML', 'https://www.hcs64.com/files/ww2ogg024.zip')), ('.\resources\applications\revorb.exe', ('https://drive.google.com/uc?export=download&id=1M4a7Zknk_d02vD-LopOmoqWZWOcdlS05', 'http://yirkha.fud.cz/progs/foobar2000/revorb.exe')), (('.\resources\applications\wwise_ima_adpcm.exe', '.\resources\archives\sound_conveter_v1.15.zip'), ('https://drive.google.com/uc?export=download&id=1Hr7r7RVKLU6iJVpZZpBSTO97NXXq1S9J', 'https://bitbucket.org/zabb65/payday-2-modding-information/downloads/sound_conveter_v1.15.zip')), ('.\resources\scripts\bnk_extractor.bms', ('https://drive.google.com/uc?export=download&id=1qsqo9EHi9mgQ_ytu4o35wr1puHJ74le6', 'https://pastebin.com/raw/LXUa1Mri')), ('.\resources\scripts\func_getTYPE.bms', ('https://drive.google.com/uc?export=download&id=1HrPJjBwk1gDmfHWwlLUHp5GsVEYfMMXV', 'https://pastebin.com/raw/puz9zQ6f')), ('.\resources\scripts\pck_AKPK_extractor.bms', ('https://drive.google.com/uc?export=download&id=1SrIqUn6ba_VlB3LTQp9HuL8fDo3U5PH2', 'https://pastebin.com/raw/n6BccWjA')), ('.\resources\scripts\wwise_pcm_decoder.bms', ('https://drive.google.com/uc?export=download&id=1ciksiKfhPkAeckJcqN8yXjRqy8yuyVxw', 'https://pastebin.com/raw/qB4JWNeV')), ('.\resources\aliasTables\r6s_extractor_bnkTable.txt', 'https://pastebin.com/raw/34ekBA6T'), ('.\resources\aliasTables\r6s_extractor_nameTable_bnk.txt', 'https://drive.google.com/uc?export=download&id=13Ey2tjLY92j7g-RUXs0m92a5ndQZNl0V'), ('.\resources\aliasTables\r6s_extractor_nameTable_pck.txt', 'https://drive.google.com/uc?export=download&id=12wyuUCtqYnUUHeS8UER7L5bIt8Xxu9VX'), ('.\resources\aliasTables\r6s_extractor_oasisTable_greedy.txt', 'https://pastebin.com/raw/CGrY3PWX'), ('.\resources\aliasTables\r6s_extractor_oasisTable_exact.txt', 'https://pastebin.com/raw/Yi5SeynY') | ForEach-Object {
- if ($_[0] -is [array]) {
- if (!(Test-Path $_[0][0])) {
- if (!(Test-Path $_[0][1])) {
- if ($Connection) {
- Invoke-WebRequest -Uri $_[1][1] -OutFile $_[0][1] -UseBasicParsing
- $Downloading = $true
- } else {
- $Missing += "`n`t'{0}'" -f ($_[0][0]).Split('\')[3]
- }
- }
- if (Test-Path $_[0][1]) {
- New-Item -Path '.\resources\archives\temp' -ItemType Directory -ErrorAction SilentlyContinue >$null
- Expand-Archive $_[0][1] -DestinationPath '.\resources\archives\temp'
- Move-Item ('.\resources\archives\temp\{0}' -f ($_[0][0]).Split('\')[3]) -Destination '.\resources\applications'
- Remove-Item '.\resources\archives\temp' -Recurse
- } elseif ($Connection) {
- Invoke-WebRequest -Uri $_[1][0] -OutFile $_[0][0] -UseBasicParsing
- }
- if (!(Test-Path $_[0][0]) -and $Downloading) {
- $Missing += "`n`t'{0}'" -f ($_[0][0]).Split('\')[3]
- }
- }
- } else {
- if (!(Test-Path $_[0]) -or ($outdatedAlias.Count -gt 0 -and $outdatedAlias.Contains($_[0]))) {
- if ($Connection) {
- if ($_[1] -is [array]) {
- Invoke-WebRequest -Uri $_[1][1] -OutFile $_[0] -UseBasicParsing
- if (Test-Path $_[0]) {
- Invoke-WebRequest -Uri $_[1][0] -OutFile $_[0] -UseBasicParsing
- }
- } else {
- Invoke-WebRequest -Uri $_[1] -OutFile $_[0] -UseBasicParsing
- }
- if (!(Test-Path $_[0])) {
- $Missing += "`n`t'{0}'" -f ($_[0]).Split('\')[3]
- }
- } elseif ($_[0] -notmatch 'alias') {
- $Missing += "`n`t'{0}'" -f ($_[0]).Split('\')[3]
- }
- }
- }
- Clear-Variable -Name 'Downloading' -ErrorAction SilentlyContinue
- }
- $animatePID | Animate-Dot
- if ($Missing.Length -gt 0) {
- Write-Host ("`n ERROR: Missing the following resources:`n").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}}) -ForegroundColor Red
- Write-Host $Missing.ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}}) -ForegroundColor Red
- Write-Host ("`n Download manually or try again.").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}}) -ForegroundColor Magenta
- Write-Host ("`n Terminating!").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}}) -ForegroundColor Red
- Start-Sleep 5
- exit
- }
- # Checking for installation directory
- if ($dirSource -eq $null -or !(Test-Path -LiteralPath $dirSource)) {
- if ((Test-Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Ubisoft\Launcher\Installs\635') -and (Test-Path -LiteralPath ($tempPath = (Get-ItemProperty 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Ubisoft\Launcher\Installs\635').InstallDir.Replace('/', '\')))) {
- $dirSource = $tempPath.TrimEnd('\')
- } else {
- Write-Host ("`n ERROR: Cannot find Tom Clancy's Rainbow Six Siege installation directory, define manually in script!`n`n Terminating!").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}}) -ForegroundColor Red
- Start-Sleep 5
- exit
- }
- }
- if (Test-Path -LiteralPath ('{0}\sounddata\pc' -f $dirSource)) {
- $dirSource += '\sounddata\pc'
- }
- # Checking for source files
- if (($pckCount = (Get-ChildItem -LiteralPath $dirSource -Recurse -File -Filter *.pck).Count) -eq 0) {
- Write-Host ("`n ERROR: Cannot find any source files, define manually in script!`n`n Terminating!").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}}) -ForegroundColor Red
- Start-Sleep 5
- exit
- } else {
- Write-Host ("`n Found {0} '.pck' files at " -f $pckCount).ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- Write-Host -ForegroundColor Magenta $dirSource.ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- }
- # Checking for output directory
- if (!(Test-Path -LiteralPath $dirOutput)) {
- New-Item -Path $dirOutput -ItemType 'Directory' -ErrorAction SilentlyContinue >$null
- Write-Host -ForegroundColor Green ("`n Created output directory at ").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- Write-Host -ForegroundColor Magenta $dirOutput.ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- } else {
- Write-Host -ForegroundColor Green ("`n Output directory located at ").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- Write-Host -ForegroundColor Magenta $dirOutput.ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- }
- # <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> #
- ####################################################################################################
- ####################################################################################################
- # <><><><><><><><><><><><><><><><><><><><><> EXTRACTION <><><><><><><><><><><><><><><><><><><><><> #
- # .pck
- Write-Host ("`n Extracting '.pck' files").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- $Start = (Get-Date)
- $animatePID = Animate-Dot
- # Extracting .pck
- (Start-Process .\resources\applications\quickbms.exe -ArgumentList ('-F *.pck -K -D -Y -. -Q -R .\resources\scripts\pck_AKPK_extractor.bms "{0}" "{1}"' -f $dirSource, $dirOutput) -WindowStyle Hidden -PassThru).Id | Stop-ChildOnExit
- $animatePID | Animate-Dot
- # .bnk
- Write-Host (" Extracting '.bnk' files").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- $Start = (Get-Date)
- $animatePID = Animate-Dot
- # Populating $bnkTable
- Get-Content .\resources\aliasTables\r6s_extractor_bnkTable.txt | Select-Object -Skip 1 | ForEach-Object {
- $bnkTable.Add($_.Split(';')[0].Split(','), (($_.Split(';') | Select-Object -Skip 1) -join ';'))
- }
- # Extracting .bnk
- Get-ChildItem $dirOutput -File -Recurse -Filter *.bnk | ForEach-Object {
- $fileName = $_.BaseName
- if (($alias = ($bnkTable.GetEnumerator() | Where-Object {$_.Name.Contains($fileName.Substring(2))} | Select-Object -First 1).Value) -ne $null) {
- if ($alias.Contains(';')) {
- $dirPath = $_.DirectoryName
- $alias = ($alias.Split(';') | Where-Object {$dirPath -match $_.Split(',')[1]} | Select-Object -First 1 | ForEach-Object {$_.Split(',')[0]})
- }
- $bnkOut = '{0}\{1} ({2})' -f $_.DirectoryName, $alias, $_.BaseName
- } else {
- $bnkOut = '{0}\{1}' -f $_.DirectoryName, $_.BaseName
- }
- (Start-Process .\resources\applications\quickbms.exe -ArgumentList ('-K -D -Y -. -Q -R .\resources\scripts\bnk_extractor.bms "{0}" "{1}"' -f $_.FullName, $bnkOut) -WindowStyle Hidden -PassThru).Id | Stop-ChildOnExit
- Clear-Variable -Name 'fileName', 'bnkOut' 2>$null
- }
- $animatePID | Animate-Dot
- # <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> #
- ####################################################################################################
- ####################################################################################################
- # <><><><><><><><><><><> REMOVING REDUNDANT AND DUPLICATE FILES AND SORTING <><><><><><><><><><><> #
- # Removing redundant files
- if ($removeRedundant) {
- Write-Host (' Removing redundant files').ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- $Start = (Get-Date)
- $animatePID = Animate-Dot
- $filter = '.00040000', '.01020000', '.wav'
- if ($wav_unknownRedundant) {
- $filter += ,'.wav_unknown'
- }
- if ($removeSource) {
- $filter += ,'.bnk'
- }
- Get-ChildItem -LiteralPath $dirOutput -File -Recurse | Where-Object {$filter.Contains($_.Extension)} | ForEach-Object {
- Remove-Item -LiteralPath $_.FullName
- }
- $animatePID | Animate-Dot
- }
- # Moving files
- # Based on .bnk output
- Write-Host (' Moving extracted files').ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- $Start = (Get-Date)
- $animatePID = Animate-Dot
- Get-ChildItem -LiteralPath $dirOutput -File -Recurse -Filter '* *' | Where-Object { $_.Directory.Name -notmatch 'sounds' } | ForEach-Object {
- if ($_.Extension -eq '.Wwise' -and ($tempMatch = [regex]::Matches((Get-Content $_.FullName), 'OasisID[0-9]+')).Count -gt 0) {
- if (!$oasisTable.Contains($tempMatch.Groups[0].Value)) {
- $oasisTable.Add($tempMatch.Groups[0].Value, $_.Directory.Name)
- }
- } elseif (!$contentTable.Contains(([string]$tempContent = (Get-Content $_.FullName -TotalCount 3)))) {
- $contentTable.Add($tempContent, $_.Directory.Name)
- }
- }
- Get-ChildItem -LiteralPath $dirOutput -File -Recurse -Exclude '* *' | Where-Object { $_.Directory.Name -match 'sounds' } | ForEach-Object {
- if (($_.Extension -eq '.Wwise' -and ($tempMatch = [regex]::Matches((Get-Content $_.FullName), 'OasisID[0-9]+')).Count -gt 0 -and ($tempName = $oasisTable.($tempMatch.Groups[0].Value))) -or ($tempName = $contentTable.((Get-Content $_.FullName -TotalCount 3) -as [string]))) {
- if (!(Test-Path ('{0}\{1}' -f $_.DirectoryName, $tempName))) {
- New-Item ('{0}\{1}' -f $_.DirectoryName, $tempName) -ItemType Directory >$null
- }
- Move-Item $_.FullName -Destination ('{0}\{1}' -f $_.DirectoryName, $tempName)
- }
- }
- # Based on $oasisTable_ext
- if ($greedyOasisTable) {
- $tempPath = '.\resources\aliasTables\r6s_extractor_oasisTable_greedy.txt'
- } else {
- $tempPath = '.\resources\aliasTables\r6s_extractor_oasisTable_exact.txt'
- }
- # Populating $oasisTable_ext
- Get-Content $tempPath | Select-Object -Skip 1 | ForEach-Object {
- $oasisTable_ext.Add(($_.Split(';')[0].Split(',') | ForEach-Object {
- if ($_.Contains('..')) {
- [int]$s, [int]$e = $_ -split '\.\.'
- $s..$e
- } else {
- $_
- }
- }), $_.Split(';')[1])
- }
- Get-ChildItem -LiteralPath $dirOutput -File -Recurse -Filter *.Wwise | Where-Object { $_.Directory.Name -cnotmatch '[A-Z]' } | ForEach-Object {
- if (($tempMatch = [regex]::Matches((Get-Content $_.FullName), 'OasisID([0-9]+)')).Count -gt 0 -and ($tempName = ($oasisTable_ext.GetEnumerator() | Where-Object {$_.Name.Contains($tempMatch.Groups[1].Value)}).Value) -ne $null) {
- if ($_.Directory.Name -match '0x') {
- $tempDir = $_.Directory.Parent.FullName
- $tempName += ' ({0})' -f $_.Directory.Name
- } else {
- $tempDir = $_.DirectoryName
- }
- if (!(Test-Path ('{0}\{1}' -f $tempDir, $tempName))) {
- New-Item ('{0}\{1}' -f $tempDir, $tempName) -ItemType Directory >$null
- }
- Move-Item $_.FullName -Destination ('{0}\{1}' -f $tempDir, $tempName)
- }
- }
- # Based on $nameTable_pck
- # Populating $nameTable_pck
- Get-Content .\resources\aliasTables\r6s_extractor_nameTable_pck.txt | Select-Object -Skip 1 | ForEach-Object {
- $nameTable_pck.Add($_.Split(';')[0].Split(',').Replace('lwav', 'wav_unknown'), $_.Split(';')[1])
- }
- Get-ChildItem -LiteralPath $dirOutput -File -Recurse -Exclude '* *' | ? { $_.Directory.Name -cnotmatch '[A-Z]' } | ForEach-Object {
- $tempBaseFile = $_.BaseName.Substring(2)
- $tempFile = $_.Name.Substring(2)
- if (($tempName = ($nameTable_pck.GetEnumerator() | Where-Object {$_.Name.Contains($tempBaseFile) -or $_.Name.Contains($tempFile)}).Value) -ne $null) {
- if ($_.Directory.Name -match '0x') {
- $tempDir = $_.Directory.Parent.FullName
- $tempName += ' ({0})' -f $_.Directory.Name
- } else {
- $tempDir = $_.DirectoryName
- }
- if (!(Test-Path ('{0}\{1}' -f $tempDir, $tempName))) {
- New-Item ('{0}\{1}' -f $tempDir, $tempName) -ItemType Directory >$null
- }
- Move-Item $_.FullName -Destination ('{0}\{1}' -f $tempDir, $tempName)
- }
- }
- # Based on $nameTable_bnk
- # Populating $nameTable_bnk
- Get-Content .\resources\aliasTables\r6s_extractor_nameTable_bnk.txt | Select-Object -Skip 1 | ForEach-Object {
- $nameTable_bnk.Add($_.Split(';')[0].Split(',').Replace('lwav', 'wav_unknown'), $_.Split(';')[1])
- }
- Get-ChildItem -LiteralPath $dirOutput -File -Recurse -Filter '* *' | ? { $_.Directory.Name -cnotmatch '[A-Z]' } | ForEach-Object {
- $tempBaseFile = $_.BaseName.Substring(2)
- if (($tempName = ($nameTable_pck.GetEnumerator() | Where-Object {$_.Name.Contains($tempBaseFile)}).Value) -ne $null) {
- if ($_.Directory.Name -match '0x') {
- $tempDir = $_.Directory.Parent.FullName
- $tempName += ' ({0})' -f $_.Directory.Name
- } else {
- $tempDir = $_.DirectoryName
- }
- if (!(Test-Path ('{0}\{1}' -f $tempDir, $tempName))) {
- New-Item ('{0}\{1}' -f $tempDir, $tempName) -ItemType Directory >$null
- }
- Move-Item $_.FullName -Destination ('{0}\{1}' -f $tempDir, $tempName)
- }
- }
- $animatePID | Animate-Dot
- # Removing duplicate files
- if ($removeDuplicates) {
- Write-Host (' Removing duplicate files').ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- $Start = (Get-Date)
- $animatePID = Animate-Dot
- Get-ChildItem -LiteralPath $dirOutput -File -Recurse | ForEach-Object {
- if (!$dupTable.Contains(($hash = (Get-FileHash -LiteralPath $_.FullName -Algorithm MD5).Hash))) {
- $dupTable.Add($hash, $_.FullName)
- } else {
- if ($_.Directory.Name -cmatch '[A-Z]' -and ((Get-Item -LiteralPath $dupTable.$hash).Directory.Name) -cnotmatch '[A-Z]') {
- Remove-Item -LiteralPath $dupTable.$hash
- $dupTable.Remove($hash)
- $dupTable.Add($hash, $_.FullName)
- } else {
- Remove-Item -LiteralPath $_.FullName
- }
- }
- }
- $animatePID | Animate-Dot
- }
- # <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> #
- ####################################################################################################
- ####################################################################################################
- # <><><><><><><><><><><><><><><><><><><><><>< CONVERSION ><><><><><><><><><><><><><><><><><><><><> #
- # Converting .Wwise files
- Write-Host (" Converting '.Wwise' files").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- $Start = (Get-Date)
- $animatePID = Animate-Dot
- Get-ChildItem -LiteralPath $dirOutput -File -Recurse -Filter *.Wwise | ForEach-Object {
- if (!((.\resources\applications\ww2ogg.exe $_.FullName --pcb .\resources\applications\packed_codebooks_aoTuV_603.bin) -match 'Parse error')) {
- .\resources\applications\revorb.exe $_.FullName.Replace('.Wwise','.ogg')
- }
- }
- $animatePID | Animate-Dot
- <# Don't know how to convert .wav_unknown files (previously .lwav), 'wwise_ima_adpcm.exe' only produces nonsense #>
- # Converting .at3 files
- Write-Host (" Converting '.at3' files").ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- $Start = (Get-Date)
- $animatePID = Animate-Dot
- (Start-Process .\resources\applications\quickbms.exe -ArgumentList ('-F *.at3 -K -D -Y -. -Q -R .\resources\scripts\wwise_pcm_decoder.bms "{0}" "{0}"' -f $dirOutput) -WindowStyle Hidden -PassThru).Id | Stop-ChildOnExit
- $animatePID | Animate-Dot
- # <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> #
- ####################################################################################################
- ####################################################################################################
- # <><><><><><><><><><><><><><><><><><><>< REMOVING SOURCE ><><><><><><><><><><><><><><><><><><><> #
- # Removing extracted source files
- if ($removeSource) {
- Write-Host (' Removing extracted source files').ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- $Start = (Get-Date)
- $animatePID = Animate-Dot
- Get-ChildItem -LiteralPath $dirOutput -File -Recurse | Where-Object {('.00040000', '.01020000', '.bnk', '.wav_unknown', '.Wwise', '.at3').Contains($_.Extension)} | ForEach-Object {
- Remove-Item -LiteralPath $_.FullName
- }
- $animatePID | Animate-Dot
- }
- # Removing empty directories
- if ($removeEmptyDir) {
- Write-Host (' Removing empty directories').ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru -NoNewline} else {$_}}) -NoNewline
- $Start = (Get-Date)
- $animatePID = Animate-Dot
- Get-ChildItem -LiteralPath $dirOutput -Directory -Recurse | Where-Object {(Get-ChildItem -LiteralPath $_.FullName -File -Recurse | Select-Object -First 1).Count -eq 0} | ForEach-Object {
- Remove-Item -LiteralPath $_.FullName -Recurse
- }
- $animatePID | Animate-Dot
- }
- # Finishing
- Write-Host ("`n Overall duration: {0:h\:mm\:ss}`n" -f ((Get-Date) - $OverallStart)).ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- Write-Host -ForegroundColor Green (' Done!').ForEach({if ($createLog) {$_ | Add-Content -LiteralPath $env:TEMP\tc_r6s_audio_extractor_log.txt -PassThru} else {$_}})
- Read-Host
- # <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> #
- ###################################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement