mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
update components
This commit is contained in:
parent
853848966f
commit
881fcf2434
@ -150,6 +150,21 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The production year.</value>
|
/// <value>The production year.</value>
|
||||||
public int? ProductionYear { get; set; }
|
public int? ProductionYear { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the home page URL.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The home page URL.</value>
|
||||||
|
public string HomePageUrl { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the series identifier.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The series identifier.</value>
|
||||||
|
public string SeriesId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the show identifier.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The show identifier.</value>
|
||||||
|
public string ShowId { get; set; }
|
||||||
|
|
||||||
public ProgramInfo()
|
public ProgramInfo()
|
||||||
{
|
{
|
||||||
|
@ -185,7 +185,11 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value><c>null</c> if [has image] contains no value, <c>true</c> if [has image]; otherwise, <c>false</c>.</value>
|
/// <value><c>null</c> if [has image] contains no value, <c>true</c> if [has image]; otherwise, <c>false</c>.</value>
|
||||||
public bool? HasImage { get; set; }
|
public bool? HasImage { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the show identifier.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The show identifier.</value>
|
||||||
|
public string ShowId { get; set; }
|
||||||
|
|
||||||
public RecordingInfo()
|
public RecordingInfo()
|
||||||
{
|
{
|
||||||
|
@ -95,6 +95,12 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
/// <value><c>true</c> if this instance is post padding required; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if this instance is post padding required; otherwise, <c>false</c>.</value>
|
||||||
public bool IsPostPaddingRequired { get; set; }
|
public bool IsPostPaddingRequired { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the series identifier.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The series identifier.</value>
|
||||||
|
public string SeriesId { get; set; }
|
||||||
|
|
||||||
public SeriesTimerInfo()
|
public SeriesTimerInfo()
|
||||||
{
|
{
|
||||||
Days = new List<DayOfWeek>();
|
Days = new List<DayOfWeek>();
|
||||||
|
@ -295,6 +295,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
RecordAnyTime = false,
|
RecordAnyTime = false,
|
||||||
RecordNewOnly = false
|
RecordNewOnly = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (program != null)
|
||||||
|
{
|
||||||
|
defaults.SeriesId = program.SeriesId;
|
||||||
|
defaults.ProgramId = program.Id;
|
||||||
|
}
|
||||||
|
|
||||||
return Task.FromResult(defaults);
|
return Task.FromResult(defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,8 +522,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
OriginalAirDate = info.OriginalAirDate,
|
OriginalAirDate = info.OriginalAirDate,
|
||||||
Status = RecordingStatus.Scheduled,
|
Status = RecordingStatus.Scheduled,
|
||||||
Overview = info.Overview,
|
Overview = info.Overview,
|
||||||
SeriesTimerId = info.Id.Substring(0, 10),
|
SeriesTimerId = timer.SeriesTimerId,
|
||||||
TimerId = timer.Id
|
TimerId = timer.Id,
|
||||||
|
ShowId = info.ShowId
|
||||||
};
|
};
|
||||||
_recordingProvider.Add(recording);
|
_recordingProvider.Add(recording);
|
||||||
}
|
}
|
||||||
@ -624,7 +632,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
{
|
{
|
||||||
allPrograms = GetProgramsForSeries(seriesTimer, allPrograms);
|
allPrograms = GetProgramsForSeries(seriesTimer, allPrograms);
|
||||||
|
|
||||||
allPrograms = allPrograms.Where(epg => currentRecordings.All(r => r.ProgramId.Substring(0, 14) != epg.Id.Substring(0, 14))); //filtered recordings already running
|
var recordingShowIds = currentRecordings.Select(i => i.ShowId).ToList();
|
||||||
|
|
||||||
|
allPrograms = allPrograms.Where(epg => !recordingShowIds.Contains(epg.ShowId, StringComparer.OrdinalIgnoreCase));
|
||||||
|
|
||||||
return allPrograms.Select(i => RecordingHelper.CreateTimer(i, seriesTimer));
|
return allPrograms.Select(i => RecordingHelper.CreateTimer(i, seriesTimer));
|
||||||
}
|
}
|
||||||
@ -638,7 +648,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
if (seriesTimer.RecordNewOnly)
|
if (seriesTimer.RecordNewOnly)
|
||||||
{
|
{
|
||||||
allPrograms = allPrograms.Where(epg => !epg.IsRepeat); //Filtered by New only
|
allPrograms = allPrograms.Where(epg => !epg.IsRepeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!seriesTimer.RecordAnyChannel)
|
if (!seriesTimer.RecordAnyChannel)
|
||||||
@ -648,8 +658,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
allPrograms = allPrograms.Where(epg => seriesTimer.Days.Contains(epg.StartDate.DayOfWeek));
|
allPrograms = allPrograms.Where(epg => seriesTimer.Days.Contains(epg.StartDate.DayOfWeek));
|
||||||
|
|
||||||
// TODO: This assumption will require review once additional listing providers are added
|
return allPrograms.Where(epg => string.Equals(epg.SeriesId, seriesTimer.SeriesId, StringComparison.OrdinalIgnoreCase));
|
||||||
return allPrograms.Where(epg => epg.Id.StartsWith(seriesTimer.ProgramId, StringComparison.OrdinalIgnoreCase));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetChannelEpgCachePath(string channelId)
|
private string GetChannelEpgCachePath(string channelId)
|
||||||
|
@ -26,6 +26,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings.Emby
|
|||||||
|
|
||||||
public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
|
public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
channelNumber = NormalizeNumber(channelNumber);
|
||||||
|
|
||||||
var url = "https://data.emby.media/service/listings?id=" + info.ListingsId;
|
var url = "https://data.emby.media/service/listings?id=" + info.ListingsId;
|
||||||
|
|
||||||
// Normalize
|
// Normalize
|
||||||
@ -37,7 +39,99 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings.Emby
|
|||||||
|
|
||||||
var response = await GetResponse<ListingInfo[]>(url).ConfigureAwait(false);
|
var response = await GetResponse<ListingInfo[]>(url).ConfigureAwait(false);
|
||||||
|
|
||||||
return new List<ProgramInfo>();
|
return response.Where(i => IncludeInResults(i, channelNumber)).Select(GetProgramInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ProgramInfo GetProgramInfo(ListingInfo info)
|
||||||
|
{
|
||||||
|
var showType = info.showType ?? string.Empty;
|
||||||
|
|
||||||
|
var program = new ProgramInfo
|
||||||
|
{
|
||||||
|
Id = info.listingID.ToString(CultureInfo.InvariantCulture),
|
||||||
|
Name = GetStringValue(info.showName),
|
||||||
|
EpisodeTitle = GetStringValue(info.episodeTitle),
|
||||||
|
HomePageUrl = GetStringValue(info.webLink),
|
||||||
|
Overview = info.description,
|
||||||
|
IsHD = info.hd,
|
||||||
|
IsLive = info.live,
|
||||||
|
IsPremiere = info.seasonPremiere || info.seriesPremiere,
|
||||||
|
IsMovie = showType.IndexOf("Movie", StringComparison.OrdinalIgnoreCase) != -1,
|
||||||
|
IsKids = showType.IndexOf("Children", StringComparison.OrdinalIgnoreCase) != -1,
|
||||||
|
IsNews = showType.IndexOf("News", StringComparison.OrdinalIgnoreCase) != -1,
|
||||||
|
IsSports = showType.IndexOf("Sports", StringComparison.OrdinalIgnoreCase) != -1
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.listDateTime))
|
||||||
|
{
|
||||||
|
program.StartDate = DateTime.ParseExact(info.listDateTime, "yyyy'-'MM'-'dd' 'HH':'mm':'ss", CultureInfo.InvariantCulture);
|
||||||
|
program.EndDate = program.StartDate.AddMinutes(info.duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.starRating > 0)
|
||||||
|
{
|
||||||
|
program.CommunityRating = info.starRating*2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.rating))
|
||||||
|
{
|
||||||
|
// They don't have dashes so try to normalize
|
||||||
|
program.OfficialRating = info.rating.Replace("TV", "TV-").Replace("--", "-");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.year))
|
||||||
|
{
|
||||||
|
program.ProductionYear = int.Parse(info.year, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.showID > 0)
|
||||||
|
{
|
||||||
|
program.ShowId = info.showID.ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.seriesID > 0)
|
||||||
|
{
|
||||||
|
program.SeriesId = info.seriesID.ToString(CultureInfo.InvariantCulture);
|
||||||
|
program.IsSeries = true;
|
||||||
|
program.IsRepeat = info.repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.starRating > 0)
|
||||||
|
{
|
||||||
|
program.CommunityRating = info.starRating * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(info.showName, "Movie", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// Sometimes the movie title will be in here
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.episodeTitle))
|
||||||
|
{
|
||||||
|
program.Name = info.episodeTitle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetStringValue(string s)
|
||||||
|
{
|
||||||
|
return string.IsNullOrWhiteSpace(s) ? null : s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IncludeInResults(ListingInfo info, string itemNumber)
|
||||||
|
{
|
||||||
|
if (string.Equals(itemNumber, NormalizeNumber(info.number), StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var channelNumber = info.channelNumber.ToString(CultureInfo.InvariantCulture);
|
||||||
|
if (info.subChannelNumber > 0)
|
||||||
|
{
|
||||||
|
channelNumber += "." + info.subChannelNumber.ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Equals(channelNumber, itemNumber, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken)
|
public async Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken)
|
||||||
@ -48,18 +142,25 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings.Emby
|
|||||||
{
|
{
|
||||||
var station = response.stations.FirstOrDefault(i =>
|
var station = response.stations.FirstOrDefault(i =>
|
||||||
{
|
{
|
||||||
|
var itemNumber = NormalizeNumber(channel.Number);
|
||||||
|
|
||||||
|
if (string.Equals(itemNumber, NormalizeNumber(i.number), StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var channelNumber = i.channelNumber.ToString(CultureInfo.InvariantCulture);
|
var channelNumber = i.channelNumber.ToString(CultureInfo.InvariantCulture);
|
||||||
if (i.subChannelNumber > 0)
|
if (i.subChannelNumber > 0)
|
||||||
{
|
{
|
||||||
channelNumber += "." + i.subChannelNumber.ToString(CultureInfo.InvariantCulture);
|
channelNumber += "." + i.subChannelNumber.ToString(CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Equals(channelNumber, channel.Number, StringComparison.OrdinalIgnoreCase);
|
return string.Equals(channelNumber, itemNumber, StringComparison.OrdinalIgnoreCase);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (station != null)
|
if (station != null)
|
||||||
{
|
{
|
||||||
channel.Name = station.name;
|
//channel.Name = station.name;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(station.logoFilename))
|
if (!string.IsNullOrWhiteSpace(station.logoFilename))
|
||||||
{
|
{
|
||||||
@ -70,6 +171,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings.Emby
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string NormalizeNumber(string number)
|
||||||
|
{
|
||||||
|
return number.Replace('-', '.');
|
||||||
|
}
|
||||||
|
|
||||||
public Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings)
|
public Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings)
|
||||||
{
|
{
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
@ -108,7 +214,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings.Emby
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<T> GetResponse<T>(string url)
|
private async Task<T> GetResponse<T>(string url, Func<string, string> filter = null)
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
using (var stream = await _httpClient.Get(new HttpRequestOptions
|
using (var stream = await _httpClient.Get(new HttpRequestOptions
|
||||||
@ -131,12 +237,27 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings.Emby
|
|||||||
|
|
||||||
}).ConfigureAwait(false))
|
}).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
return _jsonSerializer.DeserializeFromStream<T>(secondStream);
|
return ParseResponse<T>(secondStream, filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private T ParseResponse<T>(Stream response, Func<string,string> filter)
|
||||||
|
{
|
||||||
|
using (var reader = new StreamReader(response))
|
||||||
|
{
|
||||||
|
var json = reader.ReadToEnd();
|
||||||
|
|
||||||
|
if (filter != null)
|
||||||
|
{
|
||||||
|
json = filter(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _jsonSerializer.DeserializeFromString<T>(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class LineupInfo
|
private class LineupInfo
|
||||||
{
|
{
|
||||||
public string lineupID { get; set; }
|
public string lineupID { get; set; }
|
||||||
|
@ -622,6 +622,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
item.ProviderImageUrl = info.ImageUrl;
|
item.ProviderImageUrl = info.ImageUrl;
|
||||||
item.RunTimeTicks = (info.EndDate - info.StartDate).Ticks;
|
item.RunTimeTicks = (info.EndDate - info.StartDate).Ticks;
|
||||||
item.StartDate = info.StartDate;
|
item.StartDate = info.StartDate;
|
||||||
|
item.HomePageUrl = info.HomePageUrl;
|
||||||
|
|
||||||
item.ProductionYear = info.ProductionYear;
|
item.ProductionYear = info.ProductionYear;
|
||||||
item.PremiereDate = item.PremiereDate ?? info.OriginalAirDate;
|
item.PremiereDate = item.PremiereDate ?? info.OriginalAirDate;
|
||||||
|
Loading…
Reference in New Issue
Block a user