Пример #1
0
        public static bool CanPlay(string path)
        {
            if (RunningOnExtender)
            {
                return(false);
            }
            if (configuredPlayers == null)
            {
                lock (lck)
                    if (configuredPlayers == null)
                    {
                        LoadConfig();
                    }
            }
            MediaType type = MediaTypeResolver.DetermineType(path);

            if (configuredPlayers.ContainsKey(type))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public override bool RefreshMetadata(MediaBrowser.Library.Metadata.MetadataRefreshOptions options)
        {
            if (RealMovie == null)
            {
                RealMovie = (Movie)Kernel.Instance.ItemRepository.RetrieveItem(RealMovieID);
            }
            MediaBrowser.Library.Logging.Logger.ReportInfo("Refreshing trailer for " + RealMovie.Name);
            this.PrimaryImagePath   = Util.CloneImage(RealMovie.PrimaryImagePath);
            this.BackdropImagePaths = new List <string>();
            if (RealMovie.BackdropImagePaths != null)
            {
                foreach (string backdrop in RealMovie.BackdropImagePaths)
                {
                    this.BackdropImagePaths.Add(backdrop);
                }
            }
            if ((options & MetadataRefreshOptions.Force) == MetadataRefreshOptions.Force)
            {
                var images = new List <MediaBrowser.Library.ImageManagement.LibraryImage>();
                images.Add(PrimaryImage);
                images.AddRange(BackdropImages);

                foreach (var image in images)
                {
                    try
                    {
                        if (image != null)
                        {
                            image.ClearLocalImages();
                            MediaBrowser.Library.Factories.LibraryImageFactory.Instance.ClearCache(image.Path);
                        }
                    }
                    catch (Exception ex)
                    {
                        MediaBrowser.Library.Logging.Logger.ReportException("Failed to clear local image (its probably in use)", ex);
                    }
                }
                //changed = RealMovie.RefreshMetadata(options);
            }


            this.Overview         = RealMovie.Overview;
            this.ProductionYear   = RealMovie.ProductionYear;
            this.RunningTime      = RealMovie.RunningTime;
            this.Actors           = RealMovie.Actors;
            this.Directors        = RealMovie.Directors;
            this.Name             = RealMovie.Name + " " + Plugin.PluginOptions.Instance.TrailerSuffix;
            this.SortName         = RealMovie.SortName;
            this.Studios          = RealMovie.Studios;
            this.Path             = RealMovie.TrailerFiles.First();
            this.MediaType        = MediaTypeResolver.DetermineType(Path);
            this.MediaInfo        = RealMovie.MediaInfo;
            this.DateCreated      = System.IO.File.GetCreationTime(this.Path);
            this.DisplayMediaType = "Trailer";
            Plugin.proxy.SetTrailerInfo(this);
            Kernel.Instance.ItemRepository.SaveItem(this);

            return(true);
        }
Пример #3
0
        /// <summary>
        /// Determines if a given external player configuration is configured to play a list of files
        /// </summary>
        public static bool CanPlay(ConfigData.ExternalPlayer player, IEnumerable <string> files)
        {
            IEnumerable <MediaType> types = files.Select(f => MediaTypeResolver.DetermineType(f));

            // See if there's a configured player matching the ExternalPlayerType and MediaType.
            // We're not able to evaluate VideoFormat in this scenario
            // If none is found it will return null
            return(CanPlay(player, types, new List <VideoFormat>(), files.Count() > 1));
        }
        public static bool IsVideo(string path)
        {
            MediaType type = MediaTypeResolver.DetermineType(path);

            // Assume video if type is not unknown
            if (type != MediaType.Unknown || Helper.IsVideo(path))
            {
                return(true);
            }

            return(false);
        }
Пример #5
0
 internal void RefreshProxy()
 {
     foreach (var item in ActualChildren)
     {
         var trailer = item as ITunesTrailer;
         if (trailer != null && Plugin.proxy != null)
         {
             trailer.Path      = Plugin.proxy.ProxyUrl(trailer);
             trailer.MediaType = MediaTypeResolver.DetermineType(trailer.Path);
             Kernel.Instance.ItemRepository.SaveItem(trailer);
         }
     }
 }
Пример #6
0
        //private DateTime startTime;
        protected override void PlayInternal(bool resume)
        {
            if (PlaybackController.IsPlaying)
            {
                PlaybackController.Stop(); //stop whatever is playing
            }
            //startTime = DateTime.Now; //grab this so we can attempt to determine how long we are playing the item
            //MediaBrowser.Library.Logging.Logger.ReportInfo("Playing external.  Duration: " + duration);
            MediaType type = MediaTypeResolver.DetermineType(path);

            ConfigData.ExternalPlayer p = configuredPlayers[type];
            string  args   = string.Format(p.Args, path);
            Process player = Process.Start(p.Command, args);

            Async.Queue("Ext Player Mgmt", () => ManageExtPlayer(player, p.MinimizeMCE, p.ShowSplashScreen));
        }
Пример #7
0
        protected override void PlayInternal(bool resume)
        {
            if (PlaybackController.IsPlaying)
            {
                PlaybackController.Pause();
            }


            MediaType type = MediaTypeResolver.DetermineType(path);

            ConfigData.ExternalPlayer p = configuredPlayers[type];
            string args = string.Format(p.Args, path);

            Process.Start(p.Command, args);
            MarkWatched();
        }
        /// <summary>
        /// Mounts an iso based Video and updates it's path
        /// </summary>
        private Media MountAndGetNewMedia(Video video)
        {
            string mountedPath = Application.CurrentInstance.MountISO(video.IsoFiles.First());

            // Clone it so we can modify some of it's properties
            Video clone = Serializer.Clone <Video>(video);

            clone.Path = mountedPath;

            clone.MediaType        = MediaTypeResolver.DetermineType(mountedPath);
            clone.DisplayMediaType = clone.MediaType.ToString();

            // Application.AddNewlyWatched requires this to be set
            clone.Parent = video.Parent;

            return(clone);
        }
        protected override List <BaseItem> GetNonCachedChildren()
        {
            //build our list of trailers
            var validChildren   = new List <BaseItem>();
            var actualMovieRefs = new List <string>();

            foreach (Folder folder in Kernel.Instance.RootFolder.Children)
            {
                if (folder != this && folder is Folder)
                {
                    foreach (BaseItem item in folder.AllRecursiveChildren)
                    {
                        if (item is Movie)
                        {
                            Movie movie = item as Movie;
                            if (movie.ContainsTrailers && !actualMovieRefs.Contains(movie.Path.ToLower()))
                            {
                                //create our movie item
                                MovieTrailer trailer = new MovieTrailer();
                                //now assign the id and fill in essentials - pointing to trailer as actual movie
                                trailer.Id          = ("MBTrailers.MovieTrailer" + movie.TrailerFiles.First().ToLower()).GetMD5();
                                trailer.RealMovieID = movie.Id;
                                trailer.Overview    = movie.Overview;
                                trailer.Genres      = movie.Genres;
                                trailer.MpaaRating  = movie.MpaaRating;
                                trailer.Path        = movie.TrailerFiles.First();
                                trailer.MediaType   = MediaTypeResolver.DetermineType(trailer.Path);
                                trailer.Parent      = this;
                                //and add to our children
                                validChildren.Add(trailer);
                                actualMovieRefs.Add(movie.Path.ToLower()); //we keep track so we don't get dups
                            }
                        }
                    }
                }
            }
            return(validChildren);
        }
 public static MediaType GetVideoMediaType(this IMediaLocation location)
 {
     return(MediaTypeResolver.DetermineType(location.Path));
 }
 /// <summary>
 /// Determines whether this PlayableItem can play a file
 /// </summary>
 public override bool CanPlay(string path)
 {
     return(CanPlay(MediaTypeResolver.DetermineType(path)));
 }
        public BaseItem GetItem(BaseItemDto mb3Item, string itemType)
        {
            var item = InstantiateItem(itemType, mb3Item);

            if (item != null)
            {
                item.Name = mb3Item.Name;
                //Logger.ReportVerbose("Item {0} is {1}", item.Name, item.GetType().Name);
                item.Path             = mb3Item.Path;
                item.DateCreated      = (mb3Item.DateCreated ?? DateTime.MinValue).ToLocalTime();
                item.DisplayMediaType = mb3Item.DisplayMediaType;
                item.Overview         = mb3Item.Overview;
                item.SortName         = mb3Item.SortName;
                item.TagLine          = mb3Item.Taglines != null && mb3Item.Taglines.Count > 0 ? mb3Item.Taglines[0] : null;
                item.UserData         = mb3Item.UserData;
                item.PremierDate      = mb3Item.PremiereDate ?? DateTime.MinValue;
                item.FirstAired       = mb3Item.PremiereDate != null?mb3Item.PremiereDate.Value.ToLocalTime().ToString("ddd d MMM, yyyy") : null;

                item.EndDate             = mb3Item.EndDate ?? DateTime.MinValue;
                item.ProductionYear      = mb3Item.ProductionYear ?? item.PremierDate.Year;
                item.ProductionLocations = mb3Item.ProductionLocations;
                //Logger.ReportInfo("*********** Premier Date for {0} is {1}",item.Name,item.PremierDate);
                item.ApiParentId = mb3Item.ParentId;
                //if (item.ApiParentId == null) Logger.ReportVerbose("Parent Id is null for {0}",item.Name);
                item.LocationType = mb3Item.LocationType;
                // recursive media count
                item.ApiRecursiveItemCount = mb3Item.RecursiveItemCount;
                item.ApiItemCount          = mb3Item.ChildCount;
                // disc status
                item.IsOffline      = mb3Item.LocationType == LocationType.Offline;
                item.IsExternalDisc = mb3Item.IsPlaceHolder ?? false;
                // playback access
                item.PlaybackAllowed = (mb3Item.PlayAccess == PlayAccess.Full) && !(mb3Item.IsPlaceHolder ?? false);
                // delete access
                item.CanDelete = mb3Item.CanDelete ?? false;

                //Ratings
                item.CriticRating        = mb3Item.CriticRating;
                item.CriticRatingSummary = mb3Item.CriticRatingSummary;
                item.MetaScore           = mb3Item.Metascore;

                //SpecialFeatures
                item.SpecialFeatureCount = mb3Item.SpecialFeatureCount ?? 0;

                //Counts
                item.MovieCount      = mb3Item.MovieCount ?? 0;
                item.SeriesCount     = mb3Item.SeriesCount ?? 0;
                item.EpisodeCount    = mb3Item.EpisodeCount ?? 0;
                item.TrailerCount    = mb3Item.LocalTrailerCount ?? 0;
                item.GameCount       = mb3Item.GameCount ?? 0;
                item.SongCount       = mb3Item.SongCount ?? 0;
                item.AlbumCount      = mb3Item.AlbumCount ?? 0;
                item.MusicVideoCount = mb3Item.MusicVideoCount ?? 0;


                var runTimeTicks = mb3Item.RunTimeTicks;
                item.RuntimeTicks = runTimeTicks ?? 0;

                var index = item as IndexFolder;
                if (index != null)
                {
                    index.Id      = mb3Item.Id.GetMD5();
                    index.IndexId = mb3Item.Id;
                }
                else
                {
                    item.Id = new Guid(mb3Item.Id);
                }

                if (mb3Item.ImageTags != null)
                {
                    foreach (var tag in mb3Item.ImageTags)
                    {
                        switch (tag.Key)
                        {
                        case ImageType.Primary:
                            if (mb3Item.HasPrimaryImage)
                            {
                                item.PrimaryImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxPrimaryWidth, CropWhitespace = false
                                });
                            }
                            break;

                        case ImageType.Logo:
                            if (mb3Item.HasLogo)
                            {
                                item.LogoImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxLogoWidth, CropWhitespace = false
                                });
                            }
                            break;

                        case ImageType.Art:
                            if (mb3Item.HasArtImage)
                            {
                                item.ArtImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxArtWidth, CropWhitespace = false
                                });
                            }
                            break;

                        case ImageType.Banner:
                            if (mb3Item.HasBanner)
                            {
                                item.BannerImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxBannerWidth, CropWhitespace = false
                                });
                            }
                            break;

                        case ImageType.Thumb:
                            if (mb3Item.HasThumb)
                            {
                                item.ThumbnailImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxThumbWidth, CropWhitespace = false
                                });
                            }
                            break;

                        case ImageType.Disc:
                            if (mb3Item.HasDiscImage)
                            {
                                item.DiscImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxDiscWidth, CropWhitespace = false
                                });
                            }
                            break;
                        }
                    }
                }

                if (mb3Item.BackdropImageTags != null && mb3Item.BackdropCount > 0)
                {
                    var ndx = 0;
                    item.BackdropImagePaths = new List <string>();
                    foreach (var bd in mb3Item.BackdropImageTags)
                    {
                        item.BackdropImagePaths.Add(Kernel.ApiClient.GetImageUrl(mb3Item.Id, new ImageOptions {
                            ImageType = ImageType.Backdrop, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxBackgroundWidth, Tag = bd, ImageIndex = ndx
                        }));
                        ndx++;
                    }
                }

                var folder = item as Folder;
                if (folder != null)
                {
                    // Collection Type
                    folder.CollectionType = mb3Item.CollectionType;
                    // Fill in display prefs
                    folder.DisplayPreferencesId = mb3Item.DisplayPreferencesId ?? mb3Item.Id;

                    // cumulative runtime
                    if (mb3Item.CumulativeRunTimeTicks != null)
                    {
                        folder.RunTime = (int)(mb3Item.CumulativeRunTimeTicks / TimeSpan.TicksPerMinute);
                    }

                    // unwatched count
                    if (mb3Item.UserData != null && mb3Item.UserData.UnplayedItemCount.HasValue)
                    {
                        folder.UnwatchedCount = mb3Item.UserData.UnplayedItemCount.Value;
                    }
                    // it is just too slow to try and gather these as channels are dynamic and potentially large
                    else if (mb3Item.Type == "Channel" || mb3Item.Type == "ChannelFolder")
                    {
                        folder.UnwatchedCount = 0;
                    }

                    // we want our created date to be the date of last item we contain
                    folder.DateCreated = mb3Item.DateLastMediaAdded ?? folder.DateCreated;
                }

                var video = item as Video;
                if (video != null && video.Path != null)
                {
                    video.ContainsTrailers = mb3Item.LocalTrailerCount > 0;
                    if (mb3Item.Video3DFormat != null)
                    {
                        video.VideoFormat = mb3Item.Video3DFormat == Video3DFormat.FullSideBySide || mb3Item.Video3DFormat == Video3DFormat.HalfSideBySide ? "Sbs3D" : "Digital3D";
                        video.Is3D        = true;
                    }
                    else
                    {
                        video.VideoFormat = "Standard";
                    }

                    // Chapters
                    if (mb3Item.Chapters != null)
                    {
                        var ndx = 0;
                        video.Chapters = mb3Item.Chapters.Select(c => new Chapter {
                            ApiParentId = mb3Item.Id, PositionTicks = c.StartPositionTicks, Name = c.Name, PrimaryImagePath = c.HasImage ? GetImageUrl(video, new ImageOptions {
                                Tag = c.ImageTag, ImageType = ImageType.Chapter, ImageIndex = ndx++
                            }) : null
                        }).ToList();
                    }
                }

                var media = item as Media;
                if (media != null)
                {
                    media.PartCount    = mb3Item.PartCount ?? 1;
                    media.MediaSources = mb3Item.MediaSources;

                    if (mb3Item.MediaType == Model.Entities.MediaType.Video)
                    {
                        if (mb3Item.VideoType == VideoType.VideoFile && media.Path != null)
                        {
                            media.MediaType = MediaTypeResolver.DetermineType(media.Path);
                        }
                        else
                        {
                            switch (mb3Item.VideoType)
                            {
                            case VideoType.BluRay:
                                media.MediaType = MediaType.BluRay;
                                break;

                            case VideoType.Dvd:
                                media.MediaType = MediaType.DVD;
                                break;

                            case VideoType.Iso:
                                media.MediaType = MediaType.ISO;
                                break;

                            default:
                                media.MediaType = MediaType.Unknown;
                                break;
                            }
                        }
                    }
                    else
                    {
                        media.MediaType = MediaTypeResolver.DetermineType(media.Path);
                    }

                    if (mb3Item.MediaStreams != null)
                    {
                        var vidStream   = mb3Item.MediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);
                        var audStream   = mb3Item.MediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Audio && s.IsDefault) ?? mb3Item.MediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Audio);
                        var subtStreams = mb3Item.MediaStreams.Where(s => s.Type == MediaStreamType.Subtitle && !string.IsNullOrEmpty(s.Language)).Select(s => s.IsForced ? s.Language.ToUpper() : s.Language).ToArray();
                        media.MediaStreams = mb3Item.MediaStreams;
                        media.AspectRatio  = !string.IsNullOrEmpty(mb3Item.AspectRatio) ? mb3Item.AspectRatio : null;
                        media.SubTitle     = subtStreams.Any() ? string.Join(", ", subtStreams) : null;

                        media.MediaInfo = new MediaInfoData
                        {
                            OverrideData = new MediaInfoData.MIData
                            {
                                AudioStreamCount  = mb3Item.MediaStreams.Count(s => s.Type == MediaStreamType.Audio),
                                AudioBitRate      = audStream != null ? audStream.BitRate ?? 0 : 0,
                                AudioChannelCount = audStream != null?TranslateAudioChannels(audStream.Channels ?? 0) : "",
                                                        AudioFormat                              = audStream != null ? audStream.Codec == "dca" ? audStream.Profile : audStream.Codec : "",
                                                        VideoBitRate                             = vidStream != null ? vidStream.BitRate ?? 0 : 0,
                                                        VideoCodec                               = vidStream != null ? vidStream.Codec : "",
                                                        VideoFPS                                 = vidStream != null?vidStream.AverageFrameRate.ToString() : "",
                                                                                       Width     = vidStream != null ? vidStream.Width ?? 0 : 0,
                                                                                       Height    = vidStream != null ? vidStream.Height ?? 0 : 0,
                                                                                       Subtitles = subtStreams.Any() ? string.Join(", ", subtStreams) : null,
                                                                                       RunTime   = runTimeTicks != null?ConvertTicksToMinutes(runTimeTicks) : 0
                            }
                        };
                    }
                    if (mb3Item.UserData != null)
                    {
                        media.PlaybackStatus = PlaybackStatusFactory.Instance.Create(media.Id);
                        media.PlaybackStatus.PositionTicks = mb3Item.UserData.PlaybackPositionTicks;
                        media.PlaybackStatus.PlayCount     = mb3Item.UserData.PlayCount;
                        media.PlaybackStatus.WasPlayed     = mb3Item.UserData.Played || mb3Item.LocationType == LocationType.Virtual;
                        media.PlaybackStatus.LastPlayed    = (mb3Item.UserData.LastPlayedDate ?? DateTime.MinValue).ToLocalTime();
                    }
                }

                var show = item as IShow;
                if (show != null)
                {
                    show.MpaaRating  = mb3Item.OfficialRating;
                    show.ImdbRating  = mb3Item.CommunityRating;
                    show.RunningTime = runTimeTicks != null ? (int?)ConvertTicksToMinutes(runTimeTicks) : null;

                    if (mb3Item.Genres != null)
                    {
                        show.Genres = new List <string>(mb3Item.Genres);
                    }

                    if (mb3Item.People != null)
                    {
                        show.Actors    = new List <Actor>(mb3Item.People.Where(p => p.Type == PersonType.Actor || p.Type == PersonType.GuestStar).Select(a => new Actor(a)));
                        show.Directors = new List <string>(mb3Item.People.Where(p => p.Type == PersonType.Director).Select(a => a.Name));
                    }

                    if (mb3Item.Studios != null)
                    {
                        show.Studios = new List <string>(mb3Item.Studios.Select(s => s.Name));
                        foreach (var studio in mb3Item.Studios.Where(s => s != null))
                        {
                            Studio.AddToCache(studio);
                        }
                    }
                }

                var episode = item as Episode;
                if (episode != null)
                {
                    var indexDisplay = mb3Item.IndexNumber != null && mb3Item.IndexNumber > 0 ? mb3Item.IndexNumber + (mb3Item.IndexNumberEnd != null ? "-" + mb3Item.IndexNumberEnd : "") + " - " : "";
                    episode.Name          = indexDisplay != "" ? indexDisplay + episode.Name : episode.Name;
                    episode.EpisodeNumber = mb3Item.IndexNumber != null?mb3Item.IndexNumber.Value.ToString("#00") : null;

                    episode.SeasonNumber = mb3Item.ParentIndexNumber != null?mb3Item.ParentIndexNumber.Value.ToString("#00") : null;

                    episode.SeriesId = mb3Item.SeriesId;
                    episode.SeasonId = mb3Item.SeasonId;
                    if (mb3Item.AirsAfterSeasonNumber != null)
                    {
                        episode.SortName = mb3Item.AirsAfterSeasonNumber.Value.ToString("000") + "-999999" + mb3Item.SortName;
                    }
                    else
                    if (mb3Item.AirsBeforeSeasonNumber != null && mb3Item.AirsBeforeEpisodeNumber != null)
                    {
                        episode.SortName = mb3Item.AirsBeforeSeasonNumber.Value.ToString("000") + "-" + ((int)(mb3Item.AirsBeforeEpisodeNumber - 1)).ToString("0000") + ".5" + mb3Item.SortName;
                    }
                }

                var season = item as Season;
                if (season != null)
                {
                    season.SeasonNumber = (mb3Item.IndexNumber ?? 0).ToString("000");
                }
                else
                {
                    var series = item as Series;
                    if (series != null)
                    {
                        series.Status       = mb3Item.Status;
                        series.AirTime      = mb3Item.AirTime;
                        series.ImdbRating   = mb3Item.CommunityRating;
                        series.CriticRating = mb3Item.CriticRating;
                        series.AirDay       = mb3Item.AirDays != null?mb3Item.AirDays.FirstOrDefault().ToString() : null;
                    }
                }


                var song = item as Song;
                if (song != null)
                {
                    song.Album        = mb3Item.Album;
                    song.AlbumArtist  = mb3Item.AlbumArtist;
                    song.AlbumId      = mb3Item.AlbumId;
                    song.Artist       = mb3Item.Artists.FirstOrDefault();
                    song.CriticRating = mb3Item.CommunityRating;
                }

                var album = item as MusicAlbum;
                if (album != null)
                {
                    album.AlbumArtist = mb3Item.AlbumArtist ?? mb3Item.Artists.FirstOrDefault();
                }

                var photo = item as Photo;
                if (photo != null)
                {
                    if (mb3Item.HasPrimaryImage)
                    {
                        //Make the photo itself also the backdrop so it can preview large and play back at full-res
                        item.BackdropImagePaths = new List <string> {
                            Kernel.ApiClient.GetImageUrl(mb3Item.Id, new ImageOptions {
                                ImageType = ImageType.Primary, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxBackgroundWidth, Tag = mb3Item.ImageTags[ImageType.Primary]
                            })
                        };
                    }

                    if (string.IsNullOrEmpty(photo.Overview))
                    {
                        if (photo.DateTaken != DateTime.MinValue || !string.IsNullOrEmpty(mb3Item.CameraMake) || !string.IsNullOrEmpty(mb3Item.CameraModel))
                        {
                            photo.Overview = string.Format("Taken {0} with a {1} {2}\n", photo.DateTaken > DateTime.MinValue ? photo.DateTaken.ToShortTimeString() : "", mb3Item.CameraMake, mb3Item.CameraModel);
                        }
                        photo.Overview += string.Format("Original Resolution {0}x{1}", mb3Item.Width, mb3Item.Height);
                        if (mb3Item.ShutterSpeed != null)
                        {
                            photo.Overview += string.Format(" Shutter Speed {0}\n", mb3Item.ShutterSpeed);
                        }
                    }
                }

                // Finally, any custom values
                item.FillCustomValues(mb3Item);
            }
            else
            {
                Logger.ReportWarning("Ignoring invalid item " + itemType + ".  Would not instantiate in current environment.");
            }


            return(item);
        }
