Skip to content

Commit

Permalink
3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTaylorLee committed Jul 22, 2024
1 parent 2de4191 commit b96ac43
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 49 deletions.
10 changes: 5 additions & 5 deletions build/functions/Invoke-MEDIAMoviesToProcess.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Function Invoke-MEDIAMoviesToProcess {
Set-Location $MEDIAmoviefolder

# Identify media files that might not be transcoded through a comparison with the database. Should occasionally run update-processed to correct invalid data cause by re-downloaded media files and upgrades.
$files = (Get-ChildItem -ErrorAction Inquire $MEDIAmoviefolder -r -File -Include "*.mkv", "*.mp4").fullname
$files = (Get-ChildItem -ErrorAction Inquire -LiteralPath $MEDIAmoviefolder -r -File -Include "*.mkv", "*.mp4").fullname
$query = Invoke-SqliteQuery -DataSource $DataSource -Query "Select * FROM $TableName WHERE comment = 'transcoded' and directory like `"%$MEDIAmoviefolder%`"" -ErrorAction Inquire
$transcoded = ($query).fullname
if ($null -eq $transcoded) {
Expand All @@ -33,8 +33,8 @@ Function Invoke-MEDIAMoviesToProcess {
# Iterate possibly untranscoded Files
foreach ($file in $filesforprocessing) {
##Make sure no previous failures occurred prior to stepping forward
$testnofiles = Get-ChildItem $env:FFToolsSource -File
$testnofiles2 = Get-ChildItem $env:FFToolsTarget -File
$testnofiles = Get-ChildItem -LiteralPath $env:FFToolsSource -File
$testnofiles2 = Get-ChildItem -LiteralPath $env:FFToolsTarget -File

if ($null -eq $testnofiles -and $null -eq $testnofiles2) {
$test = Test-Path -Path $file
Expand All @@ -43,10 +43,10 @@ Function Invoke-MEDIAMoviesToProcess {
if ($test -eq 'True') {
# Check that 3 times the file size exists in free space on transcoding drive
$transcodingfreespace = (Get-PSDrive transcoding | Select-Object @{ Name = "FreeGB"; Expression = { [math]::round(($_.free / 1gb), 2) } }).FreeGB
$filesizemultiplied = ((Get-ChildItem $file | Select-Object @{ Name = "filesizeGB"; Expression = { [math]::round(($_.length / 1gb), 3) } }).filesizeGB) * 3
$filesizemultiplied = ((Get-ChildItem -LiteralPath $file | Select-Object @{ Name = "filesizeGB"; Expression = { [math]::round(($_.length / 1gb), 3) } }).filesizeGB) * 3

if ($transcodingfreespace -gt $filesizemultiplied) {
$file = Get-ChildItem $file | Select-Object name, fullname, directory, LastWriteTime, @{ Name = "filesizeMB"; Expression = { [math]::round(($_.length / 1mb), 2) } }
$file = Get-ChildItem -LiteralPath $file | Select-Object name, fullname, directory, LastWriteTime, @{ Name = "filesizeMB"; Expression = { [math]::round(($_.length / 1mb), 2) } }
$fullname = $file.fullname
$filename = $file.name
$directory = $file.directory
Expand Down
10 changes: 5 additions & 5 deletions build/functions/Invoke-MEDIAShowsToProcess.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Function Invoke-MEDIAShowsToProcess {
Set-Location $MEDIAshowfolder

# Identify media files that might not be transcoded through a comparison with the database. Should occasionally run update-processed to correct invalid data cause by re-downloaded media files and upgrades.
$files = (Get-ChildItem -ErrorAction Inquire $MEDIAshowfolder -r -File -Include "*.mkv", "*.mp4").fullname
$files = (Get-ChildItem -ErrorAction Inquire -LiteralPath $MEDIAshowfolder -r -File -Include "*.mkv", "*.mp4").fullname
$query = Invoke-SqliteQuery -ErrorAction Inquire -DataSource $DataSource -Query "Select * FROM $TableName WHERE comment = 'transcoded' and directory like `"%$MEDIAshowfolder%`""
$transcoded = ($query).fullname
if ($null -eq $transcoded) {
Expand All @@ -33,8 +33,8 @@ Function Invoke-MEDIAShowsToProcess {
# Iterate possibly untranscoded Files
foreach ($file in $filesforprocessing) {
##Make sure no previous failures occurred prior to stepping forward
$testnofiles = Get-ChildItem $env:FFToolsSource -File
$testnofiles2 = Get-ChildItem $env:FFToolsTarget -File
$testnofiles = Get-ChildItem -LiteralPath $env:FFToolsSource -File
$testnofiles2 = Get-ChildItem -LiteralPath $env:FFToolsTarget -File

if ($null -eq $testnofiles -and $null -eq $testnofiles2) {
$test = Test-Path -Path $file
Expand All @@ -43,10 +43,10 @@ Function Invoke-MEDIAShowsToProcess {
if ($test -eq 'True') {
# Check that 3 times the file size exists in free space on transcoding drive
$transcodingfreespace = (Get-PSDrive transcoding | Select-Object @{ Name = "FreeGB"; Expression = { [math]::round(($_.free / 1gb), 2) } }).FreeGB
$filesizemultiplied = ((Get-ChildItem $file | Select-Object @{ Name = "filesizeGB"; Expression = { [math]::round(($_.length / 1gb), 3) } }).filesizeGB) * 3
$filesizemultiplied = ((Get-ChildItem -LiteralPath $file | Select-Object @{ Name = "filesizeGB"; Expression = { [math]::round(($_.length / 1gb), 3) } }).filesizeGB) * 3

if ($transcodingfreespace -gt $filesizemultiplied) {
$file = Get-ChildItem $file | Select-Object name, fullname, directory, LastWriteTime, @{ Name = "filesizeMB"; Expression = { [math]::round(($_.length / 1mb), 2) } }
$file = Get-ChildItem -LiteralPath $file | Select-Object name, fullname, directory, LastWriteTime, @{ Name = "filesizeMB"; Expression = { [math]::round(($_.length / 1mb), 2) } }
$fullname = $file.fullname
$filename = $file.name
$directory = $file.directory
Expand Down
10 changes: 5 additions & 5 deletions build/functions/Invoke-MediaManagement.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Function Invoke-MediaManagement {

##Shows
##Make sure no previous failures occurred prior to stepping forward with shows
$testnofiles = Get-ChildItem $env:FFToolsSource -File
$testnofiles2 = Get-ChildItem $env:FFToolsTarget -File
$testnofiles = Get-ChildItem -LiteralPath $env:FFToolsSource -File
$testnofiles2 = Get-ChildItem -LiteralPath $env:FFToolsTarget -File
if ($null -eq $testnofiles -and $null -eq $testnofiles2) {
#Copy Files to processing folders
Invoke-MEDIAShowsToProcess -MEDIAshowfolders $MEDIAshowfolders -MEDIAmoviefolders $MEDIAmoviefolders -hours $hours -DataSource $DataSource
Expand All @@ -27,8 +27,8 @@ Function Invoke-MediaManagement {

##Movies
##Make sure no previous failures occurred prior to stepping forward with movies
$testnofiles = Get-ChildItem $env:FFToolsSource -File
$testnofiles2 = Get-ChildItem $env:FFToolsTarget -File
$testnofiles = Get-ChildItem -LiteralPath $env:FFToolsSource -File
$testnofiles2 = Get-ChildItem -LiteralPath $env:FFToolsTarget -File
if ($null -eq $testnofiles -and $null -eq $testnofiles2) {
#Copy Files to processing folders
Invoke-MEDIAMoviesToProcess -MEDIAshowfolders $MEDIAshowfolders -MEDIAmoviefolders $MEDIAmoviefolders -hours $hours -DataSource $DataSource
Expand All @@ -40,7 +40,7 @@ Function Invoke-MediaManagement {

#Remove recover files older than 14 days.
Write-Output "info: Deleting backup files over $env:BACKUPRETENTION days old"
Get-ChildItem -Path $env:FFToolsTarget/recover |
Get-ChildItem -LiteralPath $env:FFToolsTarget/recover |
Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$env:BACKUPRETENTION) } |
Remove-Item -Verbose

Expand Down
8 changes: 4 additions & 4 deletions build/functions/Invoke-ProcessMovie.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function invoke-processmovie {
##Source files will be moved into a recover folder in case transcode failed.
##If source files is smaller it's metadata will be cleaned up and the transcoded file removed.
##If target files has a length of 0 ffmpeg failed and processing aborts. This avoids transcode failures overwriting good files
$sourcefiles = Get-ChildItem $env:FFToolsSource -File | Select-Object fullname, Name, length
$targetfiles = Get-ChildItem $env:FFToolsTarget -File | Select-Object fullname, Name, length
$sourcefiles = Get-ChildItem -LiteralPath $env:FFToolsSource -File | Select-Object fullname, Name, length
$targetfiles = Get-ChildItem -LiteralPath $env:FFToolsTarget -File | Select-Object fullname, Name, length
$scount = ($sourcefiles | Measure-Object).count
$tcount = ($targetfiles | Measure-Object).count

Expand All @@ -41,7 +41,7 @@ function invoke-processmovie {
# If the source file is larger and backups are kept
elseif ($env:BACKUPPROCESSED -eq 'true') {
Move-Item $sourcefiles[$i].fullname $env:FFToolsTarget/recover -Force -Verbose
(Get-ChildItem $env:FFToolsTarget/recover/($sourcefiles[$i]).name).lastwritetime = (Get-Date)
(Get-ChildItem -LiteralPath $env:FFToolsTarget/recover/($sourcefiles[$i]).name).lastwritetime = (Get-Date)
}
# If the source file is larger and backups are not kept
else {
Expand All @@ -56,7 +56,7 @@ function invoke-processmovie {
}

##Move transcoded files into a processed folder so future file handling may proceed without issue
$processedfiles = Get-ChildItem $env:FFToolsTarget -File | Select-Object fullname, Name, length
$processedfiles = Get-ChildItem -LiteralPath $env:FFToolsTarget -File | Select-Object fullname, Name, length
$pcount = ($processedfiles | Measure-Object).count
[int]$max = $pcount
for ($i = 0; $i -lt $max; $i++) {
Expand Down
8 changes: 4 additions & 4 deletions build/functions/Invoke-ProcessShow.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function invoke-processshow {
##Source files will be moved into a recover folder in case transcode failed.
##If source files is smaller it's metadata will be cleaned up and the transcoded file removed.
##If target files has a length of 0 ffmpeg failed and processing aborts. This avoids transcode failures overwriting good files
$sourcefiles = Get-ChildItem $env:FFToolsSource -File | Select-Object fullname, Name, length
$targetfiles = Get-ChildItem $env:FFToolsTarget -File | Select-Object fullname, Name, length
$sourcefiles = Get-ChildItem -LiteralPath $env:FFToolsSource -File | Select-Object fullname, Name, length
$targetfiles = Get-ChildItem -LiteralPath $env:FFToolsTarget -File | Select-Object fullname, Name, length
$scount = ($sourcefiles | Measure-Object).count
$tcount = ($targetfiles | Measure-Object).count

Expand All @@ -41,7 +41,7 @@ function invoke-processshow {
# If the source file is larger and backups are kept
elseif ($env:BACKUPPROCESSED -eq 'true') {
Move-Item $sourcefiles[$i].fullname $env:FFToolsTarget/recover -Force -Verbose
(Get-ChildItem $env:FFToolsTarget/recover/($sourcefiles[$i]).name).lastwritetime = (Get-Date)
(Get-ChildItem -LiteralPath $env:FFToolsTarget/recover/($sourcefiles[$i]).name).lastwritetime = (Get-Date)
}
# If the source file is larger and backups are not kept
else {
Expand All @@ -56,7 +56,7 @@ function invoke-processshow {
}

##Move transcoded files into a processed folder so future file handling may proceed without issue
$processedfiles = Get-ChildItem $env:FFToolsTarget -File | Select-Object fullname, Name, length
$processedfiles = Get-ChildItem -LiteralPath $env:FFToolsTarget -File | Select-Object fullname, Name, length
$pcount = ($processedfiles | Measure-Object).count
[int]$max = $pcount
for ($i = 0; $i -lt $max; $i++) {
Expand Down
6 changes: 3 additions & 3 deletions build/functions/Move-FileToMediaFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ function Move-FileToMEDIAFolder {

#Get a list of files in processed folder
$processeddir = "$env:FFToolsTarget" + "processed"
[psobject]$filestomove = Get-ChildItem $processeddir -r -File -Include "*.mkv", "*.mp4" | Select-Object name, fullname, directory, @{ Name = "NewsizeMB"; Expression = { [math]::round(($_.length / 1mb), 2) } }
[psobject]$filestomove = Get-ChildItem -LiteralPath $processeddir -r -File -Include "*.mkv", "*.mp4" | Select-Object name, fullname, directory, @{ Name = "NewsizeMB"; Expression = { [math]::round(($_.length / 1mb), 2) } }

#Move processed movie files
foreach ($file in $filestomove) {
#move the file
$destination = $moviesdb | Where-Object { $_.filename -eq $file.name }
$oldsizemb = (Get-ChildItem $destination.fullname | Select-Object @{ Name = "oldsizeMB"; Expression = { [math]::round(($_.length / 1mb), 2) } }).oldsizeMB
$oldsizemb = (Get-ChildItem -LiteralPath $destination.fullname | Select-Object @{ Name = "oldsizeMB"; Expression = { [math]::round(($_.length / 1mb), 2) } }).oldsizeMB
if (Test-Path $destination.fullname -ErrorAction SilentlyContinue) {
# log stats and changes to database
$TableName = 'Movies'
Expand Down Expand Up @@ -66,7 +66,7 @@ function Move-FileToMEDIAFolder {
foreach ($file in $filestomove) {
#move the file
$destination = $showsdb | Where-Object { $_.filename -eq $file.name }
$oldsizemb = (Get-ChildItem $destination.fullname | Select-Object @{ Name = "oldsizeMB"; Expression = { [math]::round(($_.length / 1mb), 2) } }).oldsizeMB
$oldsizemb = (Get-ChildItem -LiteralPath $destination.fullname | Select-Object @{ Name = "oldsizeMB"; Expression = { [math]::round(($_.length / 1mb), 2) } }).oldsizeMB
if (Test-Path $destination.fullname -ErrorAction SilentlyContinue) {
# log stats and changes to database
$TableName = 'Shows'
Expand Down
6 changes: 3 additions & 3 deletions build/functions/backup-mediadb.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ function Backup-Mediadb {
#Used in debug logs
Write-Output "info: Backup-Mediadb Start"

$exists = Get-ChildItem -Path $backupfolder |
$exists = Get-ChildItem -LiteralPath $backupfolder |
Where-Object { $_.CreationTime -gt (Get-Date).AddDays(-7) }

if ($null -ne $exists) {
Write-Output "info: Skipping backup, database already backed up this week."
}
else {
$date = Get-Date -Format "yyyy-MM-dd"
$database = (Get-ChildItem $datasource).fullname
$database = (Get-ChildItem -LiteralPath $datasource).fullname
Copy-Item -Path $database -Destination "$backupfolder/$date.sqlite" -Verbose
}

Get-ChildItem -Path $backupfolder |
Get-ChildItem -LiteralPath $backupfolder |
Where-Object { $_.CreationTime -lt (Get-Date).AddDays(-30) } |
Remove-Item -Verbose

Expand Down
4 changes: 2 additions & 2 deletions build/scripts/Update-Metadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Write-Output "info: UPDATEMETADATA Start"
foreach ($path in $MEDIAmoviefolders) {
[string[]]$extensions = "*.mkv", "*.mp4"
foreach ($ext in $extensions) {
$files = Get-ChildItem -Path $path -Filter $ext -Recurse
$files = Get-ChildItem -LiteralPath $path -Filter $ext -Recurse
foreach ($file in $files) {
$name = $file.fullname
$oldname = $file.fullname + ".old"
Expand All @@ -18,7 +18,7 @@ foreach ($path in $MEDIAmoviefolders) {
foreach ($path in $MEDIAshowfolders) {
[string[]]$extensions = "*.mkv", "*.mp4"
foreach ($ext in $extensions) {
$files = Get-ChildItem -Path $path -Filter $ext -Recurse
$files = Get-ChildItem -LiteralPath $path -Filter $ext -Recurse
foreach ($file in $files) {
$name = $file.fullname
$oldname = $file.fullname + ".old"
Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@
- 2.24.2 Failed to use a dev branch for 2.24.1 and workflows didn't run. Using 2.24.2 to trigger workflows and test for bugs.
- 2.25.0 Add the following to surpress verbose output, but still display stats. This will make logs easier to read by removing thousands of unneeded lines. (-hide_banner -loglevel error -stats)
- 2.25.1 Add the suppress output parameters to Invoke-Process<media/show> functions. Larger file sizes resulted in updating metadata only and those runs of ffmpeg were missing the parameters.
- 3.0.0 Deprecating Ubuntu Build and update alpine build
- 3.0.0 Deprecating Ubuntu Build and update alpine build
- 3.0.1 Add literalpath parameter instead of path parameters for get-childitems This prevents square brackets in path names treating that part of the path as a regex filter and breaking comparisons.
6 changes: 3 additions & 3 deletions modules/MediaFunctions/Public/Get-EmptyFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ function Get-EmptyFolder {
[string[]]$mediafolders = $mediashowfolders + $mediamoviefolders

foreach ($mediafolder in $mediafolders) {
Get-ChildItem $mediafolder -Directory -Recurse |
Where-Object { $_.GetFileSystemInfos().Count -eq 0 } |
Select-Object FullName
Get-ChildItem -LiteralPath $mediafolder -Directory -Recurse |
Where-Object { $_.GetFileSystemInfos().Count -eq 0 } |
Select-Object FullName
}
}
12 changes: 6 additions & 6 deletions modules/MediaFunctions/Public/Get-MissingYear.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ function Get-MissingYear {
Remove-Item /docker-transcodeautomation/data/logs/missingyear.log -Force
}
foreach ($mediafolder in $mediafolders) {
Get-ChildItem $mediafolder -r |
Sort-Object fullname |
Select-Object name, fullname |
Where-Object { $_.name -notlike "*(*)*" } |
#Format-Table -AutoSize |
Out-File /docker-transcodeautomation/data/logs/missingyear.log -Width 10000 -Append
Get-ChildItem -LiteralPath $mediafolder -r |
Sort-Object fullname |
Select-Object name, fullname |
Where-Object { $_.name -notlike "*(*)*" } |
#Format-Table -AutoSize |
Out-File /docker-transcodeautomation/data/logs/missingyear.log -Width 10000 -Append
}
Write-Output "Results can be found at /docker-transcodeautomation/data/logs/missingyear.log"
}
Loading

0 comments on commit b96ac43

Please sign in to comment.