fixes #299 - Add trailer urls to MovieDbProvider
This commit is contained in:
parent
c70f1047f7
commit
5782d9084d
|
@ -399,9 +399,9 @@ namespace MediaBrowser.Controller.Dto
|
|||
dto.Taglines = item.Taglines;
|
||||
}
|
||||
|
||||
if (fields.Contains(ItemFields.TrailerUrls))
|
||||
if (fields.Contains(ItemFields.RemoteTrailers))
|
||||
{
|
||||
dto.TrailerUrls = item.TrailerUrls;
|
||||
dto.RemoteTrailers = item.RemoteTrailers;
|
||||
}
|
||||
|
||||
dto.Type = item.GetType().Name;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
protected BaseItem()
|
||||
{
|
||||
Genres = new List<string>();
|
||||
TrailerUrls = new List<string>();
|
||||
RemoteTrailers = new List<MediaUrl>();
|
||||
Studios = new List<string>();
|
||||
People = new List<PersonInfo>();
|
||||
Taglines = new List<string>();
|
||||
|
@ -903,7 +903,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// Gets or sets the trailer URL.
|
||||
/// </summary>
|
||||
/// <value>The trailer URL.</value>
|
||||
public List<string> TrailerUrls { get; set; }
|
||||
public List<MediaUrl> RemoteTrailers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the provider ids.
|
||||
|
@ -1180,22 +1180,28 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// Adds a TrailerUrl to the item
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <exception cref="System.ArgumentNullException"></exception>
|
||||
public void AddTrailerUrl(string url)
|
||||
/// <param name="isDirectLink">if set to <c>true</c> [is direct link].</param>
|
||||
/// <exception cref="System.ArgumentNullException">url</exception>
|
||||
public void AddTrailerUrl(string url, bool isDirectLink)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
throw new ArgumentNullException("url");
|
||||
}
|
||||
|
||||
if (TrailerUrls == null)
|
||||
{
|
||||
TrailerUrls = new List<string>();
|
||||
}
|
||||
var current = RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (!TrailerUrls.Contains(url, StringComparer.OrdinalIgnoreCase))
|
||||
if (current != null)
|
||||
{
|
||||
TrailerUrls.Add(url);
|
||||
current.IsDirectLink = isDirectLink;
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoteTrailers.Add(new MediaUrl
|
||||
{
|
||||
Url = url,
|
||||
IsDirectLink = isDirectLink
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ namespace MediaBrowser.Controller.Providers
|
|||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
//item.AddTrailerUrl(val);
|
||||
item.AddTrailerUrl(val, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -133,6 +133,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Entities\MediaType.cs">
|
||||
<Link>Entities\MediaType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Entities\MediaUrl.cs">
|
||||
<Link>Entities\MediaUrl.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Entities\MetadataFields.cs">
|
||||
<Link>Entities\MetadataFields.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace MediaBrowser.Model.Dto
|
|||
/// Gets or sets the trailer urls.
|
||||
/// </summary>
|
||||
/// <value>The trailer urls.</value>
|
||||
public List<string> TrailerUrls { get; set; }
|
||||
public List<MediaUrl> RemoteTrailers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the provider ids.
|
||||
|
@ -614,16 +614,6 @@ namespace MediaBrowser.Model.Dto
|
|||
get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Menu); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is video.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is video; otherwise, <c>false</c>.</value>
|
||||
[IgnoreDataMember]
|
||||
public bool HasTrailer
|
||||
{
|
||||
get { return LocalTrailerCount > 0 || (TrailerUrls != null && TrailerUrls.Count > 0); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is video.
|
||||
/// </summary>
|
||||
|
|
11
MediaBrowser.Model/Entities/MediaUrl.cs
Normal file
11
MediaBrowser.Model/Entities/MediaUrl.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
namespace MediaBrowser.Model.Entities
|
||||
{
|
||||
public class MediaUrl
|
||||
{
|
||||
public string Url { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool? IsHD { get; set; }
|
||||
public bool IsDirectLink { get; set; }
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@
|
|||
<Compile Include="Dto\ItemCounts.cs" />
|
||||
<Compile Include="Dto\StudioDto.cs" />
|
||||
<Compile Include="Entities\ItemReview.cs" />
|
||||
<Compile Include="Entities\MediaUrl.cs" />
|
||||
<Compile Include="Entities\MetadataFields.cs" />
|
||||
<Compile Include="Entities\Video3DFormat.cs" />
|
||||
<Compile Include="Net\WebSocketMessage.cs" />
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace MediaBrowser.Model.Querying
|
|||
/// <summary>
|
||||
/// The trailer url of the item
|
||||
/// </summary>
|
||||
TrailerUrls,
|
||||
RemoteTrailers,
|
||||
|
||||
/// <summary>
|
||||
/// The user data of the item
|
||||
|
|
|
@ -793,6 +793,19 @@ namespace MediaBrowser.Providers.Movies
|
|||
{
|
||||
movie.Tags = movieData.keywords.keywords.Select(i => i.name).ToList();
|
||||
}
|
||||
|
||||
if (movieData.trailers != null && movieData.trailers.youtube != null &&
|
||||
movieData.trailers.youtube.Count > 0)
|
||||
{
|
||||
movie.RemoteTrailers = movieData.trailers.youtube.Select(i => new MediaUrl
|
||||
{
|
||||
Url = string.Format("http://www.youtube.com/watch?{0}", i.source),
|
||||
IsDirectLink = false,
|
||||
Name = i.name,
|
||||
IsHD = string.Equals("hd", i.size, StringComparison.OrdinalIgnoreCase)
|
||||
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1179,6 +1192,19 @@ namespace MediaBrowser.Providers.Movies
|
|||
public Casts casts { get; set; }
|
||||
public Releases releases { get; set; }
|
||||
public Keywords keywords { get; set; }
|
||||
public Trailers trailers { get; set; }
|
||||
}
|
||||
|
||||
public class Trailers
|
||||
{
|
||||
public List<Youtube> youtube { get; set; }
|
||||
}
|
||||
|
||||
public class Youtube
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string size { get; set; }
|
||||
public string source { get; set; }
|
||||
}
|
||||
|
||||
public class TmdbImageSettings
|
||||
|
|
Loading…
Reference in New Issue
Block a user