Пример #13
0
        public override bool RefreshMetadata(MetadataRefreshOptions options)
        {
            bool   changed = false;
            string path    = Plugin.proxy == null ? this.Path : Plugin.proxy.ProxyUrl(this);

            if (this.Path != path)
            {
                this.Path = path;
                changed   = true;
            }

            MediaType = MediaTypeResolver.DetermineType(Path);

            if ((options & MetadataRefreshOptions.FastOnly) != MetadataRefreshOptions.FastOnly &&
                Plugin.PluginOptions.Instance.FetchBackdrops && string.IsNullOrEmpty(this.BackdropImagePath))
            {
                if (this.BackdropImagePath == null)
                {
                    // use our own movieDBProvider to grab just the backdrops
                    var provider = new BackdropProvider();
                    provider.Item = (Movie)Serializer.Clone(this);
                    provider.Fetch();
                    this.BackdropImagePaths = provider.Item.BackdropImagePaths;
                    foreach (var image in this.BackdropImages)
                    {
                        try
                        {
                            if (image != null)
                            {
                                image.ClearLocalImages();
                                MediaBrowser.Library.Factories.LibraryImageFactory.Instance.ClearCache(image.Path);
                                var ignore = image.GetLocalImagePath();
                            }
                        }
                        catch (Exception ex)
                        {
                            MediaBrowser.Library.Logging.Logger.ReportException("Failed to clear local image (its probably in use)", ex);
                        }
                    }
                    changed = true;
                }
            }

            if ((options & MetadataRefreshOptions.Force) == MetadataRefreshOptions.Force)
            {
                //force images to refresh
                var images = new List <MediaBrowser.Library.ImageManagement.LibraryImage>();
                images.Add(PrimaryImage);
                images.Add(SecondaryImage);
                images.Add(BannerImage);

                foreach (var image in images)
                {
                    try
                    {
                        if (image != null)
                        {
                            image.ClearLocalImages();
                            MediaBrowser.Library.Factories.LibraryImageFactory.Instance.ClearCache(image.Path);
                        }
                    }
                    catch (Exception ex)
                    {
                        MediaBrowser.Library.Logging.Logger.ReportException("Failed to clear local image (its probably in use)", ex);
                    }
                }
                changed = true;
            }
            if (changed)
            {
                MediaBrowser.Library.Kernel.Instance.ItemRepository.SaveItem(this);
            }
            return(changed);
        }