diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-06-06 14:25:55 -0400 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2016-06-06 14:25:55 -0400 |
| commit | ee9c6c566416ac1f71d2e696528eb1af2e1ac581 (patch) | |
| tree | b3ec949f66bb9a716701405bc281eb0625271039 /MediaBrowser.Server.Implementations | |
| parent | c4dc925b00e5159a896e4f978455a9c4983b704d (diff) | |
| parent | 83105f5aaeea7af09154f6c765b414393740f00d (diff) | |
Merge pull request #1821 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Server.Implementations')
7 files changed, 141 insertions, 50 deletions
diff --git a/MediaBrowser.Server.Implementations/Connect/Responses.cs b/MediaBrowser.Server.Implementations/Connect/Responses.cs index e7c3f8154..f86527829 100644 --- a/MediaBrowser.Server.Implementations/Connect/Responses.cs +++ b/MediaBrowser.Server.Implementations/Connect/Responses.cs @@ -60,7 +60,6 @@ namespace MediaBrowser.Server.Implementations.Connect { return new ConnectUserPreferences { - GroupMoviesIntoBoxSets = config.GroupMoviesIntoBoxSets, PlayDefaultAudioTrack = config.PlayDefaultAudioTrack, SubtitleMode = config.SubtitleMode, PreferredAudioLanguages = string.IsNullOrWhiteSpace(config.AudioLanguagePreference) ? new string[] { } : new[] { config.AudioLanguagePreference }, diff --git a/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs index dccc7aa93..23560b1aa 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv var service = _liveTvManager.Services.FirstOrDefault(i => string.Equals(i.Name, liveTvItem.ServiceName, StringComparison.OrdinalIgnoreCase)); - if (service != null) + if (service != null && !item.HasImage(ImageType.Primary)) { try { diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 6e5e8298f..41c137c29 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -625,7 +625,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV _logger.Debug("Getting programs for channel {0}-{1} from {2}-{3}", channel.Number, channel.Name, provider.Item1.Name, provider.Item2.ListingsId ?? string.Empty); - var programs = await provider.Item1.GetProgramsAsync(provider.Item2, channel.Number, channel.Name, startDateUtc, endDateUtc, cancellationToken) + var channelMappings = GetChannelMappings(provider.Item2); + var channelNumber = channel.Number; + string mappedChannelNumber; + if (channelMappings.TryGetValue(channelNumber, out mappedChannelNumber)) + { + _logger.Debug("Found mapped channel on provider {0}. Tuner channel number: {1}, Mapped channel number: {2}", provider.Item1.Name, channelNumber, mappedChannelNumber); + channelNumber = mappedChannelNumber; + } + + var programs = await provider.Item1.GetProgramsAsync(provider.Item2, channelNumber, channel.Name, startDateUtc, endDateUtc, cancellationToken) .ConfigureAwait(false); var list = programs.ToList(); @@ -647,6 +656,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV return new List<ProgramInfo>(); } + private Dictionary<string, string> GetChannelMappings(ListingsProviderInfo info) + { + var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); + + foreach (var mapping in info.ChannelMappings) + { + dict[mapping.Name] = mapping.Value; + } + + return dict; + } + private List<Tuple<IListingsProvider, ListingsProviderInfo>> GetListingProviders() { return GetConfiguration().ListingProviders diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTv.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTv.cs deleted file mode 100644 index ac316f9a1..000000000 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTv.cs +++ /dev/null @@ -1,44 +0,0 @@ -using MediaBrowser.Controller.LiveTv; -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.LiveTv; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace MediaBrowser.Server.Implementations.LiveTv.Listings -{ - public class XmlTv : IListingsProvider - { - public string Name - { - get { return "XmlTV"; } - } - - public string Type - { - get { return "xmltv"; } - } - - public Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, string channelName, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public async Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken) - { - // Might not be needed - } - - public async Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings) - { - // Check that the path or url is valid. If not, throw a file not found exception - } - - public Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string country, string location) - { - // In theory this should never be called because there is always only one lineup - throw new NotImplementedException(); - } - } -} diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs new file mode 100644 index 000000000..5b0b2ad84 --- /dev/null +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -0,0 +1,112 @@ +using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.LiveTv; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +using Emby.XmlTv.Classes; +using MediaBrowser.Controller.Configuration; + +namespace MediaBrowser.Server.Implementations.LiveTv.Listings +{ + public class XmlTvListingsProvider : IListingsProvider + { + private readonly IServerConfigurationManager _config; + + public XmlTvListingsProvider(IServerConfigurationManager config) + { + _config = config; + } + + public string Name + { + get { return "XmlTV"; } + } + + public string Type + { + get { return "xmltv"; } + } + + private string GetLanguage() + { + return _config.Configuration.PreferredMetadataLanguage; + } + + // TODO: Should this method be async? + public Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, string channelName, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken) + { + var reader = new XmlTvReader(info.Path, GetLanguage(), null); + string mappedChannel = channelNumber; + + var results = reader.GetProgrammes(mappedChannel, startDateUtc, endDateUtc, cancellationToken); + return Task.FromResult(results.Select(p => new ProgramInfo() + { + ChannelId = p.ChannelId, + EndDate = p.EndDate, + EpisodeNumber = p.Episode == null ? null : p.Episode.Episode, + EpisodeTitle = p.Episode == null ? null : p.Episode.Title, + Genres = p.Categories, + Id = String.Format("{0}_{1:O}", p.ChannelId, p.StartDate), // Construct an id from the channel and start date, + StartDate = p.StartDate, + Name = p.Title, + Overview = p.Description, + ShortOverview = p.Description, + ProductionYear = !p.CopyrightDate.HasValue ? (int?)null : p.CopyrightDate.Value.Year, + SeasonNumber = p.Episode == null ? null : p.Episode.Series, + IsSeries = p.IsSeries, + IsRepeat = p.IsRepeat, + // IsPremiere = !p.PreviouslyShown.HasValue, + IsKids = p.Categories.Any(info.KidsCategories.Contains), + IsMovie = p.Categories.Any(info.MovieCategories.Contains), + IsNews = p.Categories.Any(info.NewsCategories.Contains), + IsSports = p.Categories.Any(info.SportsCategories.Contains), + ImageUrl = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source) ? p.Icon.Source : null, + HasImage = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source), + OfficialRating = p.Rating != null && !String.IsNullOrEmpty(p.Rating.Value) ? p.Rating.Value : null, + CommunityRating = p.StarRating.HasValue ? p.StarRating.Value : (float?)null + })); + } + + public async Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken) + { + // Add the channel image url + var reader = new XmlTvReader(info.Path, GetLanguage(), null); + var results = reader.GetChannels().ToList(); + + if (channels != null && channels.Count > 0) + { + channels.ForEach(c => { + var match = results.FirstOrDefault(r => r.Id == c.Id); + if (match != null && match.Icon != null && !String.IsNullOrEmpty(match.Icon.Source)) + { + c.ImageUrl = match.Icon.Source; + } + }); + } + } + + public async Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings) + { + // Check that the path or url is valid. If not, throw a file not found exception + if (!File.Exists(info.Path)) + { + throw new FileNotFoundException("Could not find the XmlTv file specified:", info.Path); + } + } + + public Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string country, string location) + { + // In theory this should never be called because there is always only one lineup + var reader = new XmlTvReader(info.Path, GetLanguage(), null); + var results = reader.GetChannels(); + + // Should this method be async? + return Task.FromResult(results.Select(c => new NameIdPair() { Id = c.Id, Name = c.DisplayName }).ToList()); + } + } +}
\ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 5b3419639..5dc064035 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -233,7 +233,7 @@ <Compile Include="LiveTv\EmbyTV\SeriesTimerManager.cs" /> <Compile Include="LiveTv\EmbyTV\TimerManager.cs" /> <Compile Include="LiveTv\Listings\SchedulesDirect.cs" /> - <Compile Include="LiveTv\Listings\XmlTv.cs" /> + <Compile Include="LiveTv\Listings\XmlTvListingsProvider.cs" /> <Compile Include="LiveTv\LiveTvConfigurationFactory.cs" /> <Compile Include="LiveTv\LiveTvDtoService.cs" /> <Compile Include="LiveTv\LiveTvManager.cs" /> diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 4386b785a..098fe0b4d 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1451,7 +1451,7 @@ namespace MediaBrowser.Server.Implementations.Session } } - public async Task RevokeUserTokens(string userId) + public async Task RevokeUserTokens(string userId, string currentAccessToken) { var existing = _authRepo.Get(new AuthenticationInfoQuery { @@ -1461,7 +1461,10 @@ namespace MediaBrowser.Server.Implementations.Session foreach (var info in existing.Items) { - await Logout(info.AccessToken).ConfigureAwait(false); + if (!string.Equals(currentAccessToken, info.AccessToken, StringComparison.OrdinalIgnoreCase)) + { + await Logout(info.AccessToken).ConfigureAwait(false); + } } } |
