コード例 #1
0
        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)));
            }
        }
コード例 #2
0
ファイル: BatchWrite.cs プロジェクト: samhu70/Tsdb-1
        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;
        }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
        public void Add(ISerie <TKey, TEntry> serie)
        {
            var existingCollection = _series.GetEntries();

            foreach (var newEntry in serie.GetEntries())
            {
                existingCollection.Add(newEntry);
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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;
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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;
                }
            }
        }
コード例 #9
0
ファイル: TsdbWriteBatcher.cs プロジェクト: samhu70/Tsdb-1
        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);
            }
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
        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;
        }
コード例 #12
0
        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);
        }
コード例 #13
0
ファイル: Serie.cs プロジェクト: samhu70/Tsdb-1
 public void Insert(ISerie <TKey, TEntry> other)
 {
     Entries.AddRange(other.GetEntries());
 }
コード例 #14
0
 public static Task WriteAsync <TKey, TEntry>(this IStorage <TKey, TEntry> storage, ISerie <TKey, TEntry> serie)
     where TEntry : IEntry
 {
     return(storage.WriteAsync(new[] { serie }));
 }
コード例 #15
0
 public string GenerateNextEpisodeStream(ISerie serie)
 {
     return streamManager.GenerateNextEpisodeStream(serie, cachedStreams);
 }
コード例 #16
0
 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));
 }
コード例 #17
0
 public BatchWrite(ISerie <TKey, TEntry> series)
 {
     _tcs    = new TaskCompletionSource <bool>();
     _series = series;
 }
コード例 #18
0
 public string GenerateNextEpisodeStream(ISerie serie)
 {
     return(streamManager.GenerateNextEpisodeStream(serie, cachedStreams));
 }
コード例 #19
0
 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));
 }
コード例 #20
0
 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));
 }
コード例 #21
0
 public SerieController(ISerie contract) => _interface = contract;
コード例 #22
0
 public static Task WriteDirectlyToVolumeStorageAsync <TKey, TEntry>(this TsdbClient <TKey, TEntry> client, ISerie <TKey, TEntry> items)
     where TEntry : IEntry
 {
     return(client.WriteDirectlyToVolumeStorageAsync(new[] { items }));
 }
コード例 #23
0
 public bool Save(ISerie value)
 {
     _serieList.Add(value);
     return(true);
 }