Rank metadata search results and honor filename IDs on tagged files
extractSearchTerms dropped a filename's {tmdb-…} ID whenever the movie was
already tagged (name+release-date+media-kind present), returning a bare title
and ignoring the embedded ID — so a search on a tagged or previously-searched
file came back as a fuzzy title list. That branch now also parses the filename,
so the direct ID lookup fires regardless of prior tagging.
Also rank movie title-search results so exact title matches sort to the top of
the fuzzy provider list, and recover the release year from the filename
(ParseFilename strips it from the title without reporting it) to pick the
default entry: exact+year, then exact, then year-only, then the provider's own
order (a stable sort, so relevance survives within each band). Applied in the
search sheet, the queue metadata action, and both AppleScript commands with
identical ranking so scripted indexes stay aligned; the sheet now highlights
the default pick. Bracketed years win over bare dot/space years so
resolutions like .1920.1080p don't win.
Bump the fork version to 1.9.5mkv2.
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
a153763019
commit
13255140e9
8 files changed
+148
-23
No files matched your search
@@ -150,7 +150,7 @@ class SBFetchMetadataScriptCommand: NSScriptCommand, ScriptCommandDocumentTarget
|
||||
let preferredArtworkSize = ArtworkSize(rawValue: queuePrefs.providerArtworkSize) ?? .standard
|
||||
|
||||
switch terms {
|
||||
case let .movie(title, id):
|
||||
case let .movie(title, id, year):
|
||||
let language = MetadataSearch.defaultLanguage(service: movieService, type: .movie)
|
||||
|
||||
// Shared continuation for both the ID lookup and the title search
|
||||
@@ -188,7 +188,9 @@ class SBFetchMetadataScriptCommand: NSScriptCommand, ScriptCommandDocumentTarget
|
||||
let searchByName: () -> Void = {
|
||||
let movieSearch = MetadataSearch.movieSeach(service: movieService, movie: title, language: language)
|
||||
_ = movieSearch.search(completionHandler: { results in
|
||||
if let result = results.first {
|
||||
// Same ranking as the search sheet and the queue: exact
|
||||
// title match first, then the file-name year.
|
||||
if let result = rankMovieResults(results, title: title, year: year).first {
|
||||
completeWith(result, movieSearch)
|
||||
} else {
|
||||
completion(nil)
|
||||
@@ -663,8 +665,10 @@ class SBFetchMetadataResultsScriptCommand: NSScriptCommand, ScriptCommandDocumen
|
||||
|
||||
// Perform the search based on media type
|
||||
switch terms {
|
||||
case .movie(let title, _):
|
||||
let results = movieService.search(movie: title, language: searchLanguage)
|
||||
case .movie(let title, _, let parsedYear):
|
||||
// Ranked so the indexes handed out here line up with the ranked
|
||||
// list the index-based fetch-metadata command rebuilds later.
|
||||
let results = rankMovieResults(movieService.search(movie: title, language: searchLanguage), title: title, year: parsedYear)
|
||||
|
||||
// Convert MetadataResult to SBMetadataResult
|
||||
let sbResults = results.map { result in
|
||||
@@ -814,11 +818,13 @@ class SBFetchAndSetMetadataResultScriptCommand: NSScriptCommand, ScriptCommandDo
|
||||
|
||||
// Perform the search based on media type
|
||||
// (Title search by design: the caller indexes into the list returned by the
|
||||
// earlier fetch-metadata-results command, so no ID shortcut here.)
|
||||
// earlier fetch-metadata-results command, so no ID shortcut here — and the
|
||||
// same ranking must be applied, so the caller's index selects the same entry.)
|
||||
switch terms {
|
||||
case let .movie(title, _):
|
||||
case let .movie(title, _, parsedYear):
|
||||
let movieSearch = MetadataSearch.movieSeach(service: movieService, movie: title, language: searchLanguage)
|
||||
_ = movieSearch.search(completionHandler: { results in
|
||||
_ = movieSearch.search(completionHandler: { found in
|
||||
let results = rankMovieResults(found, title: title, year: parsedYear)
|
||||
if resultIndex >= 0 && resultIndex < results.count {
|
||||
let selectedResult = results[resultIndex]
|
||||
|
||||
|
||||
Reference in new issue
Block a user