Added Channel and Program Images and Category Mapping

pull/702/head
Alex Stevens 9 years ago
parent cf1fa24e8b
commit bd001d8c6a

@ -2,13 +2,13 @@
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.LiveTv;
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Emby.XmlTv.Classes; using Emby.XmlTv.Classes;
using System.IO;
namespace MediaBrowser.Server.Implementations.LiveTv.Listings namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{ {
@ -16,6 +16,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{ {
private string _filePath = "C:\\Temp\\"; private string _filePath = "C:\\Temp\\";
private string _language = null; private string _language = null;
private Dictionary<string, List<string>> _categoryMappings = new Dictionary<string, List<string>>(){
{ "Movie", new List<String>() { "Movie", "Film" } },
{ "Sports", new List<String>() { "Sports", "Football", "Rugby", "Soccer" } },
{ "Kids", new List<String>() { "Childrens", "Children", "Kids", "Disney" } },
{ "News", new List<String>() { "News", "Journalism", "Documentary", "Current Affairs" } },
};
public string Name public string Name
{ {
@ -51,6 +57,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
IsSeries = p.IsSeries, IsSeries = p.IsSeries,
IsRepeat = p.IsRepeat, IsRepeat = p.IsRepeat,
IsPremiere = !p.PreviouslyShown.HasValue, IsPremiere = !p.PreviouslyShown.HasValue,
IsKids = p.Categories.Any(_categoryMappings["Kids"].Contains),
IsMovie = p.Categories.Any(_categoryMappings["Movie"].Contains),
IsNews = p.Categories.Any(_categoryMappings["News"].Contains),
IsSports = p.Categories.Any(_categoryMappings["Sports"].Contains),
ImageUrl = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source) ? p.Icon.Source : null,
HasImage = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source),
})); }));
} }
@ -64,10 +76,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{ {
channels.ForEach(c => { channels.ForEach(c => {
var match = results.FirstOrDefault(r => r.Id == c.Id); var match = results.FirstOrDefault(r => r.Id == c.Id);
if (match != null) if (match != null && match.Icon != null && !String.IsNullOrEmpty(match.Icon.Source))
{ {
// c.ImageUrl = match.Url; c.ImageUrl = match.Icon.Source;
// TODO: Add support for the channel logo to the XMLTv Component
} }
}); });
} }

Loading…
Cancel
Save