Modernize the code a bit, fix the help url and improve the dts options
This commit is contained in:
1 parent
e161718557
commit
b005cd7d1d
26 files changed
+355
-214
No files matched your search
@@ -10,6 +10,8 @@
|
||||
|
||||
@class MP42Metadata;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MetadataImporter : NSObject {
|
||||
@private
|
||||
BOOL _isCancelled;
|
||||
@@ -27,9 +29,9 @@ typedef enum SBCachePolicy : NSUInteger {
|
||||
+ (NSData *)downloadDataFromURL:(NSURL *)url withCachePolicy:(SBCachePolicy)policy;
|
||||
|
||||
#pragma mark Class methods
|
||||
+ (NSArray *) movieProviders;
|
||||
+ (NSArray *) tvProviders;
|
||||
+ (NSArray *) languagesForProvider:(NSString *)aProvider;
|
||||
+ (NSArray<NSString *> *) movieProviders;
|
||||
+ (NSArray<NSString *> *) tvProviders;
|
||||
+ (NSArray<NSString *> *) languagesForProvider:(NSString *)aProvider;
|
||||
+ (instancetype) importerForProvider:(NSString *)aProviderName;
|
||||
+ (instancetype) defaultMovieProvider;
|
||||
+ (instancetype) defaultTVProvider;
|
||||
@@ -39,21 +41,26 @@ typedef enum SBCachePolicy : NSUInteger {
|
||||
+ (NSString *) defaultLanguageForProvider:(NSString *)provider;
|
||||
|
||||
#pragma mark Asynchronous searching
|
||||
- (void) searchTVSeries:(NSString *)aSeries language:(NSString *)aLanguage completionHandler:(void(^)(NSArray *results))handler;
|
||||
- (void) searchTVSeries:(NSString *)aSeries language:(NSString *)aLanguage seasonNum:(NSString *)aSeasonNum episodeNum:(NSString *)aEpisodeNum completionHandler:(void(^)(NSArray *results))handler;
|
||||
- (void) searchTVSeries:(NSString *)aSeries language:(NSString *)aLanguage completionHandler:(void(^)(NSArray<MP42Metadata *> * _Nullable results))handler;
|
||||
- (void) searchTVSeries:(NSString *)aSeries language:(NSString *)aLanguage seasonNum:(NSString *)aSeasonNum episodeNum:(NSString *)aEpisodeNum completionHandler:(void(^)(NSArray<MP42Metadata *> * _Nullable results))handler;
|
||||
|
||||
- (void) searchMovie:(NSString *)aMovieTitle language:(NSString *)aLanguage completionHandler:(void(^)(NSArray *results))handler;
|
||||
- (void) searchMovie:(NSString *)aMovieTitle language:(NSString *)aLanguage completionHandler:(void(^)(NSArray<MP42Metadata *> * _Nullable results))handler;
|
||||
|
||||
- (void) loadFullMetadata:(MP42Metadata *)aMetadata language:(NSString *)aLanguage completionHandler:(void(^)(MP42Metadata *metadata))handler;
|
||||
- (void) loadFullMetadata:(MP42Metadata *)aMetadata language:(NSString *)aLanguage completionHandler:(void(^)(MP42Metadata * _Nullable metadata))handler;
|
||||
|
||||
- (void) cancel;
|
||||
|
||||
#pragma Methods to be overridden
|
||||
- (NSArray *) languages;
|
||||
- (NSArray *) searchTVSeries:(NSString *)aSeriesName language:(NSString *)aLanguage;
|
||||
- (NSArray *) searchTVSeries:(NSString *)aSeriesName language:(NSString *)aLanguage seasonNum:(NSString *)aSeasonNum episodeNum:(NSString *)aEpisodeNum;
|
||||
- (NSArray *) searchMovie:(NSString *)aMovieTitle language:(NSString *)aLanguage;
|
||||
- (MP42Metadata*) loadTVMetadata:(MP42Metadata *)aMetadata language:(NSString *)aLanguage;
|
||||
- (MP42Metadata*) loadMovieMetadata:(MP42Metadata *)aMetadata language:(NSString *)aLanguage;
|
||||
- (NSArray<NSString *> *) languages;
|
||||
|
||||
- (NSArray<MP42Metadata *> * _Nullable) searchTVSeries:(NSString *)aSeriesName language:(NSString *)aLanguage;
|
||||
- (NSArray<MP42Metadata *> * _Nullable) searchTVSeries:(NSString *)aSeriesName language:(NSString *)aLanguage seasonNum:(NSString * _Nullable)aSeasonNum episodeNum:(NSString * _Nullable)aEpisodeNum;
|
||||
|
||||
- (NSArray<MP42Metadata *> * _Nullable) searchMovie:(NSString *)aMovieTitle language:(NSString *)aLanguage;
|
||||
|
||||
- (MP42Metadata * _Nullable) loadTVMetadata:(MP42Metadata *)aMetadata language:(NSString *)aLanguage;
|
||||
- (MP42Metadata * _Nullable) loadMovieMetadata:(MP42Metadata *)aMetadata language:(NSString *)aLanguage;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -225,7 +225,7 @@
|
||||
}
|
||||
|
||||
#pragma mark Asynchronous searching
|
||||
- (void) searchTVSeries:(NSString *)aSeries language:(NSString *)aLanguage completionHandler:(void(^)(NSArray *results))handler {
|
||||
- (void) searchTVSeries:(NSString *)aSeries language:(NSString *)aLanguage completionHandler:(void(^)(NSArray<MP42Metadata *> * _Nullable results))handler {
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
NSArray *results = [self searchTVSeries:aSeries language:aLanguage];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@@ -236,7 +236,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void) searchTVSeries:(NSString *)aSeries language:(NSString *)aLanguage seasonNum:(NSString *)aSeasonNum episodeNum:(NSString *)aEpisodeNum completionHandler:(void(^)(NSArray *results))handler {
|
||||
- (void) searchTVSeries:(NSString *)aSeries language:(NSString *)aLanguage seasonNum:(NSString *)aSeasonNum episodeNum:(NSString *)aEpisodeNum completionHandler:(void(^)(NSArray<MP42Metadata *> * _Nullable results))handler {
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
NSArray *results = [self searchTVSeries:aSeries language:aLanguage seasonNum:aSeasonNum episodeNum:aEpisodeNum];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@@ -247,7 +247,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void) searchMovie:(NSString *)aMovieTitle language:(NSString *)aLanguage completionHandler:(void(^)(NSArray *results))handler {
|
||||
- (void) searchMovie:(NSString *)aMovieTitle language:(NSString *)aLanguage completionHandler:(void(^)(NSArray<MP42Metadata *> * _Nullable results))handler {
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
NSArray *results = [self searchMovie:aMovieTitle language:aLanguage];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@@ -258,7 +258,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void) loadFullMetadata:(MP42Metadata *)aMetadata language:(NSString *)aLanguage completionHandler:(void(^)(MP42Metadata *metadata))handler {
|
||||
- (void) loadFullMetadata:(MP42Metadata *)aMetadata language:(NSString *)aLanguage completionHandler:(void(^)(MP42Metadata * _Nullable metadata))handler {
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
if (aMetadata.mediaKind == 9) {
|
||||
[self loadMovieMetadata:aMetadata language:aLanguage];
|
||||
@@ -279,7 +279,7 @@
|
||||
|
||||
#pragma mark Methods to be overridden
|
||||
|
||||
- (NSArray *) languages {
|
||||
- (NSArray<NSString *> *) languages {
|
||||
@throw [NSException exceptionWithName:NSInternalInconsistencyException
|
||||
reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]
|
||||
userInfo:nil];
|
||||
|
||||
@@ -171,8 +171,7 @@
|
||||
|
||||
- (IBAction) help:(id)sender
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openURL: [NSURL
|
||||
URLWithString:@"http://code.google.com/p/subler/wiki/Documentation"]];
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://bitbucket.org/galad87/subler/wiki/Home"]];
|
||||
}
|
||||
|
||||
- (IBAction) linkDonate:(id)sender
|
||||
@@ -207,7 +206,7 @@
|
||||
|
||||
SBDocument *doc = [self openUntitledDocumentAndDisplay:displayDocument error:&outError];
|
||||
[doc performSelectorOnMainThread:@selector(showImportSheet:) withObject:[NSArray arrayWithObject:url] waitUntilDone:NO];
|
||||
completionHandler(doc, NO, NULL);
|
||||
completionHandler(doc, NO, outError);
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
IBOutlet NSSlider *slider;
|
||||
IBOutlet NSButton *addArtworkButton;
|
||||
IBOutlet NSButton *loadMoreArtworkButton;
|
||||
NSMutableArray *imageURLsUnloaded;
|
||||
NSMutableArray<NSURL *> *imageURLsUnloaded;
|
||||
NSMutableArray *images;
|
||||
NSArray *artworkProviderNames;
|
||||
NSArray<NSString *> *artworkProviderNames;
|
||||
}
|
||||
|
||||
#pragma mark Initialization
|
||||
- (instancetype)initWithDelegate:(id <SBArtworkSelectorDelegate>)del imageURLs:(NSArray *)imageURLs artworkProviderNames:(NSArray *)artworkProviderNames;
|
||||
- (instancetype)initWithDelegate:(id <SBArtworkSelectorDelegate>)del imageURLs:(NSArray<NSURL *> *)imageURLs artworkProviderNames:(NSArray<NSString *> *)artworkProviderNames;
|
||||
|
||||
#pragma mark Load images
|
||||
- (IBAction) loadMoreArtwork:(id)sender;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MP42File;
|
||||
|
||||
@interface SBDocument : NSDocument {
|
||||
@@ -72,3 +74,5 @@
|
||||
- (void)showImportSheet:(NSArray *)fileURLs;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+54
-45
@@ -59,12 +59,11 @@
|
||||
languages = [[[MP42Languages defaultManager] languages] retain];
|
||||
_optimize = NO;
|
||||
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
[self reloadPropertyView];
|
||||
[sendToQueue setImage:[NSImage imageNamed:NSImageNameShareTemplate]];
|
||||
|
||||
[fileTracksTable registerForDraggedTypes:[NSArray arrayWithObjects:SublerTableViewDataType, nil]];
|
||||
[documentWindow registerForDraggedTypes:[NSArray arrayWithObjects:
|
||||
NSColorPboardType, NSFilenamesPboardType, nil]];
|
||||
[fileTracksTable registerForDraggedTypes:@[SublerTableViewDataType]];
|
||||
[documentWindow registerForDraggedTypes:@[NSFilenamesPboardType]];
|
||||
|
||||
}
|
||||
|
||||
@@ -86,6 +85,9 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Read methods
|
||||
|
||||
+ (BOOL)canConcurrentlyReadDocumentsOfType:(NSString *)type
|
||||
{
|
||||
return YES;
|
||||
@@ -96,15 +98,13 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
#pragma mark Read methods
|
||||
|
||||
- (void)reloadFile:(NSURL *)absoluteURL
|
||||
{
|
||||
if (absoluteURL) {
|
||||
self.mp4 = [[[MP42File alloc] initWithExistingFile:absoluteURL andDelegate:self] autorelease];
|
||||
|
||||
[fileTracksTable reloadData];
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
[self reloadPropertyView];
|
||||
|
||||
if (!self.mp4) {
|
||||
[self close];
|
||||
@@ -130,7 +130,7 @@
|
||||
self.mp4 = [[[MP42File alloc] initWithExistingFile:absoluteURL andDelegate:self] autorelease];
|
||||
|
||||
[fileTracksTable reloadData];
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
[self reloadPropertyView];
|
||||
[self updateChangeCount:NSChangeCleared];
|
||||
|
||||
if (outError != NULL && !self.mp4) {
|
||||
@@ -174,11 +174,6 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)saveToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation completionHandler:(void (^)(NSError * _Nullable))completionHandler
|
||||
{
|
||||
[super saveToURL:url ofType:typeName forSaveOperation:saveOperation completionHandler:completionHandler];
|
||||
}
|
||||
|
||||
- (BOOL)writeSafelyToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation error:(NSError * _Nullable *)outError
|
||||
{
|
||||
NSMutableDictionary * attributes = [[NSMutableDictionary alloc] init];
|
||||
@@ -187,8 +182,6 @@
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBOrganizeAlternateGroups"] boolValue])
|
||||
[attributes setObject:@YES forKey:MP42OrganizeAlternateGroups];
|
||||
|
||||
[self unblockUserInteraction];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[optBar setIndeterminate:YES];
|
||||
[optBar startAnimation:self];
|
||||
@@ -197,6 +190,7 @@
|
||||
modalDelegate:nil didEndSelector:NULL contextInfo:nil];
|
||||
});
|
||||
|
||||
[self unblockUserInteraction];
|
||||
|
||||
IOPMAssertionID assertionID;
|
||||
// Enable sleep assertion
|
||||
@@ -249,14 +243,17 @@
|
||||
[savePanel setExtensionHidden:NO];
|
||||
[savePanel setAccessoryView:saveView];
|
||||
|
||||
NSArray *formats = [self writableTypesForSaveOperation:NSSaveAsOperation];
|
||||
NSArray<NSString *> *formats = [self writableTypesForSaveOperation:NSSaveAsOperation];
|
||||
|
||||
[fileFormat removeAllItems];
|
||||
for (id format in formats)
|
||||
for (NSString *format in formats) {
|
||||
[fileFormat addItemWithTitle:format];
|
||||
}
|
||||
|
||||
[fileFormat selectItemAtIndex:[[[NSUserDefaults standardUserDefaults] valueForKey:@"defaultSaveFormat"] integerValue]];
|
||||
if ([[NSUserDefaults standardUserDefaults] valueForKey:@"SBSaveFormat"])
|
||||
[_currentSavePanel setAllowedFileTypes:[NSArray arrayWithObject:[[NSUserDefaults standardUserDefaults] valueForKey:@"SBSaveFormat"]]];
|
||||
if ([[NSUserDefaults standardUserDefaults] valueForKey:@"SBSaveFormat"]) {
|
||||
_currentSavePanel.allowedFileTypes = @[[[NSUserDefaults standardUserDefaults] valueForKey:@"SBSaveFormat"]];
|
||||
}
|
||||
|
||||
NSString *filename = nil;
|
||||
for (MP42Track *track in self.mp4.tracks) {
|
||||
@@ -266,11 +263,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (filename)
|
||||
if (filename) {
|
||||
[savePanel performSelector:@selector(setNameFieldStringValue:) withObject:filename];
|
||||
}
|
||||
|
||||
if (self.mp4.dataSize > 4200000000)
|
||||
if (self.mp4.dataSize > 4200000000) {
|
||||
[_64bit_data setState:NSOnState];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -300,7 +299,7 @@
|
||||
break;
|
||||
}
|
||||
|
||||
[_currentSavePanel setAllowedFileTypes:[NSArray arrayWithObject:requiredFileType]];
|
||||
[_currentSavePanel setAllowedFileTypes:@[requiredFileType]];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:requiredFileType forKey:@"SBSaveFormat"];
|
||||
}
|
||||
|
||||
@@ -414,7 +413,7 @@
|
||||
|
||||
#pragma mark table datasource
|
||||
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)t
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
|
||||
{
|
||||
return self.mp4.tracks.count;
|
||||
}
|
||||
@@ -477,6 +476,11 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
}
|
||||
|
||||
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
|
||||
{
|
||||
[self reloadPropertyView];
|
||||
}
|
||||
|
||||
- (void)reloadPropertyView
|
||||
{
|
||||
if ([propertyView view] != nil) {
|
||||
// remove the current view
|
||||
@@ -532,7 +536,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
return NO;
|
||||
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
|
||||
[pboard declareTypes:[NSArray arrayWithObject:SublerTableViewDataType] owner:self];
|
||||
[pboard declareTypes:@[SublerTableViewDataType] owner:self];
|
||||
[pboard setData:data forType:SublerTableViewDataType];
|
||||
return YES;
|
||||
}
|
||||
@@ -595,7 +599,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
[importWindow autorelease], importWindow = nil;
|
||||
|
||||
[fileTracksTable reloadData];
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
[self reloadPropertyView];
|
||||
}
|
||||
|
||||
- (IBAction)sendToQueue:(id)sender
|
||||
@@ -706,7 +710,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
[self.mp4 organizeAlternateGroups];
|
||||
|
||||
[fileTracksTable reloadData];
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
[self reloadPropertyView];
|
||||
[self updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
@@ -717,7 +721,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
[self.mp4 addTrack:[MP42ChapterTrack chapterTrackFromFile:fileURL]];
|
||||
|
||||
[fileTracksTable reloadData];
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
[self reloadPropertyView];
|
||||
[self updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
@@ -725,7 +729,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
{
|
||||
NSError *error;
|
||||
if ([chapters updateFromCSVFile:URL error:&error]) {
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
[self reloadPropertyView];
|
||||
[self updateChangeCount:NSChangeDone];
|
||||
}
|
||||
else {
|
||||
@@ -762,7 +766,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)showImportSheet:(NSArray *)fileURLs
|
||||
- (void)showImportSheet:(NSArray<NSURL *> *)fileURLs
|
||||
{
|
||||
NSError *error = nil;
|
||||
|
||||
@@ -770,7 +774,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
|
||||
if (importWindow) {
|
||||
if ([importWindow onlyContainsSubtitleTracks]) { //execute always. Maybe we should do this only for subtitle
|
||||
[importWindow addTracks:nil];
|
||||
[importWindow addTracks:self];
|
||||
[self didEndSheet:nil returnCode:NSOKButton contextInfo:nil];
|
||||
} else { // show the dialog
|
||||
[NSApp beginSheet:[importWindow window] modalForWindow:documentWindow
|
||||
@@ -781,15 +785,18 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
}
|
||||
}
|
||||
|
||||
- (void)importDoneWithTracks:(NSArray *)tracksToBeImported andMetadata:(MP42Metadata *)metadata
|
||||
- (void)importDoneWithTracks:(NSArray<MP42Track *> *)tracksToBeImported andMetadata:(MP42Metadata *)metadata
|
||||
{
|
||||
if (tracksToBeImported) {
|
||||
for (id track in tracksToBeImported)
|
||||
for (MP42Track *track in tracksToBeImported) {
|
||||
[self.mp4 addTrack:track];
|
||||
}
|
||||
|
||||
[self updateChangeCount:NSChangeDone];
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBOrganizeAlternateGroups"] boolValue])
|
||||
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBOrganizeAlternateGroups"] boolValue]) {
|
||||
[self.mp4 organizeAlternateGroups];
|
||||
}
|
||||
}
|
||||
|
||||
if (metadata) {
|
||||
@@ -813,7 +820,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
}
|
||||
}
|
||||
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
[self reloadPropertyView];
|
||||
[self updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
@@ -823,7 +830,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
panel.allowsMultipleSelection = NO;
|
||||
panel.canChooseFiles = YES;
|
||||
panel.canChooseDirectories = NO;
|
||||
[panel setAllowedFileTypes:[NSArray arrayWithObjects:@"mp4", @"m4v", @"m4a", @"xml", @"nfo", nil]];
|
||||
panel.allowedFileTypes = @[@"mp4", @"m4v", @"m4a", @"xml", @"nfo"];
|
||||
|
||||
[panel beginSheetModalForWindow:documentWindow completionHandler:^(NSInteger result) {
|
||||
if (result == NSFileHandlingPanelOKButton) {
|
||||
@@ -839,12 +846,12 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
NSString *filename = [[[[self fileURL] path] stringByDeletingPathExtension] lastPathComponent];
|
||||
|
||||
if (row != -1 && [[self.mp4 trackAtIndex:row] isKindOfClass:[MP42SubtitleTrack class]]) {
|
||||
[panel setAllowedFileTypes:[NSArray arrayWithObject: @"srt"]];
|
||||
panel.allowedFileTypes = @[@"srt"];
|
||||
filename = [filename stringByAppendingFormat:@".%@", [[self.mp4 trackAtIndex:row] language]];
|
||||
}
|
||||
else if (row != -1 ) {
|
||||
filename = [filename stringByAppendingString:@" - Chapters"];
|
||||
[panel setAllowedFileTypes:[NSArray arrayWithObject: @"txt"]];
|
||||
panel.allowedFileTypes = @[@"txt"];
|
||||
}
|
||||
|
||||
[panel setCanSelectHiddenExtension: YES];
|
||||
@@ -894,7 +901,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
duration:self.mp4.duration];
|
||||
|
||||
[fileTracksTable reloadData];
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
[self reloadPropertyView];
|
||||
[self updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
@@ -902,7 +909,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
{
|
||||
[self.mp4 organizeAlternateGroups];
|
||||
[fileTracksTable reloadData];
|
||||
[self tableViewSelectionDidChange:nil];
|
||||
[self reloadPropertyView];
|
||||
[self updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
@@ -924,23 +931,25 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
NSPasteboard *pboard = [sender draggingPasteboard];
|
||||
|
||||
if ( [[pboard types] containsObject:NSURLPboardType] ) {
|
||||
NSArray *items = [pboard readObjectsForClasses:
|
||||
[NSArray arrayWithObject: [NSURL class]] options: nil];
|
||||
NSMutableArray *supItems = [[[NSMutableArray alloc] init] autorelease];
|
||||
NSArray *items = [pboard readObjectsForClasses:@[[NSURL class]] options:nil];
|
||||
NSMutableArray<NSURL *> *supItems = [[[NSMutableArray alloc] init] autorelease];
|
||||
|
||||
for (NSURL *file in items) {
|
||||
if ([[file pathExtension] caseInsensitiveCompare: @"txt"] == NSOrderedSame)
|
||||
if ([[file pathExtension] caseInsensitiveCompare: @"txt"] == NSOrderedSame) {
|
||||
[self addChapterTrack:file];
|
||||
}
|
||||
else if ([[file pathExtension] caseInsensitiveCompare: @"xml"] == NSOrderedSame ||
|
||||
[[file pathExtension] caseInsensitiveCompare: @"nfo"] == NSOrderedSame)
|
||||
[[file pathExtension] caseInsensitiveCompare: @"nfo"] == NSOrderedSame) {
|
||||
[self addMetadata:file];
|
||||
}
|
||||
else if (isFileFormatSupported([file pathExtension])) {
|
||||
[supItems addObject:file];
|
||||
}
|
||||
}
|
||||
|
||||
if ([supItems count])
|
||||
if (supItems.count) {
|
||||
[self showImportSheet:supItems];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MP42Metadata;
|
||||
|
||||
@protocol SBFileImportDelegate
|
||||
@@ -40,3 +42,5 @@
|
||||
- (IBAction)uncheckSelected:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -358,8 +358,9 @@
|
||||
|
||||
- (IBAction)addTracks:(id)sender
|
||||
{
|
||||
if (!_actionArray) // if add tracks is called directly, need to prepare actions
|
||||
if (!_actionArray) { // if add tracks is called directly, need to prepare actions
|
||||
[self _prepareActionArray];
|
||||
}
|
||||
|
||||
NSMutableArray *tracks = [[NSMutableArray alloc] init];
|
||||
NSInteger i = 0;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SBQueueItem;
|
||||
|
||||
@protocol SBItemViewDelegate <NSObject>
|
||||
@@ -28,8 +30,10 @@
|
||||
}
|
||||
|
||||
@property (nonatomic, readonly) SBQueueItem *item;
|
||||
@property (nonatomic, assign, readwrite) id delegate;
|
||||
@property (nonatomic, assign, readwrite) id<SBItemViewDelegate> delegate;
|
||||
|
||||
- (instancetype)initWithItem:(SBQueueItem *)item;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SBTableView;
|
||||
@class SBArtworkSelector;
|
||||
|
||||
@@ -66,3 +68,5 @@
|
||||
+ (void) deleteCachedMetadata;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SBOptionsViewController : NSViewController {
|
||||
@private
|
||||
IBOutlet NSPopUpButton *_destButton;
|
||||
@@ -26,3 +28,5 @@
|
||||
- (instancetype)initWithOptions:(NSMutableDictionary *)options;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -37,8 +37,9 @@
|
||||
@"SBAudioMixdown": @"1",
|
||||
@"SBAudioBitrate": @"96",
|
||||
@"SBAudioConvertAC3": @"YES",
|
||||
@"SBAudioDtsPassthrough": @"NO",
|
||||
@"SBAudioKeepAC3": @"YES",
|
||||
@"SBAudioConvertDts": @"YES",
|
||||
@"SBAudioKeepDTS": @"NO",
|
||||
@"SBSubtitleConvertBitmap": @"YES",
|
||||
@"SBRatingsCountry": @"All countries",
|
||||
@"SBSaveFormat": @"m4v",
|
||||
|
||||
@@ -8,13 +8,15 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MP42Metadata;
|
||||
|
||||
extern NSString *SBPresetManagerUpdatedNotification;
|
||||
|
||||
@interface SBPresetManager : NSObject {
|
||||
@private
|
||||
NSMutableArray *_presets;
|
||||
NSMutableArray<MP42Metadata *> *_presets;
|
||||
}
|
||||
|
||||
+ (SBPresetManager *)sharedManager;
|
||||
@@ -25,6 +27,8 @@ extern NSString *SBPresetManagerUpdatedNotification;
|
||||
- (MP42Metadata *)setWithName:(NSString *)name;
|
||||
- (BOOL)removePresetAtIndex:(NSUInteger)index;
|
||||
|
||||
@property(readonly) NSArray *presets;
|
||||
@property(readonly) NSArray<MP42Metadata *> *presets;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+18
-13
@@ -22,6 +22,8 @@ NSString *SBPresetManagerUpdatedNotification = @"SBPresetManagerUpdatedNotificat
|
||||
|
||||
@implementation SBPresetManager
|
||||
|
||||
@synthesize presets = _presets;
|
||||
|
||||
+ (SBPresetManager *)sharedManager
|
||||
{
|
||||
static dispatch_once_t pred;
|
||||
@@ -31,8 +33,9 @@ NSString *SBPresetManagerUpdatedNotification = @"SBPresetManagerUpdatedNotificat
|
||||
return sharedPresetManager;
|
||||
}
|
||||
|
||||
- (id)init {
|
||||
if ((self = [super init])) {
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_presets = [[NSMutableArray alloc] init];
|
||||
|
||||
[self loadPresets];
|
||||
@@ -48,7 +51,7 @@ NSString *SBPresetManagerUpdatedNotification = @"SBPresetManagerUpdatedNotificat
|
||||
|
||||
- (void)newSetFromExistingMetadata:(MP42Metadata *)set
|
||||
{
|
||||
id newSet = [set copy];
|
||||
MP42Metadata *newSet = [set copy];
|
||||
[_presets addObject:newSet];
|
||||
[newSet release];
|
||||
|
||||
@@ -71,8 +74,9 @@ NSString *SBPresetManagerUpdatedNotification = @"SBPresetManagerUpdatedNotificat
|
||||
NSString *appSupportPath = [self appSupportPath];
|
||||
MP42Metadata *newPreset;
|
||||
|
||||
if (!appSupportPath)
|
||||
if (!appSupportPath) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSDirectoryEnumerator *dirEnum = [fileManager enumeratorAtPath:appSupportPath];
|
||||
while ((file = [dirEnum nextObject])) {
|
||||
@@ -89,10 +93,12 @@ NSString *SBPresetManagerUpdatedNotification = @"SBPresetManagerUpdatedNotificat
|
||||
}
|
||||
}
|
||||
|
||||
if (![_presets count])
|
||||
if (!_presets.count) {
|
||||
return NO;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)savePresets
|
||||
@@ -101,12 +107,13 @@ NSString *SBPresetManagerUpdatedNotification = @"SBPresetManagerUpdatedNotificat
|
||||
NSString *appSupportPath = [self appSupportPath];
|
||||
BOOL noErr = YES;
|
||||
|
||||
|
||||
if (!appSupportPath)
|
||||
if (!appSupportPath) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![fileManager fileExistsAtPath:appSupportPath])
|
||||
if (![fileManager fileExistsAtPath:appSupportPath]) {
|
||||
[fileManager createDirectoryAtPath:appSupportPath withIntermediateDirectories:noErr attributes:nil error:NULL];
|
||||
}
|
||||
|
||||
for (MP42Metadata *object in _presets) {
|
||||
if ([object isEdited]) {
|
||||
@@ -137,14 +144,14 @@ NSString *SBPresetManagerUpdatedNotification = @"SBPresetManagerUpdatedNotificat
|
||||
return [self removePresetWithName:name];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)removePresetWithName:(NSString *)name
|
||||
{
|
||||
BOOL err = NO;
|
||||
NSString *appSupportPath = [self appSupportPath];
|
||||
|
||||
if (!appSupportPath)
|
||||
if (!appSupportPath) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
err = [fileManager removeItemAtPath:[NSString stringWithFormat:@"%@/%@.sbpreset", appSupportPath, name]
|
||||
@@ -153,6 +160,4 @@ NSString *SBPresetManagerUpdatedNotification = @"SBPresetManagerUpdatedNotificat
|
||||
return err;
|
||||
}
|
||||
|
||||
@synthesize presets = _presets;
|
||||
|
||||
@end
|
||||
+6
-1
@@ -11,6 +11,8 @@
|
||||
|
||||
#import "SBQueueItem.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SBQueueStatus) {
|
||||
SBQueueStatusUnknown = 0,
|
||||
SBQueueStatusWorking,
|
||||
@@ -57,7 +59,7 @@ extern NSString *SBQueueCancelledNotification;
|
||||
- (SBQueueItem *)itemAtIndex:(NSUInteger)index;
|
||||
- (NSUInteger)indexOfItem:(SBQueueItem *)item;
|
||||
- (NSIndexSet *)indexesOfItemsWithStatus:(SBQueueItemStatus)status;
|
||||
- (NSArray *)itemsAtIndexes:(NSIndexSet *)indexes;
|
||||
- (NSArray<SBQueueItem *> *)itemsAtIndexes:(NSIndexSet *)indexes;
|
||||
|
||||
- (void)insertItem:(SBQueueItem *)anItem atIndex:(NSUInteger)index;
|
||||
|
||||
@@ -69,3 +71,6 @@ extern NSString *SBQueueCancelledNotification;
|
||||
- (BOOL)saveQueueToDisk;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
@class SBQueueItem;
|
||||
@class MP42Metadata;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* SBQueue actions protocol, actions can be run by
|
||||
* the queue's items.
|
||||
@@ -57,3 +59,5 @@
|
||||
*/
|
||||
@interface SBQueueOrganizeGroupsAction : NSObject <SBQueueActionProtocol>
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -7,9 +7,10 @@
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "SBQueue.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SBQueueItem;
|
||||
@class SBOptionsViewController;
|
||||
@class SBQueuePreferences;
|
||||
@@ -51,3 +52,5 @@
|
||||
- (BOOL)saveQueueToDisk;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+31
-18
@@ -22,7 +22,7 @@ static void *SBQueueContex = &SBQueueContex;
|
||||
|
||||
#define SublerBatchTableViewDataType @"SublerBatchTableViewDataType"
|
||||
|
||||
@interface SBQueueController () <NSPopoverDelegate, NSWindowDelegate, NSTableViewDelegate, NSTableViewDataSource, SBTableViewDelegate>
|
||||
@interface SBQueueController () <NSPopoverDelegate, NSWindowDelegate, NSTableViewDelegate, NSTableViewDataSource, SBTableViewDelegate, SBItemViewDelegate>
|
||||
|
||||
@property (nonatomic, readonly) SBQueue *queue;
|
||||
@property (nonatomic, retain) NSPopover *popover;
|
||||
@@ -64,7 +64,7 @@ static void *SBQueueContex = &SBQueueContex;
|
||||
return sharedManager;
|
||||
}
|
||||
|
||||
- (id)init {
|
||||
- (instancetype)init {
|
||||
if (self = [super initWithWindowNibName:@"Queue"]) {
|
||||
[SBQueuePreferences registerUserDefaults];
|
||||
_prefs = [[SBQueuePreferences alloc] init];
|
||||
@@ -185,14 +185,14 @@ static void *SBQueueContex = &SBQueueContex;
|
||||
|
||||
#pragma mark - Queue methods
|
||||
|
||||
/*
|
||||
/**
|
||||
* The queue status
|
||||
*/
|
||||
- (SBQueueStatus)status {
|
||||
return self.queue.status;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Saves the queue and the user defaults.
|
||||
*/
|
||||
- (BOOL)saveQueueToDisk {
|
||||
@@ -200,7 +200,7 @@ static void *SBQueueContex = &SBQueueContex;
|
||||
return [self.queue saveQueueToDisk];
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Opens a SBQueueItem in a new document window
|
||||
* and removes it from the queue.
|
||||
*/
|
||||
@@ -209,21 +209,34 @@ static void *SBQueueContex = &SBQueueContex;
|
||||
[self updateUI];
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
if (!item.mp4File)
|
||||
[item prepare:NULL];
|
||||
__block NSError *error;
|
||||
BOOL result = NO;
|
||||
|
||||
if (!item.mp4File) {
|
||||
result = [item prepare:&error];
|
||||
if (result == NO) {
|
||||
NSLog(@"%@", error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MP42File *mp4 = item.mp4File;
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
SBDocument *doc = [[SBDocument alloc] initWithMP4:mp4 error:NULL];
|
||||
[[NSDocumentController sharedDocumentController] addDocument:doc];
|
||||
[doc makeWindowControllers];
|
||||
[doc showWindows];
|
||||
[doc release];
|
||||
SBDocument *doc = [[SBDocument alloc] initWithMP4:mp4 error:&error];
|
||||
|
||||
[self.itemPopover close];
|
||||
if (doc) {
|
||||
[[NSDocumentController sharedDocumentController] addDocument:doc];
|
||||
[doc makeWindowControllers];
|
||||
[doc showWindows];
|
||||
[doc release];
|
||||
|
||||
[self removeItems:[NSArray arrayWithObject:item]];
|
||||
[self updateUI];
|
||||
[self.itemPopover close];
|
||||
|
||||
[self removeItems:[NSArray arrayWithObject:item]];
|
||||
[self updateUI];
|
||||
} else {
|
||||
NSLog(@"%@", error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -345,7 +358,7 @@ static void *SBQueueContex = &SBQueueContex;
|
||||
|
||||
#pragma mark - NSPopover delegate
|
||||
|
||||
/*
|
||||
/**
|
||||
* Creates a popover with the queue options.
|
||||
*/
|
||||
- (void)createOptionsPopover {
|
||||
@@ -378,7 +391,7 @@ static void *SBQueueContex = &SBQueueContex;
|
||||
return _detachedWindow;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Creates a popover with a SBQueueItem
|
||||
*/
|
||||
- (void)createItemPopover:(SBQueueItem *)item {
|
||||
@@ -440,7 +453,7 @@ static void *SBQueueContex = &SBQueueContex;
|
||||
|
||||
#pragma mark - UI methods
|
||||
|
||||
/*
|
||||
/**
|
||||
* Updates the count on the app dock icon.
|
||||
*/
|
||||
- (void)updateDockTile {
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
@class MP42File;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef enum SBQueueItemStatus : NSInteger {
|
||||
SBQueueItemStatusUnknown = 0,
|
||||
SBQueueItemStatusReady,
|
||||
@@ -38,9 +40,9 @@ typedef enum SBQueueItemStatus : NSInteger {
|
||||
}
|
||||
|
||||
@property (nonatomic, readwrite) SBQueueItemStatus status;
|
||||
@property (nonatomic, readonly) NSString *localizedWorkingDescription;
|
||||
@property (nonatomic, readonly, nullable) NSString *localizedWorkingDescription;
|
||||
|
||||
@property (nonatomic, readonly) MP42File *mp4File;
|
||||
@property (nonatomic, readonly, nullable) MP42File *mp4File;
|
||||
|
||||
@property (nonatomic, readonly) NSURL *URL;
|
||||
@property (nonatomic, copy) NSURL *destURL;
|
||||
@@ -48,7 +50,7 @@ typedef enum SBQueueItemStatus : NSInteger {
|
||||
@property (nonatomic, readonly) NSArray *actions;
|
||||
@property (nonatomic, readonly) NSDictionary *attributes;
|
||||
|
||||
@property (nonatomic, assign) id delegate;
|
||||
@property (nonatomic, assign, nullable) id delegate;
|
||||
|
||||
+ (instancetype)itemWithURL:(NSURL *)URL;
|
||||
|
||||
@@ -63,3 +65,5 @@ typedef enum SBQueueItemStatus : NSInteger {
|
||||
- (void)cancel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+11
-10
@@ -205,9 +205,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
// DTS -> always convert.
|
||||
// DTS -> convert only if specified in the prefs.
|
||||
if ([track.format isEqualToString:MP42AudioFormatDTS]) {
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioDtsPassthrough"] boolValue]) {
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioConvertDts"] boolValue]) {
|
||||
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"SBAudioKeepDts"] boolValue]) {
|
||||
MP42AudioTrack *copy = [track copy];
|
||||
copy.needConversion = YES;
|
||||
copy.mixdownType = SBDolbyPlIIMixdown;
|
||||
@@ -215,20 +216,19 @@
|
||||
[self.mp4File addTrack:copy];
|
||||
|
||||
[copy release];
|
||||
}
|
||||
else {
|
||||
track.needConversion = YES;
|
||||
}
|
||||
else {
|
||||
track.needConversion = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// VobSub -> only if specified in the prefs.
|
||||
if (([track.format isEqualToString:MP42SubtitleFormatVobSub] && [[[NSUserDefaults standardUserDefaults] valueForKey:@"SBSubtitleConvertBitmap"] boolValue]))
|
||||
track.needConversion = YES;
|
||||
|
||||
// If an audio track needs to be converted, apply the mixdown from the preferences.
|
||||
if ([track isMemberOfClass:[MP42AudioTrack class]] && track.needConversion)
|
||||
{
|
||||
if ([track isMemberOfClass:[MP42AudioTrack class]] && track.needConversion) {
|
||||
NSInteger mixdown = [[[NSUserDefaults standardUserDefaults]
|
||||
valueForKey:@"SBAudioMixdown"] integerValue];
|
||||
MP42AudioTrack *audioTrack = (MP42AudioTrack *)track;
|
||||
@@ -252,8 +252,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (isTrackMuxable(track.format) || trackNeedConversion(track.format))
|
||||
if (isTrackMuxable(track.format) || trackNeedConversion(track.format)) {
|
||||
[self.mp4File addTrack:track];
|
||||
}
|
||||
}
|
||||
[fileImporter release];
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern NSString * const SBQueueFileType;
|
||||
extern NSString * const SBQueueOrganize;
|
||||
extern NSString * const SBQueueMetadata;
|
||||
@@ -36,3 +38,5 @@ extern NSString * const SBQueueDestination;
|
||||
- (void)saveUserDefaults;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Reference in new issue
Block a user