Skip to content

Commit

Permalink
4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTaylorLee committed Oct 25, 2024
1 parent d0bd17c commit 2c93f9c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
11 changes: 10 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ The pull request checklist must be reviewed and completed prior to completing a
- [ ] Reviewed the [Contributing Guidelines](https://github.com/TheTaylorLee/docker-transcodeautomation/blob/master/contributing.md)
- [ ] Updated changelog.md
- [ ] Updated version with new semver
- [ ] Built dev images and tested changes
- [ ] Build dev images and test changes
- [ ] Rename a file and ensure the database entry updates paths & retains statistics.
- [ ] Delete a file. The associated table entry should mark fileexists false and not modify the comment.
- [ ] Update-Processed once run should mark the comment NULL
- [ ] Replace a file with a file of the same name, but the comment should not match dta-*. The table entry should remain unchanged.
- Update-Processed when run should null the comment of the db entry.
- Next run the table entry should be renamed and NULL fields should have data. Ensure entries are accurate.
- [ ] Add a new unique file and see that a table entry is created and the file is transcoded
- [ ] Move a file to a new parent directory provided to MEDIA(MOVIE/SHOWS)FOLDERS environment variable. Statistics should be preserved.
- [ ] If this is a new major release with breaking changes, a github release must first be created.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,11 @@ Move-FileToMediaFolder #Move transcoded files back to media folders. TranscodeAu
- `/docker-transcodeautomation/data/MediaDB.sqlite` volume file is a sqlite database containing media data and statistics
- Any sqlite viewer of choice can be leveraged if desired to view this data
- [Here is an example using Grafana](https://github.com/TheTaylorLee/docker-transcodeautomation/tree/master/examples/grafana)

## Additional Notes
- If a file is is replaced by another file of the same name, and the old file is deleted, statistics cannot update sooner than (25 hours + PROCDELAY + MINAGE). This ensures statistics are not lost in rare circumstances. Becuase of this the container must run at a minimum that long without restart prior to a replaced files database entry being updated.
- Docker logs should provide hints to the root of the issue and relevant snippets need to be included in opened issues.
- If the logs indicate that there are files leftover in the transcoding directory you must remove them. This is a safety feature that ensures failed transcodes don't replace original files.
- If your media database becomes corrupted, use the backed-up databases to restore a healthy copy.
- /docker-transcodeautomation/data/MediaDB.SQLite #database location
- /docker-transcodeautomation/data/Backups #BackupsLocation
11 changes: 10 additions & 1 deletion build/Invoke-TranscodeAutomation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,18 @@ if ($host.version.major -eq '7') {
$dt = Get-Date
Write-Output "info: Transcodeautomation while loop started at $dt"
###The Move-FiletoMediaFolder function is run here as a part of the fix for issue #29 Having it run here ensures even if there are no files to transcode, the failed file move is processed during the next window.
/docker-transcodeautomation/scripts/Update-Processed.ps1
Move-FileToMEDIAFolder -MEDIAshowfolders $MEDIAshowfolders -MEDIAmoviefolders $MEDIAmoviefolders -DataSource $datasource #Issue 29
Invoke-MediaManagement -hours $env:MINAGE -MEDIAshowfolders $MEDIAshowfolders -MEDIAmoviefolders $MEDIAmoviefolders -DataSource $datasource
# Update-Processed can only run after the all possible file handling delays have passed. This ensures that if a file name changed but still exists, other functions update the database first.
if ($null -eq $runthisonetimeonly) {
Write-Output "info: Set runthisonetimeonly to true and populate a date variable for update-processed to leverage."
$runthisonetimeonly = $true
$updateprocesseddate = Get-Date
[int]$updateprocessedsecondsdelay = 90000 + $minseconds + ([int]$env:MINAGE * 3600)
}
if ($updateprocesseddate -lt (Get-Date).AddSeconds(-$updateprocessedsecondsdelay)) {
/docker-transcodeautomation/scripts/Update-Processed.ps1 -DataSource $datasource
}
Backup-Mediadb -backupfolder $backupfolder -datasource $datasource
Update-Statistics -DataSource $datasource
}
Expand Down
4 changes: 2 additions & 2 deletions build/functions/Invoke-MEDIAMoviesToProcess.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Function Invoke-MEDIAMoviesToProcess {
$query = Invoke-SqliteQuery -DataSource $DataSource -Query "Select * FROM $TableName WHERE (comment = `"$comment`" and comment IS NOT NULL)" -ErrorAction Inquire
}

# If File Exists
# If File Exists on disk
if ($test -eq 'True' -or $null -ne $query) {
# 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
Expand Down Expand Up @@ -138,7 +138,7 @@ Function Invoke-MEDIAMoviesToProcess {
else {
$fullname = $file
$modified = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$query = "Update $TableName SET comment = NULL, filesizeMB = NULL, fileexists = 'false', modified = `"$modified`", updatedby = 'Invoke-MEDIAMoviesToProcess' WHERE fullname = `"$fullname`""
$query = "Update $TableName SET filesizeMB = NULL, fileexists = 'false', modified = `"$modified`", updatedby = 'Invoke-MEDIAMoviesToProcess' WHERE fullname = `"$fullname`""
Invoke-SqliteQuery -ErrorAction Inquire -DataSource $DataSource -Query $query
}
}
Expand Down
4 changes: 2 additions & 2 deletions build/functions/Invoke-MEDIAShowsToProcess.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Function Invoke-MEDIAShowsToProcess {
$query = Invoke-SqliteQuery -DataSource $DataSource -Query "Select * FROM $TableName WHERE (comment = `"$comment`" and comment IS NOT NULL)" -ErrorAction Inquire
}

# If File Exists
# If File Exists on disk
if ($test -eq 'True' -or $null -ne $query) {
# 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
Expand Down Expand Up @@ -138,7 +138,7 @@ Function Invoke-MEDIAShowsToProcess {
else {
$fullname = $file
$modified = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$query = "Update $TableName SET comment = NULL, filesizeMB = NULL, fileexists = 'false', modified = `"$modified`", updatedby = 'Invoke-MEDIAShowsToProcess' WHERE fullname = `"$fullname`""
$query = "Update $TableName SET filesizeMB = NULL, fileexists = 'false', modified = `"$modified`", updatedby = 'Invoke-MEDIAShowsToProcess' WHERE fullname = `"$fullname`""
Invoke-SqliteQuery -ErrorAction Inquire -DataSource $DataSource -Query $query
}
}
Expand Down
4 changes: 3 additions & 1 deletion build/scripts/Update-Processed.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Write-Output "info: Update-Processed Start"

[string]$DataSource = "/docker-transcodeautomation/data/MediaDB.SQLite"
param (
[string]$DataSource
)

# Test to see if update-processed has run in the last 7 days
$getcount = Invoke-SqliteQuery -DataSource $DataSource -Query "select * from UpdateProcessedLog"
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@
- Update Invoke-Media(shows/movies)ToProcess. Change the logic up so that if an entry already exists that matches the immutable index it updates the files entry. This ensures renamed and moved files always update the pre-existing table entry.
- Update invoke-process(movie/show) and start-transcode(movies/show) to use update-lastindex for transcoding/remuxing index data into the processed media metadata.
- Eliminated latest tag. There are breaking change I don't need to be pushing that out unannounced. Read github release notes for how to migrate.
- 4.0.1 Fix file failing to update the database properly if if renamed.
- 4.0.1 Fix file failing to update the database properly if renamed. Had to add delays for update-processed and not null comments when running these functions. Invoke-Media(shows/movies)ToProcess

0 comments on commit 2c93f9c

Please sign in to comment.