mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
Fix not initialising structs properly
This commit is contained in:
parent
556b34d000
commit
6d25610d53
@ -48,12 +48,12 @@ namespace MediaBrowser.Providers.TV
|
|||||||
{
|
{
|
||||||
var list = new List<RemoteSearchResult>();
|
var list = new List<RemoteSearchResult>();
|
||||||
|
|
||||||
var identity = ParseIdentity(searchInfo.GetProviderId(FullIdKey));
|
var identity = Identity.ParseIdentity(searchInfo.GetProviderId(FullIdKey));
|
||||||
|
|
||||||
if (identity == null)
|
if (identity == null)
|
||||||
{
|
{
|
||||||
await Identify(searchInfo).ConfigureAwait(false);
|
await Identify(searchInfo).ConfigureAwait(false);
|
||||||
identity = ParseIdentity(searchInfo.GetProviderId(FullIdKey));
|
identity = Identity.ParseIdentity(searchInfo.GetProviderId(FullIdKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (identity != null)
|
if (identity != null)
|
||||||
@ -104,12 +104,12 @@ namespace MediaBrowser.Providers.TV
|
|||||||
|
|
||||||
public async Task<MetadataResult<Episode>> GetMetadata(EpisodeInfo searchInfo, CancellationToken cancellationToken)
|
public async Task<MetadataResult<Episode>> GetMetadata(EpisodeInfo searchInfo, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var identity = ParseIdentity(searchInfo.GetProviderId(FullIdKey));
|
var identity = Identity.ParseIdentity(searchInfo.GetProviderId(FullIdKey));
|
||||||
|
|
||||||
if (identity == null)
|
if (identity == null)
|
||||||
{
|
{
|
||||||
await Identify(searchInfo).ConfigureAwait(false);
|
await Identify(searchInfo).ConfigureAwait(false);
|
||||||
identity = ParseIdentity(searchInfo.GetProviderId(FullIdKey));
|
identity = Identity.ParseIdentity(searchInfo.GetProviderId(FullIdKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = new MetadataResult<Episode>();
|
var result = new MetadataResult<Episode>();
|
||||||
@ -783,28 +783,50 @@ namespace MediaBrowser.Providers.TV
|
|||||||
return Task.FromResult<object>(null);
|
return Task.FromResult<object>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var number = info.IndexNumber.Value.ToString();
|
var id = new Identity(seriesTvdbId, info.ParentIndexNumber, info.IndexNumber.Value, info.IndexNumberEnd);
|
||||||
if (info.IndexNumberEnd != null)
|
info.SetProviderId(FullIdKey, id.ToString());
|
||||||
number += "-" + info.IndexNumberEnd;
|
|
||||||
|
|
||||||
var id = string.Format(
|
|
||||||
FullIdFormat,
|
|
||||||
seriesTvdbId,
|
|
||||||
info.ParentIndexNumber.HasValue ? info.ParentIndexNumber.Value.ToString() : "A",
|
|
||||||
number);
|
|
||||||
|
|
||||||
info.SetProviderId(FullIdKey, FullIdFormat);
|
|
||||||
|
|
||||||
return Task.FromResult(id);
|
return Task.FromResult(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Identity? ParseIdentity(string id)
|
public int Order { get { return 0; } }
|
||||||
|
|
||||||
|
public struct Identity
|
||||||
|
{
|
||||||
|
public string SeriesId { get; private set; }
|
||||||
|
public int? SeasonIndex { get; private set; }
|
||||||
|
public int EpisodeNumber { get; private set; }
|
||||||
|
public int? EpisodeNumberEnd { get; private set; }
|
||||||
|
|
||||||
|
public Identity(string id)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
this = ParseIdentity(id).Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Identity(string seriesId, int? seasonIndex, int episodeNumber, int? episodeNumberEnd)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
SeriesId = seriesId;
|
||||||
|
SeasonIndex = seasonIndex;
|
||||||
|
EpisodeNumber = episodeNumber;
|
||||||
|
EpisodeNumberEnd = episodeNumberEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("{0}:{1}:{2}",
|
||||||
|
SeriesId,
|
||||||
|
SeasonIndex != null ? SeasonIndex.Value.ToString() : "A",
|
||||||
|
EpisodeNumber + (EpisodeNumberEnd != null ? "-" + EpisodeNumberEnd.Value.ToString() : ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Identity? ParseIdentity(string id)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(id))
|
if (string.IsNullOrEmpty(id))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
var parts = id.Split(':');
|
var parts = id.Split(':');
|
||||||
var series = parts[0];
|
var series = parts[0];
|
||||||
var season = parts[1] != "A" ? (int?)int.Parse(parts[1]) : null;
|
var season = parts[1] != "A" ? (int?)int.Parse(parts[1]) : null;
|
||||||
@ -812,42 +834,20 @@ namespace MediaBrowser.Providers.TV
|
|||||||
int index;
|
int index;
|
||||||
int? indexEnd;
|
int? indexEnd;
|
||||||
|
|
||||||
if (parts[2].Contains("-"))
|
if (parts[2].Contains("-")) {
|
||||||
{
|
|
||||||
var split = parts[2].IndexOf("-", StringComparison.OrdinalIgnoreCase);
|
var split = parts[2].IndexOf("-", StringComparison.OrdinalIgnoreCase);
|
||||||
index = int.Parse(parts[2].Substring(0, split));
|
index = int.Parse(parts[2].Substring(0, split));
|
||||||
indexEnd = int.Parse(parts[2].Substring(split + 1));
|
indexEnd = int.Parse(parts[2].Substring(split + 1));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
index = int.Parse(parts[2]);
|
index = int.Parse(parts[2]);
|
||||||
indexEnd = null;
|
indexEnd = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Identity(series, season, index, indexEnd);
|
return new Identity(series, season, index, indexEnd);
|
||||||
}
|
} catch {
|
||||||
catch
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Order { get { return 0; } }
|
|
||||||
|
|
||||||
private struct Identity
|
|
||||||
{
|
|
||||||
public string SeriesId { get; private set; }
|
|
||||||
public int? SeasonIndex { get; private set; }
|
|
||||||
public int EpisodeNumber { get; private set; }
|
|
||||||
public int? EpisodeNumberEnd { get; private set; }
|
|
||||||
|
|
||||||
public Identity(string seriesId, int? seasonIndex, int episodeNumber, int? episodeNumberEnd)
|
|
||||||
{
|
|
||||||
SeriesId = seriesId;
|
|
||||||
SeasonIndex = seasonIndex;
|
|
||||||
EpisodeNumber = episodeNumber;
|
|
||||||
EpisodeNumberEnd = episodeNumberEnd;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,14 @@ namespace MediaBrowser.Providers.TV
|
|||||||
public string SeriesId { get; private set; }
|
public string SeriesId { get; private set; }
|
||||||
public int Index { get; private set; }
|
public int Index { get; private set; }
|
||||||
|
|
||||||
|
public TvdbSeasonIdentity(string id)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
this = TvdbSeasonIdentityProvider.ParseIdentity(id).Value;
|
||||||
|
}
|
||||||
|
|
||||||
public TvdbSeasonIdentity(string seriesId, int index)
|
public TvdbSeasonIdentity(string seriesId, int index)
|
||||||
|
: this()
|
||||||
{
|
{
|
||||||
SeriesId = seriesId;
|
SeriesId = seriesId;
|
||||||
Index = index;
|
Index = index;
|
||||||
|
Loading…
Reference in New Issue
Block a user