public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
        {
            var artist = (MusicArtist)item;

            BaseProviderInfo data;
            if (!item.ProviderData.TryGetValue(Id, out data))
            {
                data = new BaseProviderInfo();
                item.ProviderData[Id] = data;
            }

            var songs = artist.RecursiveChildren.OfType<Audio>().ToList();

            if (!item.LockedFields.Contains(MetadataFields.Genres))
            {
                artist.Genres = songs.SelectMany(i => i.Genres)
                    .Distinct(StringComparer.OrdinalIgnoreCase)
                    .ToList();
            }

            data.FileStamp = GetComparisonData(songs);

            SetLastRefreshed(item, DateTime.UtcNow);
            return TrueTaskResult;
        }
        /// <summary>
        /// Sets the persisted last refresh date on the item for this provider.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="value">The value.</param>
        /// <param name="providerVersion">The provider version.</param>
        /// <param name="status">The status.</param>
        /// <exception cref="System.ArgumentNullException">item</exception>
        public virtual void SetLastRefreshed(BaseItem item, DateTime value, string providerVersion, ProviderRefreshStatus status = ProviderRefreshStatus.Success)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            BaseProviderInfo data;

            if (!item.ProviderData.TryGetValue(Id, out data))
            {
                data = new BaseProviderInfo();
            }

            data.LastRefreshed     = value;
            data.LastRefreshStatus = status;
            data.ProviderVersion   = providerVersion;

            // Save the file system stamp for future comparisons
            if (RefreshOnFileSystemStampChange && item.LocationType == LocationType.FileSystem)
            {
                try
                {
                    data.FileStamp = GetCurrentFileSystemStamp(item);
                }
                catch (IOException ex)
                {
                    Logger.ErrorException("Error getting file stamp for {0}", ex, item.Path);
                }
            }

            item.ProviderData[Id] = data;
        }
Example #3
0
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        protected virtual bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (providerInfo == null)
            {
                throw new ArgumentNullException("providerInfo");
            }

            if (NeedsRefreshBasedOnCompareDate(item, providerInfo))
            {
                return(true);
            }

            if (RefreshOnFileSystemStampChange && item.LocationType == LocationType.FileSystem && HasFileSystemStampChanged(item, providerInfo))
            {
                return(true);
            }

            if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
            {
                return(true);
            }

            if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success)
            {
                return(true);
            }

            return(false);
        }
        protected override async Task FetchLastfmData(BaseItem item, string id, CancellationToken cancellationToken)
        {
            var result = await GetAlbumResult(item, cancellationToken).ConfigureAwait(false);

            if (result != null && result.album != null)
            {
                LastfmHelper.ProcessAlbumData(item, result.album);
                //And save locally if indicated
                if (ConfigurationManager.Configuration.SaveLocalMeta)
                {
                    var ms = new MemoryStream();
                    JsonSerializer.SerializeToStream(result.album, ms);

                    cancellationToken.ThrowIfCancellationRequested();

                    await _providerManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LocalMetaFileName), ms, cancellationToken).ConfigureAwait(false);
                    
                }
            }

            BaseProviderInfo data;
            if (!item.ProviderData.TryGetValue(Id, out data))
            {
                data = new BaseProviderInfo();
                item.ProviderData[Id] = data;
            }

            data.Data = GetComparisonData(item as MusicAlbum);
        }
        public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            if (item.HasImage(ImageType.Primary))
            {
                SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
                return true;
            }

            var changed = true;

            try
            {
                changed = await DownloadImage((LiveTvProgram)item, cancellationToken).ConfigureAwait(false);
            }
            catch (HttpException ex)
            {
                // Don't fail the provider on a 404
                if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
                {
                    throw;
                }
            }

            if (changed)
            {
                SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
            }

            return changed;
        }
        /// <summary>
        /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.Boolean}.</returns>
        public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));

            if (metadataFile != null)
            {
                var path = metadataFile.FullName;

                await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);

                try
                {
                    new BaseItemXmlParser<Person>(Logger).Fetch((Person)item, path, cancellationToken);
                }
                finally
                {
                    XmlParsingResourcePool.Release();
                }

                SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
                return true;
            }

            return false;
        }
        /// <summary>
        /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.Boolean}.</returns>
        public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var metadataFile = Path.Combine(item.MetaLocation, Path.ChangeExtension(Path.GetFileName(item.Path), ".xml"));

            var file = item.ResolveArgs.Parent.ResolveArgs.GetMetaFileByPath(metadataFile);

            if (file != null)
            {
                await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);

                try
                {
                    await new EpisodeXmlParser(Logger, _itemRepo).FetchAsync((Episode)item, metadataFile, cancellationToken).ConfigureAwait(false);
                }
                finally
                {
                    XmlParsingResourcePool.Release();
                }
            }

            SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
            return true;
        }
