Pass an URL.
This commit is contained in:
1 parent
5df048ff82
commit
c9b9ccfea1
2 files changed
+16
-11
No files matched your search
@@ -62,7 +62,7 @@ import Cocoa
|
||||
// MARK: Other
|
||||
private var artworkSelector: ArtworkSelectorController?
|
||||
private weak var delegate: MetadataSearchControllerDelegate?
|
||||
private let searchTerm: String
|
||||
private let url: URL?
|
||||
|
||||
// MARK: - Static methods
|
||||
@objc public static func clearRecentSearches() {
|
||||
@@ -82,8 +82,8 @@ import Cocoa
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
@objc init(delegate: MetadataSearchControllerDelegate, searchString: String) {
|
||||
self.searchTerm = searchString
|
||||
@objc init(delegate: MetadataSearchControllerDelegate, url: URL?) {
|
||||
self.url = url
|
||||
self.delegate = delegate
|
||||
self.state = .none
|
||||
self.movieService = MetadataSearch.defaultMovieService
|
||||
@@ -113,7 +113,7 @@ import Cocoa
|
||||
movieMetadataProvider.selectItem(withTitle: movieService.name)
|
||||
tvMetadataProvider.selectItem(withTitle: tvShowService.name)
|
||||
|
||||
if let info = searchTerm.parsedAsFilename() {
|
||||
if let info = url?.lastPathComponent.parsedAsFilename() {
|
||||
switch info {
|
||||
case let .movie(title):
|
||||
searchMode.selectTabViewItem(at: 0)
|
||||
@@ -127,6 +127,11 @@ import Cocoa
|
||||
searchForResults(searchTvButton)
|
||||
}
|
||||
}
|
||||
else if let title = url?.deletingPathExtension().lastPathComponent {
|
||||
movieName.stringValue = title
|
||||
tvSeriesName.stringValue = title
|
||||
searchForResults(searchMovieButton)
|
||||
}
|
||||
else {
|
||||
updateUI()
|
||||
}
|
||||
|
||||
@@ -833,10 +833,10 @@ static NSDictionary *_detailMonospacedAttr;
|
||||
|
||||
#pragma mark - Metadata search
|
||||
|
||||
- (NSString *)sourceFilename {
|
||||
- (NSURL *)sourceFilename {
|
||||
for (MP42Track *track in self.mp4.tracks) {
|
||||
if (track.URL) {
|
||||
return track.URL.lastPathComponent;
|
||||
return track.URL;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
@@ -844,13 +844,13 @@ static NSDictionary *_detailMonospacedAttr;
|
||||
|
||||
- (IBAction)searchMetadata:(id)sender
|
||||
{
|
||||
NSString *filename = [self sourceFilename];
|
||||
NSURL *url = [self sourceFilename];
|
||||
|
||||
if (!filename) {
|
||||
filename = self.fileURL.lastPathComponent;
|
||||
if (!url) {
|
||||
url = self.fileURL;
|
||||
}
|
||||
|
||||
self.sheetController = [[SBMetadataSearchController alloc] initWithDelegate:self searchString:filename];
|
||||
self.sheetController = [[SBMetadataSearchController alloc] initWithDelegate:self url:url];
|
||||
[self.documentWindow beginSheet:self.sheetController.window completionHandler:^(NSModalResponse returnCode) {
|
||||
self.sheetController = nil;
|
||||
}];
|
||||
@@ -897,7 +897,7 @@ static NSDictionary *_detailMonospacedAttr;
|
||||
NSString *title = [self.mp4.metadata metadataItemsFilteredByIdentifier:MP42MetadataKeyName].firstObject.stringValue;
|
||||
|
||||
if (title.length == 0) {
|
||||
title = [self sourceFilename];
|
||||
title = [self sourceFilename].lastPathComponent;
|
||||
}
|
||||
|
||||
NSUInteger duration = self.mp4.duration;
|
||||
|
||||
Reference in new issue
Block a user