| 1 | #import "_SapphireFileMetaData.h" |
|---|
| 2 | |
|---|
| 3 | #define SapphireFileMetaDataName @"FileMetaData" |
|---|
| 4 | |
|---|
| 5 | //ATV Extra Info |
|---|
| 6 | extern NSString *META_SHOW_BROADCASTER_KEY; |
|---|
| 7 | extern NSString *META_SHOW_PUBLISHED_DATE_KEY; |
|---|
| 8 | extern NSString *META_SHOW_AQUIRED_DATE; |
|---|
| 9 | extern NSString *META_SHOW_RATING_KEY; |
|---|
| 10 | extern NSString *META_SHOW_FAVORITE_RATING_KEY; |
|---|
| 11 | extern NSString *META_COPYRIGHT_KEY; |
|---|
| 12 | |
|---|
| 13 | //IMDB Type Info |
|---|
| 14 | extern NSString *META_MOVIE_TITLE_KEY; |
|---|
| 15 | extern NSString *META_MOVIE_CAST_KEY; |
|---|
| 16 | extern NSString *META_MOVIE_RELEASE_DATE_KEY; |
|---|
| 17 | extern NSString *META_MOVIE_DIRECTOR_KEY; |
|---|
| 18 | extern NSString *META_MOVIE_WIRTERS_KEY; |
|---|
| 19 | extern NSString *META_MOVIE_GENRES_KEY; |
|---|
| 20 | extern NSString *META_MOVIE_PLOT_KEY; |
|---|
| 21 | extern NSString *META_MOVIE_IMDB_RATING_KEY; |
|---|
| 22 | extern NSString *META_MOVIE_IMDB_250_KEY; |
|---|
| 23 | extern NSString *META_MOVIE_MPAA_RATING_KEY; |
|---|
| 24 | extern NSString *META_MOVIE_OSCAR_KEY; |
|---|
| 25 | extern NSString *META_MOVIE_IDENTIFIER_KEY; |
|---|
| 26 | |
|---|
| 27 | //TV Show Specific Keys |
|---|
| 28 | extern NSString *META_TITLE_KEY; |
|---|
| 29 | extern NSString *META_SEASON_NUMBER_KEY; |
|---|
| 30 | extern NSString *META_EPISODE_NUMBER_KEY; |
|---|
| 31 | extern NSString *META_SHOW_NAME_KEY; |
|---|
| 32 | extern NSString *META_DESCRIPTION_KEY; |
|---|
| 33 | extern NSString *META_SHOW_AIR_DATE; |
|---|
| 34 | extern NSString *META_RATING_KEY; |
|---|
| 35 | extern NSString *META_SUMMARY_KEY; |
|---|
| 36 | extern NSString *META_ABSOLUTE_EP_NUMBER_KEY; |
|---|
| 37 | extern NSString *META_SHOW_IDENTIFIER_KEY; |
|---|
| 38 | extern NSString *META_EPISODE_2_NUMBER_KEY; |
|---|
| 39 | extern NSString *META_ABSOLUTE_EP_2_NUMBER_KEY; |
|---|
| 40 | extern NSString *META_SEARCH_SEASON_NUMBER_KEY; |
|---|
| 41 | extern NSString *META_SEARCH_EPISODE_NUMBER_KEY; |
|---|
| 42 | extern NSString *META_SEARCH_EPISODE_2_NUMBER_KEY; |
|---|
| 43 | extern NSString *FILE_CLASS_KEY; |
|---|
| 44 | |
|---|
| 45 | typedef enum { |
|---|
| 46 | IMPORT_TYPE_FILE_MASK = 1, |
|---|
| 47 | IMPORT_TYPE_XML_MASK = 2, |
|---|
| 48 | IMPORT_TYPE_TVSHOW_MASK = 4, |
|---|
| 49 | IMPORT_TYPE_MOVIE_MASK = 8, |
|---|
| 50 | IMPORT_TYPE_ALL_MASK = 0xf, |
|---|
| 51 | } ImportTypeMask; |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | typedef enum { |
|---|
| 55 | FILE_CLASS_UTILITY= -2, |
|---|
| 56 | FILE_CLASS_NOT_FILE= -1, |
|---|
| 57 | FILE_CLASS_UNKNOWN = 0, |
|---|
| 58 | FILE_CLASS_TV_SHOW = 1, |
|---|
| 59 | FILE_CLASS_MOVIE = 2, |
|---|
| 60 | FILE_CLASS_AUDIO = 3, |
|---|
| 61 | FILE_CLASS_IMAGE = 4, |
|---|
| 62 | FILE_CLASS_OTHER = 5, |
|---|
| 63 | } FileClass; |
|---|
| 64 | |
|---|
| 65 | typedef enum { |
|---|
| 66 | FILE_CONTAINER_TYPE_QT_MOVIE = 0, |
|---|
| 67 | FILE_CONTAINER_TYPE_VIDEO_TS = 1, |
|---|
| 68 | } FileContainerType; |
|---|
| 69 | |
|---|
| 70 | @class SapphireMetaDataUpgrading; |
|---|
| 71 | |
|---|
| 72 | @interface SapphireFileMetaData : _SapphireFileMetaData {} |
|---|
| 73 | + (SapphireFileMetaData *)fileWithPath:(NSString *)path inContext:(NSManagedObjectContext *)moc; |
|---|
| 74 | + (SapphireFileMetaData *)createFileWithPath:(NSString *)path inContext:(NSManagedObjectContext *)moc; |
|---|
| 75 | + (SapphireFileMetaData *)createFileWithPath:(NSString *)path parent:(SapphireDirectoryMetaData *)parent inContext:(NSManagedObjectContext *)moc; |
|---|
| 76 | + (NSDictionary *)upgradeV1FilesFromContext:(NSManagedObjectContext *)oldMoc toContext:(NSManagedObjectContext *)newMoc withMovies:(NSDictionary *)movieLookup directories:(NSDictionary *)dirLookup; |
|---|
| 77 | |
|---|
| 78 | - (void)insertDictionary:(NSDictionary *)dict withDefer:(NSMutableDictionary *)defer; |
|---|
| 79 | - (NSComparisonResult) episodeCompare:(SapphireFileMetaData *)other; |
|---|
| 80 | - (NSComparisonResult) movieCompare:(SapphireFileMetaData *)other; |
|---|
| 81 | |
|---|
| 82 | /*! |
|---|
| 83 | * @brief See if any files need to be updated |
|---|
| 84 | * |
|---|
| 85 | * This function determines that a file needs to be updated if its modification time does not match the time remembered in the persistent store. |
|---|
| 86 | * |
|---|
| 87 | * @return YES if any files need an update, NO otherwise |
|---|
| 88 | */ |
|---|
| 89 | - (BOOL) needsUpdating; |
|---|
| 90 | |
|---|
| 91 | /*! |
|---|
| 92 | * @brief Update any files that need to be updated |
|---|
| 93 | * |
|---|
| 94 | * This function determines that a file needs to be updated if its modification time does not match the time remembered in the persistent store. |
|---|
| 95 | * |
|---|
| 96 | * @return YES if any files were updated, NO otherwise |
|---|
| 97 | */ |
|---|
| 98 | - (BOOL)updateMetaData; |
|---|
| 99 | |
|---|
| 100 | /*! |
|---|
| 101 | * @brief Adds File data read from the file |
|---|
| 102 | * |
|---|
| 103 | * @param fileMeta The new file metadata. |
|---|
| 104 | */ |
|---|
| 105 | - (oneway void)addFileData:(bycopy NSDictionary *)fileMeta; |
|---|
| 106 | |
|---|
| 107 | /*! |
|---|
| 108 | * @brief Returns the imports we have done in the past |
|---|
| 109 | * |
|---|
| 110 | * @return A mask of imports done |
|---|
| 111 | */ |
|---|
| 112 | - (ImportTypeMask)importTypeValue; |
|---|
| 113 | |
|---|
| 114 | /*! |
|---|
| 115 | * @brief Sets the file has having done an import, usually with no data |
|---|
| 116 | * |
|---|
| 117 | * @param The type of import done |
|---|
| 118 | */ |
|---|
| 119 | - (void)didImportType:(ImportTypeMask)type; |
|---|
| 120 | |
|---|
| 121 | /*! |
|---|
| 122 | * @brief Returns the time of import from a source (file and xml only) |
|---|
| 123 | * |
|---|
| 124 | * @param source The source to check |
|---|
| 125 | * @return The seconds since 1970 of the import |
|---|
| 126 | */ |
|---|
| 127 | - (long)importedTimeFromSource:(int)source; |
|---|
| 128 | |
|---|
| 129 | /*! |
|---|
| 130 | * @brief Sets the file to re-import from some sources |
|---|
| 131 | * |
|---|
| 132 | * @param mask The sources to reimport on |
|---|
| 133 | */ |
|---|
| 134 | - (void)setToReimportFromMask:(int)mask; |
|---|
| 135 | |
|---|
| 136 | /*! |
|---|
| 137 | * @brief Reset import decisions for this file (also mark to re-import) |
|---|
| 138 | */ |
|---|
| 139 | - (void)setToResetImportDecisions; |
|---|
| 140 | |
|---|
| 141 | /*! |
|---|
| 142 | * @brief Get the overridden show name |
|---|
| 143 | * |
|---|
| 144 | * Sometimes TVRage's information is horribly wrong (such as Firefly) and it would be a pain to correct. This allows the user to provide a show name to override what is in the filename. |
|---|
| 145 | * |
|---|
| 146 | * @return the show name to use, nil if none exists |
|---|
| 147 | */ |
|---|
| 148 | - (NSString *)searchShowName; |
|---|
| 149 | |
|---|
| 150 | /*! |
|---|
| 151 | * @brief Get the overridden season number |
|---|
| 152 | * |
|---|
| 153 | * Sometimes TVRage's information is horribly wrong (such as Firefly) and it would be a pain to correct. This allows the user to provide a season number to override what is in the filename while not interferring with the number stored in the real season number. |
|---|
| 154 | * |
|---|
| 155 | * @return the season number to use, -1 if none exists |
|---|
| 156 | */ |
|---|
| 157 | - (int)searchSeasonNumber; |
|---|
| 158 | |
|---|
| 159 | /*! |
|---|
| 160 | * @brief Get the overridden episode number |
|---|
| 161 | * |
|---|
| 162 | * Sometimes TVRage's information is horribly wrong (such as Firefly) and it would be a pain to correct. This allows the user to provide a episode number to override what is in the filename while not interferring with the number stored in the real episode number. |
|---|
| 163 | * |
|---|
| 164 | * @return the episode number to use, -1 if none exists |
|---|
| 165 | */ |
|---|
| 166 | - (int)searchEpisodeNumber; |
|---|
| 167 | |
|---|
| 168 | /*! |
|---|
| 169 | * @brief Get the overridden second episode number |
|---|
| 170 | * |
|---|
| 171 | * Sometimes TVRage's information is horribly wrong (such as Firefly) and it would be a pain to correct. This allows the user to provide a second episode number to override what is in the filename while not interferring with the number stored in the real second episode number. |
|---|
| 172 | * |
|---|
| 173 | * @return the second episode number to use, -1 if none exists |
|---|
| 174 | */ |
|---|
| 175 | - (int)searchLastEpisodeNumber; |
|---|
| 176 | |
|---|
| 177 | /*! |
|---|
| 178 | * @brief Get the overridden IMDB number |
|---|
| 179 | * |
|---|
| 180 | * Sometimes IMDB can be a pain to search, or gives bad results. This allows the user to provide an IMDB number and let sapphire fetch the rest of the data. |
|---|
| 181 | * |
|---|
| 182 | * @return the IMDB number to use, -1 if none exists |
|---|
| 183 | */ |
|---|
| 184 | - (int)searchIMDBNumber; |
|---|
| 185 | |
|---|
| 186 | /*! |
|---|
| 187 | * @brief Returns the size as a string |
|---|
| 188 | * |
|---|
| 189 | * This will format the size in a human readable format. It uses strings like 2.1GB and the like. It always has one decimal number. |
|---|
| 190 | * |
|---|
| 191 | * @return The Size as a string. |
|---|
| 192 | */ |
|---|
| 193 | - (NSString *)sizeString; |
|---|
| 194 | |
|---|
| 195 | /*! |
|---|
| 196 | * @brief Clear the metadata |
|---|
| 197 | * |
|---|
| 198 | * Removes all metadata for this file. Useful if the user misidentified the file and wishes to start over on it. |
|---|
| 199 | */ |
|---|
| 200 | - (void)clearMetaData; |
|---|
| 201 | |
|---|
| 202 | /*! |
|---|
| 203 | * @brief Get the cover art Path |
|---|
| 204 | * |
|---|
| 205 | * Returns the cover art path. It will also examine up in the directory structure in order to find the cover art. It examines both the current directory, the "cover art" subdirectory, and the same for parent directories up to 2 levels. |
|---|
| 206 | * |
|---|
| 207 | * @return The path for the cover art, nil if none found |
|---|
| 208 | */ |
|---|
| 209 | - (NSString *)coverArtPath; |
|---|
| 210 | |
|---|
| 211 | /*! |
|---|
| 212 | * @brief Get the duration as a string |
|---|
| 213 | */ |
|---|
| 214 | - (NSString *)durationString; |
|---|
| 215 | |
|---|
| 216 | /*! |
|---|
| 217 | * @brief Moves a file to a new directory and updates metadata |
|---|
| 218 | * |
|---|
| 219 | * @param dir The new directory for the file |
|---|
| 220 | */ |
|---|
| 221 | - (NSString *)moveToDir:(SapphireDirectoryMetaData *)dir; |
|---|
| 222 | |
|---|
| 223 | @end |
|---|