private static void UpdateSeriesAirdate(string seriesId, DateTime airdate) { // write the mxf entry SdMxf.GetSeriesInfo(seriesId.Substring(2, 8)).StartAirdate = airdate.ToString("yyyy-MM-dd"); // update cache if needed try { using (var reader = new StringReader(epgCache.GetAsset(seriesId))) { var serializer = new JsonSerializer(); var cached = (GenericDescription)serializer.Deserialize(reader, typeof(GenericDescription)); if (!string.IsNullOrEmpty(cached.StartAirdate)) { return; } cached.StartAirdate = airdate.Equals(DateTime.MinValue) ? "" : airdate.ToString("yyyy-MM-dd"); using (var writer = new StringWriter()) { serializer.Serialize(writer, cached); epgCache.UpdateAssetJsonEntry(seriesId, writer.ToString()); } } } catch { // ignored } }
private static void ProcessSeriesDescriptionsResponses() { // process request response foreach (var response in seriesDescriptionResponses) { ++processedObjects; ReportProgress(); var seriesId = response.Key; var description = response.Value; // determine which seriesInfo this belongs to var mxfSeriesInfo = SdMxf.GetSeriesInfo(seriesId.Substring(2, 8)); // populate descriptions mxfSeriesInfo.ShortDescription = description.Description100; mxfSeriesInfo.Description = description.Description1000; // serialize JSON directly to a file using (var writer = new StringWriter()) { try { var serializer = new JsonSerializer(); serializer.Serialize(writer, description); epgCache.AddAsset(seriesId, writer.ToString()); } catch { // ignored } } } }
private static void ProcessSeriesImageResponses() { // process request response foreach (var response in imageResponses) { ++processedObjects; ReportProgress(); var uid = response.ProgramId; if (response.Data == null) { continue; } MxfSeriesInfo series = null; if (response.ProgramId.StartsWith("SP")) { foreach (var key in sportsSeries.AllKeys) { if (!sportsSeries.Get(key).Contains(response.ProgramId)) { continue; } series = SdMxf.GetSeriesInfo(key); uid = key; } } else { series = SdMxf.GetSeriesInfo(response.ProgramId.Substring(2, 8)); } if (series == null || !string.IsNullOrEmpty(series.GuideImage) || series.extras.ContainsKey("artwork")) { continue; } // get series images var artwork = GetTieredImages(response.Data, new List <string> { "series", "sport", "episode" }); if (response.ProgramId.StartsWith("SP") && artwork.Count <= 0) { continue; } series.extras.Add("artwork", artwork); series.mxfGuideImage = GetGuideImageAndUpdateCache(artwork, ImageType.Series, uid); } }
private static void DetermineSeriesInfo(MxfProgram mxfProgram, SchedulesDirect.Program sdProgram) { // for sports programs that start with "SP", create a series entry based on program title // this groups them all together as a series for recordings MxfSeriesInfo mxfSeriesInfo; if (mxfProgram.ProgramId.StartsWith("SP")) { var name = mxfProgram.Title.Replace(' ', '_'); mxfSeriesInfo = SdMxf.GetSeriesInfo(name); sportsSeries.Add(name, mxfProgram.ProgramId); } else { // create a seriesInfo entry if needed mxfSeriesInfo = SdMxf.GetSeriesInfo(mxfProgram.ProgramId.Substring(2, 8), mxfProgram.ProgramId); if (!mxfSeriesInfo.extras.ContainsKey("tvdb") && sdProgram.Metadata != null) { foreach (var providers in sdProgram.Metadata) { if (providers.TryGetValue("TheTVDB", out var provider)) { mxfSeriesInfo.extras.Add("tvdb", provider.SeriesId.ToString()); } } } if (mxfProgram.ProgramId.StartsWith("SH")) { // go ahead and create/update the cache entry as needed if (epgCache.JsonFiles.ContainsKey(mxfProgram.ProgramId)) { try { using (var reader = new StringReader(epgCache.GetAsset(mxfProgram.ProgramId))) { var serializer = new JsonSerializer(); var cached = (GenericDescription)serializer.Deserialize(reader, typeof(GenericDescription)); if (cached.StartAirdate == null) { cached.StartAirdate = mxfProgram.OriginalAirdate ?? string.Empty; using (var writer = new StringWriter()) { serializer.Serialize(writer, cached); epgCache.UpdateAssetJsonEntry(mxfProgram.ProgramId, writer.ToString()); } } } } catch { // ignored } } else { var newEntry = new GenericDescription { Code = 0, Description1000 = mxfProgram.IsGeneric ? mxfProgram.Description : null, Description100 = mxfProgram.IsGeneric ? mxfProgram.ShortDescription : null, StartAirdate = mxfProgram.OriginalAirdate ?? string.Empty }; using (var writer = new StringWriter()) { var serializer = new JsonSerializer(); serializer.Serialize(writer, newEntry); epgCache.AddAsset(mxfProgram.ProgramId, writer.ToString()); } } } } mxfSeriesInfo.Title = mxfSeriesInfo.Title ?? mxfProgram.Title; mxfProgram.mxfSeriesInfo = mxfSeriesInfo; }