Example #8
0
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tvdb)))
            {
                return false;
            }

            if (!ConfigurationManager.Configuration.DownloadSeriesImages.Art &&
                !ConfigurationManager.Configuration.DownloadSeriesImages.Logo &&
                !ConfigurationManager.Configuration.DownloadSeriesImages.Thumb &&
                !ConfigurationManager.Configuration.DownloadSeriesImages.Backdrops &&
                !ConfigurationManager.Configuration.DownloadSeriesImages.Banner)
            {
                return false;
            }

            if (item.HasImage(ImageType.Art) &&
                item.HasImage(ImageType.Logo) &&
                item.HasImage(ImageType.Banner) &&
                item.HasImage(ImageType.Thumb) &&
                item.BackdropImagePaths.Count > 0)
            {
                return false;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        /// <summary>
        /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.Boolean}.</returns>
        public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var path = MovieXmlSaver.GetMovieSavePath(item);

            if (File.Exists(path))
            {
                await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);

                try
                {
                    var video = (Video)item;

                    await new MovieXmlParser(Logger, _itemRepo).FetchAsync(video, path, cancellationToken).ConfigureAwait(false);
                }
                finally
                {
                    XmlParsingResourcePool.Release();
                }
            }

            SetLastRefreshed(item, DateTime.UtcNow, providerInfo);

            return true;
        }
