Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTaylorLee committed Jul 27, 2024
1 parent b0ad0f8 commit 6b870a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions build/functions/Invoke-MEDIAMoviesToProcess.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Function Invoke-MEDIAMoviesToProcess {
$comment = $convert.format.tags.comment

# If database entry doesn't exist for file create table entry.
$query = "SELECT * FROM $TableName WHERE filename = `"$filename`""
$adjustedfilenamematch = $filename -replace " \{[a-zA-Z]+-\d+\}", ""
$query = "SELECT * FROM $TableName WHERE filename = `"$adjustedfilenamematch`""
$result = Invoke-SqliteQuery -DataSource $DataSource -Query $query -ErrorAction Inquire
if ($null -eq $result) {
# If comment tag of media file is transcoded, update database only
Expand Down Expand Up @@ -103,14 +104,14 @@ Function Invoke-MEDIAMoviesToProcess {
# If ffprobe indicates comment tag of media file is transcoded and file directory has changed, update database only
if ($comment -eq 'transcoded') {
$modified = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$query = "Update $TableName SET comment = `"$comment`", fileexists = 'true', modified = `"$modified`", updatedby = 'Invoke-MEDIAMoviesToProcess', fullname= `"$fullname`", directory = `"$directory`", filesizeMB = `"$filesizeMB`" WHERE filename = `"$filename`" and directory != `"$directory`""
$query = "Update $TableName SET comment = `"$comment`", fileexists = 'true', modified = `"$modified`", updatedby = 'Invoke-MEDIAMoviesToProcess', fullname= `"$fullname`", directory = `"$directory`", filesizeMB = `"$filesizeMB`" WHERE filename = `"$adjustedfilenamematch`" and directory != `"$directory`""
Invoke-SqliteQuery -ErrorAction Inquire -DataSource $DataSource -Query $query
}
# else ffprobe indicates comment tag of media file is not transcoded, copy and update database. Will update if file is moved or not moved to new directory. Useful for when file has been replace by another download.
else {
Copy-Item $fullname $env:FFToolsSource -Verbose
$modified = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$query = "Update $TableName SET fileexists = 'true', modified = `"$modified`", updatedby = 'Invoke-MEDIAMoviesToProcess', fullname= `"$fullname`", directory = `"$directory`", filesizeMB = `"$filesizeMB`" WHERE filename = `"$filename`""
$query = "Update $TableName SET fileexists = 'true', modified = `"$modified`", updatedby = 'Invoke-MEDIAMoviesToProcess', fullname= `"$fullname`", directory = `"$directory`", filesizeMB = `"$filesizeMB`" WHERE filename = `"$adjustedfilenamematch`""
Invoke-SqliteQuery -ErrorAction Inquire -DataSource $DataSource -Query $query
invoke-processmovie -MEDIAshowfolders $MEDIAshowfolders -MEDIAmoviefolders $MEDIAmoviefolders -DataSource $DataSource
}
Expand Down
6 changes: 4 additions & 2 deletions z-working idea.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ $adjustedfilenamematch

# adjusted filename variable would be used in lines 65, 106, and 113 of the above mentioned script for matching the file in the mediadb.sqlite database, and will update the entry.
# The adjusted filename variable doesn't need to handle scenarios of the filenames already within the database since they are filtered prior to the foreach loop.
## However if the folder path changes, then it will create a new entry in the database, which will result in lost statistics.
### So this is a run once scenario and would be for ongoing use cases.
## However if the folder path changes or the db ids are removed in the future, then it will create a new entry in the database, which will result in lost statistics.
### So this is a run once scenario and would be for ongoing use cases.

# Will not implement this feature, but am creating a dev image for single use.

0 comments on commit 6b870a6

Please sign in to comment.