1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using MediaBrowser.Controller.Entities.TV;
- using MediaBrowser.Controller.Library;
- using MediaBrowser.Controller.Resolvers;
- using MediaBrowser.Model.Entities;
- using System;
- using System.IO;
- namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
- {
- /// <summary>
- /// Class SeriesResolver
- /// </summary>
- public class SeriesResolver : FolderResolver<Series>
- {
- /// <summary>
- /// Gets the priority.
- /// </summary>
- /// <value>The priority.</value>
- public override ResolverPriority Priority
- {
- get
- {
- return ResolverPriority.Second;
- }
- }
- /// <summary>
- /// Resolves the specified args.
- /// </summary>
- /// <param name="args">The args.</param>
- /// <returns>Series.</returns>
- protected override Series Resolve(ItemResolveArgs args)
- {
- if (args.IsDirectory)
- {
- var collectionType = args.GetCollectionType();
- // If there's a collection type and it's not tv, it can't be a series
- if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
- {
- if (args.HasParent<Series>())
- {
- return null;
- }
-
- return new Series
- {
- Path = args.Path,
- Name = Path.GetFileName(args.Path)
- };
- }
- }
- return null;
- }
- /// <summary>
- /// Sets the initial item values.
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="args">The args.</param>
- protected override void SetInitialItemValues(Series item, ItemResolveArgs args)
- {
- base.SetInitialItemValues(item, args);
- SetProviderIdFromPath(item, args.Path);
- }
- /// <summary>
- /// Sets the provider id from path.
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="path">The path.</param>
- private void SetProviderIdFromPath(Series item, string path)
- {
- var justName = Path.GetFileName(path);
- var id = justName.GetAttributeValue("tvdbid");
- if (!string.IsNullOrEmpty(id))
- {
- item.SetProviderId(MetadataProviders.Tvdb, id);
- }
- }
- }
- }
|