Example #10
0
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (HasAltMeta(item))
                return false;

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            var releaseId = item.GetProviderId(MetadataProviders.Musicbrainz);
            var releaseGroupId = item.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);

            if (string.IsNullOrEmpty(releaseId))
            {
                var result = await GetReleaseResult((MusicAlbum)item, cancellationToken).ConfigureAwait(false);

                if (!string.IsNullOrEmpty(result.ReleaseId))
                {
                    releaseId = result.ReleaseId;
                    item.SetProviderId(MetadataProviders.Musicbrainz, releaseId);
                }

                if (!string.IsNullOrEmpty(result.ReleaseGroupId))
                {
                    releaseGroupId = result.ReleaseGroupId;
                    item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, releaseGroupId);
                }
            }

            // If we have a release Id but not a release group Id...
            if (!string.IsNullOrEmpty(releaseId) && string.IsNullOrEmpty(releaseGroupId))
            {
                releaseGroupId = await GetReleaseGroupId(releaseId, cancellationToken).ConfigureAwait(false);

                item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, releaseGroupId);
            }

            SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
            return true;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        /// <param name="force"></param>
        /// <param name="providerInfo"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            await Fetch(item, providerInfo, cancellationToken).ConfigureAwait(false);

            SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
            return true;
        }
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        protected virtual bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (providerInfo == null)
            {
                throw new ArgumentNullException("providerInfo");
            }

            if (CompareDate(item) > providerInfo.LastRefreshed)
            {
                return(true);
            }

            if (RefreshOnFileSystemStampChange && HasFileSystemStampChanged(item, providerInfo))
            {
                return(true);
            }

            if (RefreshOnVersionChange && !string.Equals(ProviderVersion, providerInfo.ProviderVersion))
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        /// <param name="providerInfo">The provider information.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.Boolean}.</returns>
        public override Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            item.IndexNumber = TVUtils.GetSeasonNumberFromPath(item.Path);

            SetLastRefreshed(item, DateTime.UtcNow, providerInfo);

            return TrueTaskResult;
        }
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            //if (HasLocalMeta(item))
            //    return false;

            //return base.NeedsRefreshInternal(item, providerInfo);
            return false;
        }
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tvdb)))
            {
                return false;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (GetComparisonData(item) != providerInfo.Data)
            {
                return true;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        // Need to re-override to jump over intermediate implementation
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (!item.ResolveArgs.ContainsMetaFileByName(MetaFileName))
            {
                return false;
            }

            return CompareDate(item) > providerInfo.LastRefreshed;
        }
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (item.HasImage(ImageType.Primary))
            {
                return false;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
Example #20
0
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (item.DontFetchMeta)
            {
                return(false);
            }

            return(DateTime.UtcNow > (providerInfo.LastRefreshed.AddDays(ConfigurationManager.Configuration.MetadataRefreshDays)) &&
                   ShouldFetch(item, providerInfo));
        }
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            // Force a refresh if the IBN path changed
            if (providerInfo.FileStamp != ConfigurationManager.ApplicationPaths.ItemsByNamePath.GetMD5())
            {
                return true;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            // These values are now saved in movie.xml, so don't refresh if they're present
            if (MovieDbProvider.HasAltMeta(item) && item.CriticRating.HasValue && !string.IsNullOrEmpty(item.CriticRatingSummary))
            {
                return false;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            // If song metadata has changed
            if (GetComparisonData((MusicArtist)item) != providerInfo.FileStamp)
            {
                return true;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            // If song metadata has changed and we don't have an mbid, refresh
            if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Musicbrainz)) &&
                GetComparisonData(item as MusicAlbum) != providerInfo.Data)
            {
                return true;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            var video = (Video)item;

            if (!QualifiesForExtraction(video))
            {
                return false;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
        {
            var xml = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));

            if (xml == null)
            {
                return false;
            }

            return _fileSystem.GetLastWriteTimeUtc(xml) > providerInfo.LastRefreshed;
        }
        public override Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            var parentName = Path.GetFileNameWithoutExtension(item.Path);

            if (string.Equals(parentName, "default", StringComparison.OrdinalIgnoreCase))
            {
                item.Name = "Media Library";
            }

            SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
            return TrueTaskResult;
        }
        /// <summary>
        /// Needses the refresh based on compare date.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
        {
            var metadataFile = Path.Combine(item.MetaLocation, Path.ChangeExtension(Path.GetFileName(item.Path), ".xml"));

            var file = item.ResolveArgs.Parent.ResolveArgs.GetMetaFileByPath(metadataFile);

            if (file == null)
            {
                return false;
            }

            return _fileSystem.GetLastWriteTimeUtc(file) > providerInfo.LastRefreshed;
        }
        protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
        {
            var savePath = MovieXmlSaver.GetMovieSavePath(item);

            var xml = item.ResolveArgs.GetMetaFileByPath(savePath) ?? new FileInfo(savePath);

            if (!xml.Exists)
            {
                return false;
            }

            return _fileSystem.GetLastWriteTimeUtc(xml) > item.DateLastSaved;
        }
        /// <summary>
        /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.Boolean}.</returns>
        public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            if (!item.HasImage(ImageType.Primary))
            {
                var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualLastFmImageProvider.ProviderName).ConfigureAwait(false);

                await DownloadImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
            }

            SetLastRefreshed(item, DateTime.UtcNow, providerInfo);

            return true;
        }
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (item.HasImage(ImageType.Primary))
            {
                return false;
            }

            if (string.IsNullOrWhiteSpace(GetImageUrl(item)))
            {
                return false;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        public override Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
        {
            var series = (Series)item;

            var episodes = series.RecursiveChildren
                .OfType<Episode>()
                .ToList();

            series.DateLastEpisodeAdded = episodes.Select(i => i.DateCreated)
                .OrderByDescending(i => i)
                .FirstOrDefault();

            // Don't save to the db
            return FalseTaskResult;
        }
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            var artist = (MusicArtist)item;

            if (!artist.IsAccessedByName)
            {
                // If song metadata has changed
                if (GetComparisonData(artist) != providerInfo.FileStamp)
                {
                    return true;
                }
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (item.HasImage(ImageType.Primary) && item.HasImage(ImageType.Thumb))
            {
                return false;
            }

            // Try again periodically in case new images were added
            if ((DateTime.UtcNow - providerInfo.LastRefreshed).TotalDays > 7)
            {
                return true;
            }

            return base.NeedsRefreshInternal(item, providerInfo);
        }
        /// <summary>
        /// Returns whether or not this provider should be re-fetched.  Default functionality can
        /// compare a provided date with a last refresh time.  This can be overridden for more complex
        /// determinations.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        public bool NeedsRefresh(BaseItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException();
            }

            BaseProviderInfo data;

            if (!item.ProviderData.TryGetValue(Id, out data))
            {
                data = new BaseProviderInfo();
            }

            return(NeedsRefreshInternal(item, data));
        }
        /// <summary>
        /// Needses the refresh internal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="providerInfo">The provider info.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        protected virtual bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (providerInfo == null)
            {
                throw new ArgumentNullException("providerInfo");
            }

            if (CompareDate(item) > providerInfo.LastRefreshed)
            {
                return(true);
            }

            if (RefreshOnFileSystemStampChange && item.LocationType == LocationType.FileSystem && HasFileSystemStampChanged(item, providerInfo))
            {
                return(true);
            }

            if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
            {
                return(true);
            }

            if (RequiresInternet && DateTime.UtcNow > (providerInfo.LastRefreshed.AddDays(ConfigurationManager.Configuration.MetadataRefreshDays)))
            {
                return(true);
            }

            if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success)
            {
                return(true);
            }

            return(false);
        }
Example #37
0
 /// <summary>
 /// Shoulds the fetch.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="providerInfo">The provider info.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
 protected virtual bool ShouldFetch(BaseItem item, BaseProviderInfo providerInfo)
 {
     return(false);
 }
Example #38
0
 /// <summary>
 /// Needses the refresh based on compare date.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="providerInfo">The provider info.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
 protected virtual bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
 {
     return(CompareDate(item) > providerInfo.LastRefreshed);
 }
 /// <summary>
 /// Determines if the item's file system stamp has changed from the last time the provider refreshed
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="providerInfo">The provider info.</param>
 /// <returns><c>true</c> if [has file system stamp changed] [the specified item]; otherwise, <c>false</c>.</returns>
 protected bool HasFileSystemStampChanged(BaseItem item, BaseProviderInfo providerInfo)
 {
     return(GetCurrentFileSystemStamp(item) != providerInfo.FileStamp);
 }