Copy the text between -BEGIN- and -END- in a new textfile saved as a .ps1 file.cheezhed wrote: ↑Tue Feb 12, 2019 1:33 pmThat's great but for us neophytes how do I use the script?
Argonaute wrote: ↑Wed Feb 06, 2019 5:40 pmFor those who are using Newsleecher v7 with a product like NZBdrone, you can use the following powershell script to unobfuscate the downloaded files.
You must configure Newsleecher to copy and keep the nzb files to a protected location and the folders variables, and perhaps the files extensions, in the header of the script :
-BEGIN-
$ROOT_PATH="D:\DOWN\"
$MKV_PATH=$ROOT_PATH+"Extractions\"
$NZB_PATH=$ROOT_PATH+"Imported\"
$MKV_SPEC="*.mkv"
$NZB_SPEC="*.nzb"
function Get-Filename
{
Param(
[parameter(mandatory=$false)]
[string]$Filespec = ".\*.nzb",
[parameter(mandatory=$true)]
[string]$Pattern
)
$FileInfo = Get-ChildItem -Recurse $Filespec | Where-Object { Select-String $Pattern $_ -Quiet }
if([string]::IsNullOrEmpty($FileInfo) -eq $false) {
$RetValue = $FileInfo.Name.Remove($FileInfo.Name.LastIndexOf('.'))
} else {
$RetValue = $null
}
$RetValue
}
$MkvFilesSpec = $MKV_PATH+$MKV_SPEC
$NzbFilesSpec = $NZB_PATH+$NZB_SPEC
$MkvFiles = Get-ChildItem -Path $MkvFilesSpec
foreach($File in $MkvFiles) {
$FoundFileName = $null
$ParentFilePath = Convert-Path($File.PSParentPath)
$OriginalFileName = $File.Basename
$FoundFileName = Get-Filename -Filespec $NzbFilesSpec -Pattern $OriginalFileName
if([string]::IsNullOrEmpty($FoundFileName) -eq $false) {
[string]$NewFileName = $ParentFilePath+"\"+$FoundFileName+$File.Extension
$NewFileName
$File.MoveTo($NewFileName)
}
}
-END-
This become a Powershell script. Powershell is the new version of the command prompt since Windows 7.
In the execute part of the Windows menu if you use Windows 7 or in search part of windows 10 enter the following commands :
powershell.exe
This command open a Windows which look like a command prompt, enter the following :
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
In notepad open the .ps1 you created ion the first step, change the values after the '=' sign of the folders variables $MKV_PATH and $NZB_PATH where the mkv files are extracted after unrar and where nzb files are saved like this :
$MKV_PATH="C:\NEWSLEECHER\EXTRACTED\" # Put here the folder where newsleecher extract the downloads and don't forgot the '\' at the end of it.
$NZB_PATH="C:\NEWSLEECHER\NZB\" # Put here the folder where newsleecher save the nzb files it found in the automatic download function and don't forgot the '\' at the end of it.
save your changes and run the script using :
cd <The folder where you saved the ps1 script>
.\<The name of the script>.ps1
And it's done, you got the renamed mkv unobfuscated files.
-