| 1 | // |
|---|
| 2 | // SapphireMetaData.h |
|---|
| 3 | // Sapphire |
|---|
| 4 | // |
|---|
| 5 | // Created by Graham Booker on 6/22/07. |
|---|
| 6 | // Copyright 2007 www.nanopi.net. All rights reserved. |
|---|
| 7 | // |
|---|
| 8 | |
|---|
| 9 | #import <Cocoa/Cocoa.h> |
|---|
| 10 | #import "SapphirePredicates.h" |
|---|
| 11 | |
|---|
| 12 | #define META_TVRAGE_IMPORT_KEY @"TVRage Source" |
|---|
| 13 | #define META_IMDB_IMPORT_KEY @"IMDB Source" |
|---|
| 14 | #define META_POSTER_IMPORT_KEY @"Poster Source" |
|---|
| 15 | #define META_XML_IMPORT_KEY @"XML Source" |
|---|
| 16 | |
|---|
| 17 | //TV Show Specific Keys |
|---|
| 18 | #define META_TITLE_KEY @"Title" |
|---|
| 19 | #define META_SEASON_NUMBER_KEY @"Season" |
|---|
| 20 | #define META_EPISODE_NUMBER_KEY @"Episode" |
|---|
| 21 | #define META_SHOW_NAME_KEY @"Show Name" |
|---|
| 22 | #define META_DESCRIPTION_KEY @"Show Description" |
|---|
| 23 | #define META_SHOW_AIR_DATE @"Air Date" |
|---|
| 24 | #define META_RATING_KEY @"Rating" |
|---|
| 25 | #define META_SUMMARY_KEY @"Summary" |
|---|
| 26 | #define META_ABSOLUTE_EP_NUMBER_KEY @"Episode Number" |
|---|
| 27 | #define META_SHOW_IDENTIFIER_KEY @"Show ID" |
|---|
| 28 | |
|---|
| 29 | //ATV Extra Info |
|---|
| 30 | #define META_SHOW_BROADCASTER_KEY @"Broadcast Company" |
|---|
| 31 | #define META_SHOW_PUBLISHED_DATE_KEY @"Published Date" |
|---|
| 32 | #define META_SHOW_AQUIRED_DATE @"Date Aquired" |
|---|
| 33 | #define META_SHOW_RATING_KEY @"Rating" |
|---|
| 34 | #define META_SHOW_FAVORITE_RATING_KEY @"User Rating" |
|---|
| 35 | #define META_COPYRIGHT_KEY @"Copyright" |
|---|
| 36 | |
|---|
| 37 | //IMDB Type Info |
|---|
| 38 | #define META_MOVIE_TITLE_KEY @"Title" |
|---|
| 39 | #define META_MOVIE_CAST_KEY @"Cast" |
|---|
| 40 | #define META_MOVIE_RELEASE_DATE_KEY @"Release Date" |
|---|
| 41 | #define META_MOVIE_DIRECTOR_KEY @"Director" |
|---|
| 42 | #define META_MOVIE_WIRTERS_KEY @"Writers" |
|---|
| 43 | #define META_MOVIE_GENRES_KEY @"Genres" |
|---|
| 44 | #define META_MOVIE_PLOT_KEY @"Plot" |
|---|
| 45 | |
|---|
| 46 | //Special Display Only Info |
|---|
| 47 | #define META_EPISODE_AND_SEASON_KEY @"S/E" |
|---|
| 48 | |
|---|
| 49 | #define META_DATA_FILE_ADDED_NOTIFICATION @"MetaDataFileAdded" |
|---|
| 50 | #define META_DATA_FILE_REMOVED_NOTIFICATION @"MetaDataFileRemoved" |
|---|
| 51 | #define META_DATA_FILE_INFO_WILL_CHANGE_NOTIFICATION @"MetaDataFileInfoWillChange" |
|---|
| 52 | #define META_DATA_FILE_INFO_HAS_CHANGED_NOTIFICATION @"MetaDataFileInfoHasChanged" |
|---|
| 53 | #define META_DATA_FILE_INFO_KIND @"MetaDataFileInfoKind" |
|---|
| 54 | |
|---|
| 55 | #define FILE_CLASS_KEY @"File Class" |
|---|
| 56 | typedef enum { |
|---|
| 57 | FILE_CLASS_NOT_FILE= -1, |
|---|
| 58 | FILE_CLASS_UNKNOWN = 0, |
|---|
| 59 | FILE_CLASS_TV_SHOW = 1, |
|---|
| 60 | FILE_CLASS_MOVIE = 2, |
|---|
| 61 | FILE_CLASS_AUDIO = 3, |
|---|
| 62 | FILE_CLASS_IMAGE = 4, |
|---|
| 63 | FILE_CLASS_OTHER = 5, |
|---|
| 64 | } FileClass; |
|---|
| 65 | |
|---|
| 66 | @class SapphireMetaData, SapphireMetaDataCollection, SapphireFileMetaData, SapphireDirectoryMetaData; |
|---|
| 67 | |
|---|
| 68 | @protocol SapphireMetaDataDelegate <NSObject> |
|---|
| 69 | - (void)updateCompleteForFile:(NSString *)file; |
|---|
| 70 | @end |
|---|
| 71 | |
|---|
| 72 | @protocol SapphireMetaDataScannerDelegate <NSObject> |
|---|
| 73 | - (void)gotSubFiles:(NSArray *)subs; |
|---|
| 74 | - (void)scanningDir:(NSString *)dir; |
|---|
| 75 | - (BOOL)getSubFilesCanceled; |
|---|
| 76 | @end |
|---|
| 77 | |
|---|
| 78 | @interface SapphireMetaData : NSObject { |
|---|
| 79 | NSMutableDictionary *metaData; |
|---|
| 80 | SapphireMetaData *parent; |
|---|
| 81 | /* These two are not retained */ |
|---|
| 82 | NSString *path; |
|---|
| 83 | id <SapphireMetaDataDelegate> delegate; |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | + (NSSet *)videoExtensions; |
|---|
| 87 | + (NSSet *)audioExtensions; |
|---|
| 88 | - (NSString *)path; |
|---|
| 89 | |
|---|
| 90 | - (void)setDelegate:(id <SapphireMetaDataDelegate>)newDelegate; |
|---|
| 91 | - (void)writeMetaData; |
|---|
| 92 | - (SapphireMetaDataCollection *)collection; |
|---|
| 93 | - (NSMutableDictionary *)getDisplayedMetaDataInOrder:(NSArray * *)order; |
|---|
| 94 | |
|---|
| 95 | @end |
|---|
| 96 | |
|---|
| 97 | @interface SapphireMetaDataCollection : SapphireMetaData { |
|---|
| 98 | NSMutableDictionary *directories; |
|---|
| 99 | NSMutableDictionary *skipCollection; |
|---|
| 100 | NSMutableDictionary *hideCollection; |
|---|
| 101 | NSString *dictionaryPath; |
|---|
| 102 | NSTimer *writeTimer; |
|---|
| 103 | } |
|---|
| 104 | - (id)initWithFile:(NSString *)dictionary; |
|---|
| 105 | - (SapphireMetaData *)dataForPath:(NSString *)path; |
|---|
| 106 | - (SapphireDirectoryMetaData *)directoryForPath:(NSString *)path; |
|---|
| 107 | - (SapphireMetaData *)dataForPath:(NSString *)path withData:(NSDictionary *)data; |
|---|
| 108 | - (NSArray *)collectionDirectories; |
|---|
| 109 | - (BOOL)hideCollection:(NSString *)collection; |
|---|
| 110 | - (void)setHide:(BOOL)hide forCollection:(NSString *)collection; |
|---|
| 111 | - (BOOL)skipCollection:(NSString *)collection; |
|---|
| 112 | - (void)setSkip:(BOOL)skip forCollection:(NSString *)collection; |
|---|
| 113 | |
|---|
| 114 | @end |
|---|
| 115 | |
|---|
| 116 | @interface SapphireDirectoryMetaData : SapphireMetaData { |
|---|
| 117 | /*These two are not retained*/ |
|---|
| 118 | NSMutableDictionary *metaFiles; |
|---|
| 119 | NSMutableDictionary *metaDirs; |
|---|
| 120 | |
|---|
| 121 | NSMutableDictionary *cachedMetaFiles; |
|---|
| 122 | NSMutableDictionary *cachedMetaDirs; |
|---|
| 123 | |
|---|
| 124 | NSMutableArray *files; |
|---|
| 125 | NSMutableArray *directories; |
|---|
| 126 | |
|---|
| 127 | NSTimer *importTimer; |
|---|
| 128 | NSMutableArray *importArray; |
|---|
| 129 | BOOL scannedDirectory; |
|---|
| 130 | |
|---|
| 131 | /*This is not retained*/ |
|---|
| 132 | SapphireMetaDataCollection *collection; |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | - (void)reloadDirectoryContents; |
|---|
| 136 | - (NSArray *)files; |
|---|
| 137 | - (NSArray *)directories; |
|---|
| 138 | - (NSArray *)predicatedFiles:(SapphirePredicate *)predicate; |
|---|
| 139 | - (NSArray *)predicatedDirectories:(SapphirePredicate *)predicate; |
|---|
| 140 | |
|---|
| 141 | - (SapphireFileMetaData *)metaDataForFile:(NSString *)file; |
|---|
| 142 | - (SapphireDirectoryMetaData *)metaDataForDirectory:(NSString *)dir; |
|---|
| 143 | |
|---|
| 144 | - (BOOL)pruneMetaData; |
|---|
| 145 | - (BOOL)updateMetaData; |
|---|
| 146 | |
|---|
| 147 | - (void)cancelImport; |
|---|
| 148 | - (void)resumeImport; |
|---|
| 149 | - (void)resumeDelayedImport; |
|---|
| 150 | |
|---|
| 151 | - (SapphireMetaData *)metaDataForSubPath:(NSString *)path; |
|---|
| 152 | - (void)getSubFileMetasWithDelegate:(id <SapphireMetaDataScannerDelegate>)subDelegate skipDirectories:(NSMutableSet *)skip; |
|---|
| 153 | - (void)scanForNewFilesWithDelegate:(id <SapphireMetaDataScannerDelegate>)subDelegate skipDirectories:(NSMutableSet *)skip; |
|---|
| 154 | - (void)loadMetaData; |
|---|
| 155 | |
|---|
| 156 | - (BOOL)watchedForPredicate:(SapphirePredicate *)predicate; |
|---|
| 157 | - (void)setWatched:(BOOL)watched forPredicate:(SapphirePredicate *)predicate; |
|---|
| 158 | - (BOOL)favoriteForPredicate:(SapphirePredicate *)predicate; |
|---|
| 159 | - (void)setFavorite:(BOOL)favorite forPredicate:(SapphirePredicate *)predicate; |
|---|
| 160 | - (void)setToImportFromSource:(NSString *)source forPredicate:(SapphirePredicate *)predicate; |
|---|
| 161 | - (void)setFileClass:(FileClass)fileClass forPredicate:(SapphirePredicate *)predicate; |
|---|
| 162 | |
|---|
| 163 | @end |
|---|
| 164 | |
|---|
| 165 | @interface SapphireFileMetaData : SapphireMetaData { |
|---|
| 166 | NSDictionary *combinedInfo; |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | - (BOOL) updateMetaData; |
|---|
| 170 | |
|---|
| 171 | - (int)modified; |
|---|
| 172 | - (BOOL)watched; |
|---|
| 173 | - (void)setWatched:(BOOL)watched; |
|---|
| 174 | - (BOOL)favorite; |
|---|
| 175 | - (void)setFavorite:(BOOL)favorite; |
|---|
| 176 | - (long)importedTimeFromSource:(NSString *)source; |
|---|
| 177 | - (void)setToImportFromSource:(NSString *)source; |
|---|
| 178 | - (void)importInfo:(NSMutableDictionary *)newMeta fromSource:(NSString *)source withTime:(long)modTime; |
|---|
| 179 | - (unsigned int)resumeTime; |
|---|
| 180 | - (void)setResumeTime:(unsigned int)resumeTime; |
|---|
| 181 | - (FileClass)fileClass; |
|---|
| 182 | - (void)setFileClass:(FileClass)fileClass; |
|---|
| 183 | |
|---|
| 184 | - (long long)size; |
|---|
| 185 | - (float)duration; |
|---|
| 186 | - (Float64)sampleRate; |
|---|
| 187 | - (UInt32)audioFormatID; |
|---|
| 188 | - (BOOL)hasVideo; |
|---|
| 189 | - (int)episodeNumber; |
|---|
| 190 | - (int)seasonNumber; |
|---|
| 191 | - (NSString *)episodeTitle; |
|---|
| 192 | - (NSString *)movieTitle; |
|---|
| 193 | - (NSString *)showID; |
|---|
| 194 | - (NSString *)showName ; |
|---|
| 195 | - (NSString *)sizeString; |
|---|
| 196 | |
|---|
| 197 | @end |
|---|