Пример #1
0
        private static async Task UpdateMetaData(IMetaDataParser parser)
        {
            var options = new ProgressBarOptions
            {
                ForegroundColor   = ConsoleColor.Yellow,
                BackgroundColor   = ConsoleColor.DarkYellow,
                ProgressCharacter = '─'
            };

            var memCache = new MemFile();

            var metaData = new MetaDataService(new List <IMetaDataParser> {
                parser
            }, Client2.GetDocumentAsync);


            var             first = true;
            ConsoleProgress pb    = null;

            IProgress <double> GetProgress(string context)
            {
                pb?.Dispose();
                if (first)
                {
                    first = false;
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine();
                }

                return(pb = new ConsoleProgress(options, context));
            }

            metaData.ReportProgressFactory = GetProgress;

            await metaData.DownloadMetaData(parser.ProviderName, CancellationToken.None);
        }
Пример #2
0
 public HeaderParserTest()
 {
     this._headerParser = new HeaderParser();
 }
Пример #3
0
        private static async Task GetMetaData(IMetaDataParser parser)
        {
            var options = new ProgressBarOptions
            {
                ForegroundColor   = ConsoleColor.Yellow,
                BackgroundColor   = ConsoleColor.DarkYellow,
                ProgressCharacter = '─'
            };

            var        cts    = new CancellationTokenSource();
            var        mgr    = new MangaDownloader(null, new List <ISeriesParser>());
            PageGetter getter = Client2.GetDocumentAsync;
            var        doc    = await getter("https://www.mangaeden.com/en/en-manga/naruto/");

            //var doc = await getter("http://manganelo.com/manga/read_naruto_manga_online_free3");
            var metaData = parser.GetMetaData(doc);

            var service = new MetaDataService(new List <IMetaDataParser>()
            {
                parser
            });

            var wasCalled = false;

            IProgress <double> GetProgress(string context)
            {
                if (context == "Instances" && !wasCalled)
                {
                    wasCalled = true;
                    Console.WriteLine($"Handling {context}");
                    Console.WriteLine();
                    return(new ConsoleProgress(options, context));
                }

                if (context == "MetaData")
                {
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine($"Handling {context}");
                    Console.WriteLine();
                    return(new ConsoleProgress(options, context));
                }

                cts.Cancel();
                return(null);
            }

            service.ReportProgressFactory = GetProgress;
            var t = service.Start(parser.ProviderName, cts.Token);

            try
            {
                await t;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            var res2 = await service.GetMetaData();

            var test   = res2.Where(a => a.metaData.Genres.HasFlag(Genre.MartialArts)).ToList();
            var unused = Enum.GetValues(typeof(Genre)).Cast <Genre>().Where(e => e != Genre.None).ToDictionary(g => g, _ => false);

            foreach (var valueTuple in res2)
            {
                foreach (var genre in valueTuple.metaData.Genres.Split())
                {
                    if (unused.ContainsKey(genre))
                    {
                        unused[genre] = true;
                    }
                }
            }

            var areNotUsed = unused.Where(kvp => !kvp.Value).Select(kvp => kvp.Key).ToList();

            Console.Read();
        }