Skip to content

Commit

Permalink
Catching case where the datetime could be null such as when info.json…
Browse files Browse the repository at this point in the history
… is not present.
  • Loading branch information
ankenyr committed Jul 11, 2022
1 parent cf62f18 commit 6d5a51e
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions Jellyfin.Plugin.YoutubeMetadata/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,15 @@ public static MetadataResult<Movie> YTDLJsonToMovie(YTDLData json)
};
result.Item.Name = json.title;
result.Item.Overview = json.description;
var date = DateTime.ParseExact(json.upload_date, "yyyyMMdd", null);
var date = new DateTime(1970, 1, 1);
try
{
date = DateTime.ParseExact(json.upload_date, "yyyyMMdd", null);
}
catch
{

}
result.Item.ProductionYear = date.Year;
result.Item.PremiereDate = date;
result.AddPerson(Utils.CreatePerson(json.uploader, json.channel_id));
Expand All @@ -217,7 +225,15 @@ public static MetadataResult<MusicVideo> YTDLJsonToMusicVideo(YTDLData json)
result.Item.Artists = new List<string> { json.artist };
result.Item.Album = json.album;
result.Item.Overview = json.description;
var date = DateTime.ParseExact(json.upload_date, "yyyyMMdd", null);
var date = new DateTime(1970, 1, 1);
try
{
date = DateTime.ParseExact(json.upload_date, "yyyyMMdd", null);
}
catch
{

}
result.Item.ProductionYear = date.Year;
result.Item.PremiereDate = date;
result.AddPerson(Utils.CreatePerson(json.uploader, json.channel_id));
Expand All @@ -239,7 +255,15 @@ public static MetadataResult<Episode> YTDLJsonToEpisode(YTDLData json)
};
result.Item.Name = json.title;
result.Item.Overview = json.description;
var date = DateTime.ParseExact(json.upload_date, "yyyyMMdd", null);
var date = new DateTime(1970, 1, 1);
try
{
date = DateTime.ParseExact(json.upload_date, "yyyyMMdd", null);
}
catch
{

}
result.Item.ProductionYear = date.Year;
result.Item.PremiereDate = date;
result.Item.ForcedSortName = date.ToString("yyyyMMdd") + "-" + result.Item.Name;
Expand Down

0 comments on commit 6d5a51e

Please sign in to comment.