private void fetchMetadata(AVAsset asset, ref LibraryItem libraryItem) { if (libraryItem != null) { //Common metadata libraryItem.IsLocal = true; libraryItem.SmallThumbnailData = libraryItem.LargeThumbnailData = fetchThumbnailData(asset); libraryItem.Title = fetchStringMetadata(asset.CommonMetadata, AVMetadata.CommonKeyTitle, AVMetadata.KeySpaceCommon); libraryItem.Duration = (long)asset.Duration.Seconds * 1000; libraryItem.Description = fetchStringMetadata(asset.MetadataForFormat("com.apple.itunes"), NSObject.FromObject("©cmt"), AVMetadata.KeySpaceiTunes); libraryItem.Series = fetchStringMetadata(asset.MetadataForFormat("com.apple.itunes"), NSObject.FromObject("tvsh"), AVMetadata.KeySpaceiTunes); libraryItem.Season = fetchStringMetadata(asset.MetadataForFormat("com.apple.itunes"), NSObject.FromObject("tvsn"), AVMetadata.KeySpaceiTunes); libraryItem.Episode = fetchStringMetadata(asset.MetadataForFormat("com.apple.itunes"), NSObject.FromObject("tves"), AVMetadata.KeySpaceiTunes); libraryItem.AirDate = fetchStringMetadata(asset.Metadata, NSObject.FromObject("com.apple.iTunes.AirDate"), "itlk"); libraryItem.BrowsePath = fetchStringMetadata(asset.Metadata, NSObject.FromObject("com.apple.iTunes.Browsepath"), "itlk"); DateTime recordedDate; if (DateTime.TryParse(fetchStringMetadata(asset.Metadata, NSObject.FromObject("com.apple.iTunes.RecordingTimestamp"), "itlk"), out recordedDate)) { libraryItem.Recorded = recordedDate; } //Chapters string hasChapters = fetchStringMetadata(asset.Metadata, NSObject.FromObject("com.apple.iTunes.HasChapters"), "itlk"); if (!string.IsNullOrEmpty(hasChapters) && (hasChapters == "1")) { libraryItem.HasChapters = true; libraryItem.Chapters = fetchChapters(asset); } if (!string.IsNullOrEmpty(libraryItem.LocalFilePath) && File.Exists(libraryItem.LocalFilePath)) { libraryItem.Updated = File.GetLastWriteTime(libraryItem.LocalFilePath); } } }