private Airing MapAiring(AiringLong airingView) { var airingStart = GetEarliestStartDate(airingView); var airingEnd = GetLatestEndDate(airingView); var linearStart = GetLinearDateTime(airingView); var airingData = new Airing { AiringId = airingView.AssetId, Name = airingView.Name, Type = airingView.Type, AiringTitles = MapTitleIds(airingView), AiringDestinations = MapDestinations(airingView), Brand = airingView.Network, StartDateTime = airingStart, EndDateTime = airingEnd, LinearDateTime = linearStart, ESTStartDateTime = airingStart.HasValue ? (DateTime?)ConvertToEst(airingStart.Value) : null, ESTEndDateTime = airingEnd.HasValue ? (DateTime?)ConvertToEst(airingEnd.Value) : null, ESTLinearDateTime = linearStart.HasValue ? (DateTime?)ConvertToEst(linearStart.Value) : null, BCStartDateTime = airingStart.HasValue ? (DateTime?)ConvertToBc(ConvertToEst(airingStart.Value)) : null, BCEndDateTime = airingEnd.HasValue ? (DateTime?)ConvertToBc(ConvertToEst(airingEnd.Value)) : null, BCLinearDateTime = linearStart.HasValue ? (DateTime?)ConvertToBc(ConvertToEst(linearStart.Value)) : null, UpdatedDateTime = DateTime.UtcNow }; return(airingData); }
public void Report(Airing airing, bool isActiveAiringStatus) { foreach (var destination in airing.Flights.SelectMany(f => f.Destinations.Distinct(new DestinationComparer()))) { Report(airing.AssetId, isActiveAiringStatus, 14, destination.ExternalId); } }
public Airing GetBy(string assetId, AiringCollection getFrom = AiringCollection.CurrentOrExpiredCollection) { var query = Query.EQ("AssetId", assetId); Airing airing = null; switch (getFrom) { case AiringCollection.CurrentOrExpiredCollection: airing = _currentCollection.FindOne(query) ?? GetFromExpiredCollection(query); break; case AiringCollection.CurrentCollection: airing = _currentCollection.FindOne(query); break; case AiringCollection.ExpiredCollection: airing = GetFromExpiredCollection(query); break; case AiringCollection.DeletedCollection: airing = _deletedCollection.FindOne(query); break; } if (airing == null) { throw new AiringNotFoundException(string.Format("Airing does not exist in {0} collection.", getFrom == AiringCollection.DeletedCollection ? "deleted" : (getFrom == AiringCollection.ExpiredCollection ? "expired" : "current/expired"))); } return(airing); }
private static async Task Play(EurosportPlayer player, Airing airing) { var handler = await player.GetStream(airing.BestPlaybackUrl); handler.NewVideoSequence += async(source, part) => { await File.WriteAllBytesAsync(string.Format("{0:00000}.ts", part.SequenceNumber), part.RawData); Console.WriteLine($"Downloaded {part.SequenceNumber}, {part.PartsInQueue} still queued"); }; await handler.Start(); }
private IEnumerable <int> GetDestinations(string assetId, IEnumerable <DF_Destination> destinations) { Airing releasedAsset = ReleasedAssetByAssetId(assetId).FirstOrDefault(); if (releasedAsset == null) { return(new List <int>()); } List <string> des = GetDestinations(releasedAsset).ToList(); var mappedDestinations = destinations.Where(d => des.Contains(d.Name)); return(mappedDestinations.Where(d => ShouldAssetBeDeliveredToDestination(releasedAsset, d)) .Select(d => d.DestinationID) .Distinct()); }
private static IList <string> GetDestinations(Airing source) { if (!source.Flights.Any()) { return(new List <string>()); } var destinations = new List <string>(); foreach (var flight in source.Flights) { destinations.AddRange(flight.Destinations.Select(d => d.Name)); } return(destinations.Distinct().ToList()); }
public Airing Save(Airing airing, bool hasImmediateDelivery, bool updateHistorical) { var currentCollection = _database.GetCollection <Airing>(DataStoreConfiguration.CurrentAssetsCollection); var expiredCollection = _database.GetCollection <Airing>(DataStoreConfiguration.ExpiredAssetsCollection); var historicalCollection = _database.GetCollection <Airing>(DataStoreConfiguration.HistoricalAssetsCollection); if (updateHistorical) { var airingInString = JsonConvert.SerializeObject(airing); var historyAiring = JsonConvert.DeserializeObject <Airing>(airingInString); historyAiring.Id = ObjectId.Empty; historicalCollection.Save(historyAiring); } airing.Id = ObjectId.Empty; var query = Query.EQ("AssetId", airing.AssetId); bool hasActiveFlights = airing.Flights.Any(e => e.End > DateTime.UtcNow); var currentAsset = currentCollection.FindOne(query); var expiredAsset = expiredCollection.FindOne(query); if (currentAsset != null || hasActiveFlights || hasImmediateDelivery) { currentCollection.Update(query, Update.Replace(airing), UpdateFlags.Upsert); if (expiredAsset != null) { expiredCollection.Remove(query); _dfStatusMover.MoveToCurrentCollection(airing.AssetId); } return(_getAiringQuery.GetBy(airing.AssetId)); } expiredCollection.Update(query, Update.Replace(airing), UpdateFlags.Upsert); return(_getAiringQuery.GetBy(airing.AssetId, AiringCollection.ExpiredCollection)); }
public Airing Delete(Airing airing) { var currentCollection = _database.GetCollection <CurrentAiringId>(DataStoreConfiguration.CurrentAssetsCollection); var deletedCollection = _database.GetCollection <CurrentAiringId>(DataStoreConfiguration.DeletedAssetsCollection); var expiredCollection = _database.GetCollection <CurrentAiringId>(DataStoreConfiguration.ExpiredAssetsCollection); currentCollection.Remove(Query.EQ("AssetId", airing.AssetId)); expiredCollection.Remove(Query.EQ("AssetId", airing.AssetId)); deletedCollection.Update(Query.EQ("AssetId", airing.AssetId), Update.Replace(airing), UpdateFlags.Upsert); _dfStatusMover.MoveToExpireCollection(airing.AssetId); return(airing); }
private bool ShouldAssetBeDeliveredToDestination(Airing releasedAsset, DF_Destination destination) { #region setup to made logic easier to read var isHd = releasedAsset.Flags.Hd; var isCx = releasedAsset.Flags.Cx; var acceptsCxContent = destination.AcceptsCXContent.HasValue && destination.AcceptsCXContent.Value; var acceptsNonCxContent = destination.AcceptsNCXContent.HasValue && destination.AcceptsNCXContent.Value; var acceptsHdContent = destination.AcceptsHDContent.HasValue && destination.AcceptsHDContent.Value; var acceptsSdContent = destination.AcceptsSDContent.HasValue && destination.AcceptsSDContent.Value; #endregion return((acceptsCxContent && acceptsHdContent && isHd && isCx) || (acceptsCxContent && acceptsSdContent && !isHd && isCx) || (acceptsNonCxContent && acceptsHdContent && isHd && !isCx) || (acceptsNonCxContent && acceptsSdContent && !isHd && !isCx)); }
public List <FileModel.File> Get(string airingId) { var fileCollection = _database.GetCollection <FileModel.File>("File"); var assetCollection = _database.GetCollection <Airing>("currentassets"); // Find Airing with the corresponding airingId var airingQuery = Query.EQ("AssetId", airingId); Airing airing = assetCollection.Find(airingQuery).FirstOrDefault(); if (airing == null) { throw new AiringNotFoundException(string.Format("Airing with id {0} does not exist in collection.", airingId)); } // Verify if MediaId is empty String mediaId = string.Empty; if (!String.IsNullOrWhiteSpace(airing.MediaId)) { mediaId = airing.MediaId; } // Extract title and series id's var titleIds = airing.Title.TitleIds .Where(t => t.Authority == "Turner" && t.Value != null) .Select(t => int.Parse(t.Value)) .ToList(); if (airing.Title.Series.Id.HasValue) { titleIds.Add(airing.Title.Series.Id.Value); } var query = Query.Or(Query.EQ("MediaId", mediaId), Query.EQ("AiringId", airingId), Query.In("TitleId", new BsonArray(titleIds))); return(fileCollection.Find(query).Select(c => { c.AiringId = airingId; return c; }).ToList()); }
private string GetTranslatedUrl(string sourceUrl, BLPathModel.PathTranslation pt, Airing airing) { var result = sourceUrl.Replace(pt.Source.BaseUrl, pt.Target.BaseUrl); if (!string.IsNullOrEmpty(pt.Source.Brand) && pt.Source.Brand.Equals(airing.Network, StringComparison.OrdinalIgnoreCase)) { return(result); } else if (string.IsNullOrEmpty(pt.Source.Brand)) { return(result); } else { return(string.Empty); } }
/// <summary> /// Retrieve status notifications for both file/video and filetype/status. Both /// are based on queue settings /// </summary> /// <param name="statusQueues"></param> /// <param name="airing"></param> /// <returns>list of status change notifications</returns> private List <ChangeNotification> GetNotificationList(Airing airing, List <string> statuses) { List <Queue> activeQueues = _queueSvc.GetByStatus(true); IList <string> queuesTobeNotified = new List <string>(); List <string> notifiableStatuses = statuses; List <ChangeNotification> changeNotifications = new List <ChangeNotification>(); // Prepare for file/video notification // Find all queues that are subscribed for video change notification // and prepare for notification List <string> videoQueueNames = activeQueues .Where(q => q.DetectVideoChanges) .Select(q => q.Name).ToList(); foreach (string queue in videoQueueNames) { if (airing.DeliveredTo.Contains(queue) || airing.IgnoredQueues.Contains(queue) || airing.ChangeNotifications.Select(x => x.QueueName).Contains(queue)) { ChangeNotification newChangeNotification = new ChangeNotification(); newChangeNotification.QueueName = queue; newChangeNotification.ChangeNotificationType = ChangeNotificationType.File.ToString(); newChangeNotification.ChangedDateTime = DateTime.UtcNow; changeNotifications.Add(newChangeNotification); } } // Prepare for filetype/status notifications foreach (string statusname in notifiableStatuses) { List <Queue> subscribedQueues = activeQueues.Where(x => x.StatusNames.Contains(statusname)).ToList(); foreach (string deliveryQueue in subscribedQueues.Select(e => e.Name)) { if (airing.DeliveredTo.Contains(deliveryQueue) || airing.IgnoredQueues.Contains(deliveryQueue) || airing.ChangeNotifications.Select(x => x.QueueName).Contains(deliveryQueue)) { if (!changeNotifications .Where(c => { return(c.QueueName.Contains(deliveryQueue) && c.ChangeNotificationType == ChangeNotificationType.Status.ToString()); }).IsNullOrEmpty()) { ChangeNotification existingChangeNotification = changeNotifications.Where(c => { return(c.QueueName.Contains(deliveryQueue) && c.ChangeNotificationType == ChangeNotificationType.Status.ToString()); }).FirstOrDefault(); existingChangeNotification.ChangedProperties.Add(statusname); } else { ChangeNotification newChangeNotification = new ChangeNotification(); newChangeNotification.QueueName = deliveryQueue; newChangeNotification.ChangeNotificationType = ChangeNotificationType.Status.ToString(); newChangeNotification.ChangedProperties.Add(statusname); newChangeNotification.ChangedDateTime = DateTime.UtcNow; changeNotifications.Add(newChangeNotification); } } } } return(changeNotifications); }
/// <summary> /// Reset's the delivery queue for the airing /// </summary> /// <param name="statusQueues"></param> /// <param name="airing"></param> /// <returns>list of status change notifications</returns> private List <ChangeNotification> ResetDeliveryQueue(List <Queue> statusQueues, Airing airing) { IList <string> queuesTobeNotified = new List <string>(); List <string> airingStatusNames = airing.Status.Keys.ToList(); List <ChangeNotification> changeNotifications = new List <ChangeNotification>(); foreach (string statusname in airingStatusNames) { var subscribedQueues = statusQueues.Where(x => x.StatusNames.Contains(statusname)); foreach (var deliveryQueue in subscribedQueues.Select(e => e.Name)) { if (airing.DeliveredTo.Contains(deliveryQueue) || airing.IgnoredQueues.Contains(deliveryQueue) || airing.ChangeNotifications.Select(x => x.QueueName).Contains(deliveryQueue)) { if (changeNotifications.Select(x => x.QueueName).Contains(deliveryQueue)) { var existingChangeNotification = changeNotifications.Where(x => x.QueueName == deliveryQueue).FirstOrDefault(); existingChangeNotification.ChangedProperties.Add(statusname); } else { ChangeNotification newChangeNotification = new ChangeNotification(); newChangeNotification.QueueName = deliveryQueue; newChangeNotification.ChangeNotificationType = ChangeNotificationType.Status.ToString(); newChangeNotification.ChangedProperties.Add(statusname); newChangeNotification.ChangedDateTime = DateTime.UtcNow; changeNotifications.Add(newChangeNotification); } } } } return(changeNotifications); }
private IList <ChangeNotification> GetChangeNotifications(IList <string> queueNames, Airing currentAiring) { IList <ChangeNotification> changeNotifications = new List <ChangeNotification>(); foreach (var queueName in queueNames) { if (currentAiring.DeliveredTo.Contains(queueName) || currentAiring.ChangeNotifications.Select(x => x.QueueName).Contains(queueName) || currentAiring.IgnoredQueues.Contains(queueName)) { ChangeNotification changenotification = new ChangeNotification(); changenotification.QueueName = queueName; changenotification.ChangeNotificationType = ChangeNotificationType.Package.ToString(); changenotification.ChangedDateTime = DateTime.UtcNow; changeNotifications.Add(changenotification); } } return(changeNotifications); }
public override int GetHashCode() { return Name.GetHashCode() ^ Genre.GetHashCode() ^ Studio.GetHashCode() ^ Actor1.GetHashCode() ^ Actor2.GetHashCode() ^ StartDate.GetHashCode() ^ Episodes.GetHashCode() ^ EndDate.GetHashCode() ^ Airing.GetHashCode(); }