public string GenerateNextEpisodeStream(ISerie serie, List <IStreamItem> cachedStreams) { foreach (var cachedStream in cachedStreams) { var url = this.DynamicStreamCheck(cachedStream, serie); if (!string.IsNullOrEmpty(url)) { return(url); } } if (serie.Type == "Movie") { return(string.Format("https://www.google.com/#q={0}+stream&safe=off", serie.Title)); } if (serie.Progress.Season == null) { return(string.Format("https://www.google.com/#q={0}+episode+{1}+stream&safe=off", serie.Title, this.GetNextEpisode(serie.Progress))); } else { return(string.Format("https://www.google.com/#q={0}+season+{1}+episode+{2}+stream&safe=off", serie.Title, serie.Progress.Season, this.GetNextEpisode(serie.Progress))); } }
public void Add(ISerie <TKey, TEntry> serie) { var newEntries = serie.GetEntries(); ISerie <TKey, TEntry> existing; if (_series.TryGetValue(serie.GetKey(), out existing)) { var existingEntries = existing.GetEntries(); var list = existingEntries as List <TEntry>; if (list != null) { list.AddRange(newEntries); } else { foreach (var entry in newEntries) { existingEntries.Add(entry); } } } else { _series.Add(serie.GetKey(), serie); } _count += newEntries.Count; }
public string GenerateNextEpisodeStream(ISerie serie, List<IStreamItem> cachedStreams) { foreach (var cachedStream in cachedStreams) { var url = this.DynamicStreamCheck(cachedStream, serie); if (!string.IsNullOrEmpty(url)) { return url; } } if (serie.Type == "Movie") { return string.Format("https://www.google.com/#q={0}+stream&safe=off", serie.Title); } if (serie.Progress.Season == null) { return string.Format("https://www.google.com/#q={0}+episode+{1}+stream&safe=off", serie.Title, this.GetNextEpisode(serie.Progress)); } else { return string.Format("https://www.google.com/#q={0}+season+{1}+episode+{2}+stream&safe=off", serie.Title, serie.Progress.Season, this.GetNextEpisode(serie.Progress)); } }
public void Add(ISerie <TKey, TEntry> serie) { var existingCollection = _series.GetEntries(); foreach (var newEntry in serie.GetEntries()) { existingCollection.Add(newEntry); } }
public void CanGenerateNextEpisodeStream() { const string expectedGeneratedStream = "https://www.google.com/#q=Test+stream&safe=off"; ISerie serieMock = MockRepository.GenerateMock <ISerie>(); serieMock.Stub(x => x.Title).Return("Test"); serieMock.Stub(x => x.Progress).Return(new Progress(0, 1, 1)); serieMock.Stub(x => x.Type).Return("Movie"); string actualGeneratedStream = mainController.GenerateNextEpisodeStream(serieMock); Assert.AreEqual(expectedGeneratedStream, actualGeneratedStream); }
public QueryResult(ISerie serie, IEnumerable<object> samples) { if (serie == null) { throw new ArgumentNullException("serie"); } if (samples == null) { throw new ArgumentNullException("samples"); } this.Serie = serie; this.Samples = samples; }
static void GenericSerie <T>(ISerie <T> serie) { Console.WriteLine("Generating '{0}' ::", serie.Name); int iteration = 1; while (Console.ReadKey(true).Key != ConsoleKey.Escape) { Console.WriteLine("..."); T item = serie.GenerateNext(); Console.WriteLine("Iteration #{0}: {1}", iteration, item); iteration++; } Console.WriteLine("Done."); Console.ReadKey(true); }
public void Draw(ISerie serie, DrawingVisual visual, Size size, SeriesDataRange dataRange) { using (var dc = visual.RenderOpen()) { if (!serie.Any()) { return; } int count = 0; foreach (var _ in serie) { if (++count > 1) { break; } } if (count < 2) { return; } Point?previous = null; var pen = new Pen(serie.Stroke, serie.StrokeThickness); foreach (var point in serie) { var next = new Point( this.Proportion(point.XValue, dataRange.MinX, dataRange.MaxX) * size.Width, size.Height - this.Proportion(point.YValue, dataRange.MinY, dataRange.MaxY) * size.Height); if (!previous.HasValue) { previous = next; continue; } dc.DrawLine(pen, previous.Value, next); previous = next; } } }
public Task Write(ISerie <TKey, TEntry> serie) { lock ( _sync ) { if (_currentBatch == null) { _currentBatch = new BatchWrite <TKey, TEntry>(); } if (_currentBatch.Count + serie.GetEntries().Count > _maxBatchSize) { _batches.Enqueue(_currentBatch); _currentBatch = new BatchWrite <TKey, TEntry>(); } _currentBatch.Add(serie); return(_currentBatch.Task); } }
public Task Write(ISerie <TKey, TEntry> serie) { lock ( _sync ) { var key = serie.GetKey(); if (!_queued.TryGetValue(key, out var existingBatchWrite)) { existingBatchWrite = new BatchWrite <TKey, TEntry>(serie); _queued.Add(key, existingBatchWrite); _keys.AddLast(key); } else { existingBatchWrite.Add(serie); } _queuedCount += serie.GetEntries().Count; return(existingBatchWrite.Task); } }
private string DynamicStreamCheck(IStreamItem cachedStream, ISerie serie) { var title = serie.Title; var progress = serie.Progress; var correctedTitle = title.Replace(" ", cachedStream.WhitespaceReplacement); var hasTitle = cachedStream.Website.Contains("{0}"); var hasSeason = cachedStream.Website.Contains("{1}"); var hasEpisode = cachedStream.Website.Contains("{2}"); if (!hasTitle && !hasSeason && !hasEpisode) { return string.Empty; } if (hasTitle && !hasSeason && !hasEpisode) { return string.Format(cachedStream.Website, correctedTitle); } if (hasTitle && hasSeason && !hasEpisode) { return string.Format(cachedStream.Website, correctedTitle, progress.Season); } if (hasTitle && hasEpisode && !hasSeason) { var stream = cachedStream.Website.Replace("{2}", "{1}"); if (this.IsValidUrl(string.Format(stream, correctedTitle, progress.CurrentEpisode))) { return string.Format(stream, correctedTitle, this.GetNextEpisode(progress)); } } if (this.IsValidUrl(string.Format(cachedStream.Website, correctedTitle, progress.Season, progress.CurrentEpisode))) { return string.Format(cachedStream.Website, correctedTitle, progress.Season, this.GetNextEpisode(progress)); } return string.Empty; }
private string DynamicStreamCheck(IStreamItem cachedStream, ISerie serie) { var title = serie.Title; var progress = serie.Progress; var correctedTitle = title.Replace(" ", cachedStream.WhitespaceReplacement); var hasTitle = cachedStream.Website.Contains("{0}"); var hasSeason = cachedStream.Website.Contains("{1}"); var hasEpisode = cachedStream.Website.Contains("{2}"); if (!hasTitle && !hasSeason && !hasEpisode) { return(string.Empty); } if (hasTitle && !hasSeason && !hasEpisode) { return(string.Format(cachedStream.Website, correctedTitle)); } if (hasTitle && hasSeason && !hasEpisode) { return(string.Format(cachedStream.Website, correctedTitle, progress.Season)); } if (hasTitle && hasEpisode && !hasSeason) { var stream = cachedStream.Website.Replace("{2}", "{1}"); if (this.IsValidUrl(string.Format(stream, correctedTitle, progress.CurrentEpisode))) { return(string.Format(stream, correctedTitle, this.GetNextEpisode(progress))); } } if (this.IsValidUrl(string.Format(cachedStream.Website, correctedTitle, progress.Season, progress.CurrentEpisode))) { return(string.Format(cachedStream.Website, correctedTitle, progress.Season, this.GetNextEpisode(progress))); } return(string.Empty); }
public void Insert(ISerie <TKey, TEntry> other) { Entries.AddRange(other.GetEntries()); }
public static Task WriteAsync <TKey, TEntry>(this IStorage <TKey, TEntry> storage, ISerie <TKey, TEntry> serie) where TEntry : IEntry { return(storage.WriteAsync(new[] { serie })); }
public string GenerateNextEpisodeStream(ISerie serie) { return streamManager.GenerateNextEpisodeStream(serie, cachedStreams); }
public static Task PublishAsync <TKey, TEntry>(this IPublish <TKey, TEntry> publish, ISerie <TKey, TEntry> serie, PublicationType publicationType) where TEntry : IEntry { return(publish.PublishAsync(new[] { serie }, publicationType)); }
public BatchWrite(ISerie <TKey, TEntry> series) { _tcs = new TaskCompletionSource <bool>(); _series = series; }
public string GenerateNextEpisodeStream(ISerie serie) { return(streamManager.GenerateNextEpisodeStream(serie, cachedStreams)); }
public static Task WriteAsync <TKey, TEntry>(this TsdbClient <TKey, TEntry> client, ISerie <TKey, TEntry> serie, PublicationType publicationType, Publish publish, bool useTemporaryStorageOnFailure) where TEntry : IEntry { return(client.WriteAsync(new[] { serie }, publicationType, publish, useTemporaryStorageOnFailure)); }
public static Task WriteAsync <TKey, TEntry>(this TsdbClient <TKey, TEntry> client, ISerie <TKey, TEntry> serie, PublicationType publicationType) where TEntry : IEntry { return(client.WriteAsync(new[] { serie }, publicationType)); }
public SerieController(ISerie contract) => _interface = contract;
public static Task WriteDirectlyToVolumeStorageAsync <TKey, TEntry>(this TsdbClient <TKey, TEntry> client, ISerie <TKey, TEntry> items) where TEntry : IEntry { return(client.WriteDirectlyToVolumeStorageAsync(new[] { items })); }
public bool Save(ISerie value) { _serieList.Add(value); return(true); }