Example #1
0
        private void SaveChaptersInDb(Hq hq)
        {
            lock (_lockThis4) {
                var chaptersInDb = _libraryContext.Chapter.Find().Where(x => x.Hq == hq).Execute();
                if (chaptersInDb == null)
                {
                    chaptersInDb = new List <Chapter>();
                }
                var newChapters = new List <Chapter>();
                if (hq.Chapters != null && hq.Chapters.Count > 0)
                {
                    foreach (var chap in hq.Chapters)
                    {
                        chap.Hq = hq;
                        if (!ContainsChapterIn(chaptersInDb, chap))
                        {
                            newChapters.Add(chap);
                        }
                    }

                    if (newChapters.Count() > 0)
                    {
                        _libraryContext.Chapter.Save(newChapters);
                    }
                }
            }
        }
Example #2
0
        public void SearchUpdates()
        {
            Task.Run(() => {
                var link = "";
                Dispatcher.Invoke(() => {
                    _detailsViewModel.UpdateVisibility = true;
                    _notification.Visibility           = true;
                    link = _detailsViewModel.DownloadInfo.Hq.Link;
                });
                if (!string.IsNullOrEmpty(link))
                {
                    var source = _sourceManager.GetSourceFromLink(link);
                    var hq     = new Hq();
                    source.GetInfo(link, out hq);
                    if (hq != null && !string.IsNullOrEmpty(hq.Link))
                    {
                        Dispatcher.Invoke(() => {
                            _detailsViewModel.UpdateList = hq.Chapters;
                        });
                    }
                }

                Dispatcher.Invoke(() => {
                    _notification.Visibility = false;
                });
            });
        }
        public override void Execute(Tuple <string, object, DetailsUserControl> dic)
        {
            var hq               = new Hq();
            var link             = "";
            var detailsViewModel = dic.Item3;
            var source           = _sourceManager.GetSources()[(dic.Item1)];

            if (dic.Item2 is Update update)
            {
                detailsViewModel.Hq = update.Hq;
                link = update.Hq.Link;
            }
            else if (dic.Item2 is Hq hqSelected)
            {
                detailsViewModel.Hq = hqSelected;
                link = hqSelected.Link;
            }
            if (!string.IsNullOrEmpty(link))
            {
                Task.Run(() => {
                    source.GetInfo(link, out hq);
                    Application.Current.Dispatcher.Invoke(() => {
                        detailsViewModel.Hq = hq;
                    });
                });
            }
        }
 public string CreateCache(Hq hq)
 {
     lock (_lock1) {
         if (string.IsNullOrEmpty((string)hq.CoverSource))
         {
             return(hq.CoverSource);
         }
         try {
             var pageSource = $"{directory}\\{StringHelper.RemoveSpecialCharacters(hq.Title)}{FormatPage(hq.CoverSource)}";
             if (!File.Exists(pageSource))
             {
                 ServicePointManager.DefaultConnectionLimit = 1000;
                 using (var webClient = new HttpClient()) {
                     //webClient.Proxy = null;
                     //webClient.DownloadFile(page.Source, pageSource);
                     using (var response = webClient.GetAsync(hq.CoverSource).Result) {
                         var imageByte = response.Content.ReadAsByteArrayAsync().Result;
                         using (var binaryWriter = new BinaryWriter(new FileStream(pageSource,
                                                                                   FileMode.Append, FileAccess.Write))) {
                             binaryWriter.Write(imageByte);
                         }
                     }
                 }
             }
             return(pageSource);
         } catch {
             return(hq.CoverSource);
         }
     }
 }
 public UpdateEventArgs(Hq hqToUpdate, DateTime startTime, DateTime endTime, TimeSpan totalTime)
 {
     HqToUpdate = hqToUpdate;
     StartTime  = startTime;
     EndTime    = endTime;
     TotalTime  = totalTime;
 }
 public void FollowHq(Hq hq)
 {
     lock (_lock1) {
         _context.Hq.Update(x => new { x.Followed }, true)
         .Where(x => x.Link == hq.Link).Execute();
         FollowUpdateEventHub.OnFollowingHq(this, new FollowEventArgs(hq, DateTime.Now));
     }
 }
 public string GetReadStatus(Hq hq)
 {
     if (_context.HqEntry.Find().Where(x => x.Hq == hq).GetOne() is HqEntry entry)
     {
         return(entry.ReadStatus);
     }
     return("Add to...");
 }
        public List <HqDownloadInfo> GetHqsDownloadInfo()
        {
            lock (_lock3) {
                CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, $"Processando arquivos..."));
                var list = new List <HqDownloadInfo>();
                foreach (var loc in DownloadConfiguration.DownloadLocations)
                {
                    var drInfo = new DirectoryInfo(loc);
                    if (drInfo != null)
                    {
                        var dirs = drInfo.GetDirectories();
                        if (dirs != null && dirs.Count() > 0)
                        {
                            CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, $"{dirs.Count()} diretoórios encontrados"));
                            foreach (var dir in dirs)
                            {
                                var downloadInfo = new HqDownloadInfo();
                                CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, $"Buscando informações de {dir.Name}"));
                                if (File.Exists($"{dir.FullName}\\DownloadInfo.Json"))
                                {
                                    using (StreamReader file = File.OpenText($"{dir.FullName}\\DownloadInfo.Json")) {
                                        JsonSerializer serializer = new JsonSerializer();
                                        downloadInfo = (HqDownloadInfo)serializer.Deserialize(file, typeof(HqDownloadInfo));
                                    }
                                    if (!string.IsNullOrEmpty(downloadInfo.Hq.Link))
                                    {
                                        if (_downloadContext.Hq.Find().Where(x => x.Link == downloadInfo.Hq.Link).Execute().FirstOrDefault() is Hq hq)
                                        {
                                            downloadInfo.Hq = hq;
                                            _downloadContext.HqDownloadInfo.SaveOrReplace(downloadInfo);
                                        }
                                    }
                                }
                                else
                                {
                                    var hq = new Hq {
                                        Title = dir.Name
                                    };
                                    downloadInfo = new HqDownloadInfo {
                                        Hq = hq, Path = dir.FullName
                                    };
                                }

                                if (downloadInfo != null && downloadInfo.Hq != null)
                                {
                                    CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, $"{downloadInfo.Hq.Title} adicionado!"));
                                    list.Add(downloadInfo);
                                }
                            }
                        }
                    }
                }

                return(list);
            }
        }
Example #9
0
        public void Download(DownloadItem downloadItem)
        {
            lock (_lock4) {
                var source = _sourceManager.GetSourceFromLink(downloadItem.Hq.Link);
                if (downloadItem.Hq.Chapters == null || downloadItem.Hq.Chapters.Count() == 0)
                {
                    var hq = downloadItem.Hq;
                    if ((_downloadContext.Chapter.Find().Where(x => x.Hq == hq && x.ToDownload == true).Execute() is List <Chapter> chaps) && chaps.Count > 0)
                    {
                        downloadItem.Hq.Chapters = chaps;
                    }
                    else
                    {
                        hq = new Hq();
                        source.GetInfo(downloadItem.Hq.Link, out hq);
                        if (hq != null)
                        {
                            downloadItem.Hq = hq;
                        }
                    }
                }

                downloadItem.DownloadStarted = DateTime.Now;
                DownloadEventHub.OnDownloadStart(this, new DownloadEventArgs(downloadItem));

                var hqDirectory      = _directoryHelper.CreateHqDirectory(downloadItem.DownloadLocation, downloadItem.Hq.Title);
                var numChapters      = downloadItem.Hq.Chapters.Count();
                var chapAtual        = 1;
                var failedToDownload = new List <String>();
                foreach (var chapter in downloadItem.Hq.Chapters)
                {
                    if (_stop)
                    {
                        DownloadEventHub.OnDownloadStop(this, new DownloadEventArgs(downloadItem, (downloadItem.DownloadFinished - downloadItem.DownloadStarted), failedToDownload));
                        break;
                    }
                    try {
                        downloadItem.ActualPage = null;
                        SaveChapter(source, downloadItem, chapter, chapAtual, numChapters, hqDirectory);
                    } catch (Exception e) {
                        DownloadEventHub.OnDownloadError(this, new DownloadErrorEventArgs(downloadItem, e, DateTime.Now));
                        failedToDownload.Add(chapter.Link);
                    }
                    chapAtual++;
                }
                downloadItem.DownloadFinished = DateTime.Now;
                var downloadInfo = new HqDownloadInfo(downloadItem);
                downloadInfo.Path         = hqDirectory;
                downloadItem.IsDownloaded = true;
                _downloadContext.DownloadList.SaveOrReplace(downloadItem);
                _downloadInfoHelper.SaveDownloadInfo(downloadInfo);
                DownloadEventHub.OnDownloadEnd(this, new DownloadEventArgs(downloadItem, (downloadItem.DownloadFinished - downloadItem.DownloadStarted), failedToDownload));
            }
        }
Example #10
0
 private static void ExcludeParent(Hq hq)
 {
     foreach (var chap in hq.Chapters)
     {
         chap.Hq = null;
         if (chap.Pages != null && chap.Pages.Count() > 0)
         {
             foreach (var page in chap.Pages)
             {
                 page.Chapter = null;
             }
         }
     }
 }
        public override Hq GetHqInfo(string link)
        {
            lock (Lock1) {
                try {
                    Site = new Uri(link);
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
                    var source = HtmlHelper.GetSourceCodeFromUrl(link);
                    var hqInfo = new Hq();
                    if (source == null)
                    {
                        throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq");
                    }
                    var title = source.QuerySelector(".manga-card .infos-wrapper .title")?.TextContent;
                    title = title.Replace("(BR)", "").Trim();
                    title = title.Replace("(PT-BR)", "").Trim();
                    title = title.Replace("(Novel)", "").Trim();
                    title = title.Replace("(Manhwa)", "").Trim();
                    title = title.Replace("(Manhua)", "").Trim();
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando informações de {title}"));
                    var coverEl  = source.QuerySelector(".manga-card .cover-wrapper img");
                    var synopsis = source.QuerySelector(".manga-card .infos-wrapper .sinopse")?.TextContent;
                    hqInfo.Title = title;
                    var img = coverEl?.GetAttribute("src");
                    if (!string.IsNullOrEmpty(img))
                    {
                        hqInfo.CoverSource = $"{Site.Scheme}:{img}";
                    }
                    hqInfo.Synopsis = synopsis?.Replace("\n", "").Trim();;
                    hqInfo.Link     = link;
                    var hqInfos = source.QuerySelectorAll(".manga-card .infos-wrapper .infos .info");
                    foreach (var info in hqInfos)
                    {
                        var txt = info.TextContent;
                        if (info.TextContent.Contains("Autor"))
                        {
                            hqInfo.Author = info.TextContent.Replace("Autor:", "").Trim();
                        }
                    }
                    var chapters = GetListChapters(source).Reverse <Chapter>().ToList();
                    hqInfo.Chapters = chapters;

                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto!"));
                    return(hqInfo);
                } catch (Exception e) {
                    OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, link, e));
                    return(null);
                }
            }
        }
Example #12
0
        public override Hq GetHqInfo(string link)
        {
            lock (Lock3) {
                try {
                    Uri site = new Uri(link);
                    BaseAdress = $"{site.Scheme}://{site.Host}";

                    var driver = BrowserHelper.GetDriver(link);
                    //Task.Delay(5000).Wait();
                    var pageSource = driver.PageSource;
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
                    IDocument source = HtmlHelper.GetSourceCodeFromHtml(pageSource);
                    driver.Quit();

                    var hqInfo = new Hq();

                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
                    if (source == null)
                    {
                        throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq");
                    }
                    var title = source.QuerySelector("div#series-data div.series-info span.series-title h1")?.TextContent;
                    title = title.Replace("(BR)", "").Trim();
                    title = title.Replace("(PT-BR)", "").Trim();
                    title = title.Replace("(Novel)", "").Trim();
                    title = title.Replace("(Manhwa)", "").Trim();
                    title = title.Replace("(Manhua)", "").Trim();
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando informações de {title}"));
                    var img      = source.QuerySelector("div.series-img div.cover img");
                    var author   = source.QuerySelector("div#series-data div.series-info span.series-author")?.TextContent;
                    var synopsis = source.QuerySelector("div#series-data div.series-info span.series-desc")?.TextContent;
                    hqInfo.Title       = title;
                    hqInfo.Author      = author.Replace("\n", "").Trim();
                    hqInfo.CoverSource = img?.GetAttribute("src");
                    hqInfo.Synopsis    = synopsis.Replace("\n", "").Trim();
                    hqInfo.Link        = link;
                    var lastchapter = source.QuerySelector("#chapter-list .list-of-chapters li a");
                    var chapters    = GetListChapters($"{BaseAdress}{lastchapter?.GetAttribute("href")}").Reverse <Chapter>().ToList();
                    hqInfo.Chapters = chapters;

                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto!"));
                    return(hqInfo);
                } catch (Exception e) {
                    OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, link, e));
                    return(null);
                }
            }
        }
Example #13
0
        public override Hq GetHqInfo(string link)
        {
            lock (Lock3) {
                try {
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
                    var driver     = BrowserHelper.GetDriver(link);
                    var pageSource = driver.PageSource;
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
                    IDocument source = HtmlHelper.GetSourceCodeFromHtml(pageSource);
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
                    driver.Quit();
                    var hqInfo = new Hq();
                    if (source == null)
                    {
                        throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq");
                    }
                    var title = source.QuerySelector("h1.title")?.TextContent;
                    title = title.Replace("(BR)", "").Trim();
                    title = title.Replace("(PT-BR)", "").Trim();
                    title = title.Replace("(Novel)", "").Trim();
                    title = title.Replace("(Manhwa)", "").Trim();
                    title = title.Replace("(Manhua)", "").Trim();
                    var img      = source.QuerySelector("#descricao img");
                    var synopsis = source.QuerySelector("#descricao article")?.TextContent;
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando informações de {title}"));
                    hqInfo.Title       = title;
                    hqInfo.CoverSource = img?.GetAttribute("src");
                    hqInfo.Synopsis    = synopsis.Replace("\n", "").Trim();
                    hqInfo.Link        = link; var hqInfos = source.QuerySelectorAll("#descricao div.content ul li");
                    foreach (var info in hqInfos)
                    {
                        if (info.TextContent.Contains("Autor"))
                        {
                            hqInfo.Author = info.TextContent.Replace("Autor:", "").Trim();
                        }
                    }
                    var chapters = GetListChapters(source).Reverse <Chapter>().ToList();
                    hqInfo.Chapters = chapters;

                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto!"));
                    return(hqInfo);
                } catch (Exception e) {
                    OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, link, e));
                    return(null);
                }
            }
        }
Example #14
0
 private T SaveHqInfo <T>(string url, Func <String, T> method) where T : ModelBase
 {
     lock (_lockThis3) {
         var hq = new Hq();
         hq = method.Invoke(url) as Hq;
         if (hq != null)
         {
             hq.TimeInCache           = DateTime.Now;
             hq.IsDetailedInformation = true;
             _libraryContext.Hq.Save(hq);
             var hqId = _libraryContext.Hq.Find().Where(x => x.Link == url).Execute().FirstOrDefault()?.Id;
             hq.Id = Convert.ToInt32(hqId);
             SaveChaptersInDb(hq);
             hq.Chapters = _libraryContext.Chapter.Find().Where(x => x.Hq == hq).Execute();
         }
         return(hq as T);
     }
 }
 public virtual void OpenDetails(Hq hq)
 {
     _detailsViewModel.Opened = false;
     _hqStatusView.Visibility = false;
     Task.Run(() => {
         Dispatcher.Invoke(() => {
             _notification.Visibility = true;
         });
         var hqDetails = new Hq();
         _actualSource.GetInfo(hq.Link, out hqDetails);
         Dispatcher.Invoke(() => {
             _hqStatusView.Entry      = _entryManager.GetHqEntry(hq);
             _hqStatusView.Hq         = hqDetails;
             _detailsViewModel.Hq     = hqDetails;
             _detailsViewModel.Opened = true;
             _notification.Visibility = false;
         });
     });
 }
Example #16
0
 public override Hq GetHqInfo(string link)
 {
     lock (Lock1) {
         try {
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
             var source = HtmlHelper.GetSourceCodeFromUrl(link);
             var hqInfo = new Hq();
             if (source == null)
             {
                 throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq");
             }
             var title = source.QuerySelector(".tamanho-bloco-perfil h2")?.TextContent;
             title = title.Replace("(BR)", "").Trim();
             title = title.Replace("(PT-BR)", "").Trim();
             title = title.Replace("(Novel)", "").Trim();
             title = title.Replace("(Manhwa)", "").Trim();
             title = title.Replace("(Manhua)", "").Trim();
             var img      = source.QuerySelector("img.img-thumbnail");
             var synopsis = source.QuerySelector(".tamanho-bloco-perfil div.panel-body")?.TextContent;
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando informações de {title}"));
             hqInfo.Title       = title;
             hqInfo.CoverSource = img?.GetAttribute("src");
             hqInfo.Link        = link;
             hqInfo.Synopsis    = synopsis?.Replace("\n", "").Trim();
             var hqInfos = source.QuerySelectorAll(".tamanho-bloco-perfil h4.manga-perfil");
             foreach (var info in hqInfos)
             {
                 if (info.TextContent.Contains("Autor"))
                 {
                     hqInfo.Author = info.TextContent.Replace("Autor:", "").Trim();
                 }
             }
             var chapters = GetListChapters(source).Reverse <Chapter>().ToList();
             hqInfo.Chapters = chapters;
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto!"));
             return(hqInfo);
         } catch (Exception e) {
             OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, link, e));
             return(null);
         }
     }
 }
Example #17
0
 private T SaveHqInfo <T>(string url, Func <String, T> method, bool isFinalized) where T : ModelBase
 {
     lock (_lockThis3) {
         var hq = new Hq();
         hq                       = method.Invoke(url) as Hq;
         hq.TimeInCache           = DateTime.Now;
         hq.CoverSource           = _coveCacheHelper.CreateCache(hq);
         hq.IsDetailedInformation = true;
         if (isFinalized)
         {
             hq.TimeInCache = new DateTime(2100, 1, 1);
         }
         var id = _libraryContext.Hq.SaveOrReplace(hq);
         hq.Id = Convert.ToInt32(id);
         SaveChaptersInDb(hq);
         hq.Chapters = _libraryContext.Chapter.Find().Where(x => x.Hq == hq).Execute();
         _cache[url] = hq;
         return(hq as T);
     }
 }
Example #18
0
 public void AddToDownloadList(Hq hq, string directory)
 {
     lock (_lock1) {
         foreach (var chap in hq.Chapters)
         {
             chap.ToDownload = true;
         }
         _downloadContext.Chapter.Update(hq.Chapters);
         if (hq != null && !string.IsNullOrEmpty(hq.Link))
         {
             var downloaditem = new DownloadItem {
                 Hq = hq, DownloadLocation = directory, IsDownloaded = false
             };
             if (!_downloadList.Contains(downloaditem))
             {
                 _downloadList.Add(downloaditem);
                 _downloadContext.DownloadList.Save(downloaditem);
             }
         }
     }
 }
Example #19
0
 public void AddToDownloadList(Hq hq, string directory)
 {
     lock (_lock1) {
         if (!string.IsNullOrWhiteSpace(directory) && hq != null && !string.IsNullOrEmpty(hq.Link))
         {
             ExcludeParent(hq);
             var downloaditem = new DownloadItem {
                 Hq = hq.ToBytes(), DownloadLocation = directory, IsDownloaded = false
             };
             if (!_downloadList.Contains(downloaditem))
             {
                 _downloadList.Add(downloaditem);
                 _downloadContext.DownloadList.Save(downloaditem);
                 downloaditem.Id = _downloadContext.DownloadList.Find()
                                   .Where(x => x.DownloadLocation == directory)
                                   .Execute().FirstOrDefault().Id;
                 SaveLocation(directory);
             }
         }
     }
 }
        public dynamic GetHeroHq(int idMarvelHero, int limit, int offset)
        {
            List <Hq> hqList = new List <Hq>();
            dynamic   output = new ExpandoObject();

            try
            {
                var unprocessedOutput = _marvelClient.GetList($"characters/{idMarvelHero}/comics", limit, offset);

                int size  = Convert.ToInt32(unprocessedOutput.data.count);
                int total = Convert.ToInt32(unprocessedOutput.data.total);

                for (int j = 0; j < size; j++)
                {
                    Hq hq = new Hq();
                    hq.IdMarvel    = unprocessedOutput.data.results[j].id;
                    hq.Title       = unprocessedOutput.data.results[j].title;
                    hq.Description = unprocessedOutput.data.results[j].description;
                    hq.ImageLink   = $"{unprocessedOutput.data.results[j].thumbnail.path}.{unprocessedOutput.data.results[j].thumbnail.extension}";
                    hq.Price       = unprocessedOutput.data.results[j].prices[0].price;
                    if (unprocessedOutput.data.results[j].urls.Count > 0)
                    {
                        hq.WikiLink = unprocessedOutput.data.results[j].urls[0].url;
                    }
                    hqList.Add(hq);
                }

                output.list   = hqList;
                output.total  = total;
                output.size   = size;
                output.limit  = limit;
                output.offset = offset;
            }
            catch
            {
                _notificator.Resolve(new Notification(NotificationType.Erro, message: "An integration error has occur"));
            }

            return(output);
        }
Example #21
0
 public void SearchDetails()
 {
     Task.Run(() => {
         var result = new List <Hq>();
         var link   = "";
         var title  = "";
         Dispatcher.Invoke(() => {
             _notification.Visibility = true;
             link  = _editModel.Hq.Link;
             title = _editModel.Hq.Title;
         });
         if (!string.IsNullOrEmpty(link))
         {
             var source = _sourceManager.GetSourceFromLink(link);
             var hq     = new Hq();
             source.GetInfo(link, out hq);
             if (hq != null && !string.IsNullOrEmpty(hq.Link))
             {
                 result.Add(hq);
                 _entryManager.AddTo(ReadStatus.PRETENDO_LER, hq);
             }
             Dispatcher.Invoke(() => {
                 _editModel.Results          = result;
                 _editModel.ResultVisibility = true;
             });
         }
         else if (!string.IsNullOrEmpty(title))
         {
             var source = _sourceManager.GetSpurce(SourcesEnum.MangaHost) as MangaHostSourceManager;
             source.Search(title, out result);
             Dispatcher.Invoke(() => {
                 _editModel.Results          = result;
                 _editModel.ResultVisibility = true;
             });
         }
         Dispatcher.Invoke(() => {
             _notification.Visibility = false;
         });
     });
 }
Example #22
0
        public void DeleteHq()
        {
            var id   = _detailsViewModel.DownloadInfo.Hq.Id;
            var path = _detailsViewModel.DownloadInfo.Path;
            var hq   = new Hq {
                Id = id
            };

            _hqStatus.Hq = null;
            _detailsViewModel.DownloadInfo = null;
            _list = null;
            var info = new HqDownloadInfo {
                Hq = hq, Path = path
            };

            Task.Run(() => {
                _downloadManager.DeleteDownloadInfo(info, true);
                Dispatcher.Invoke(() => {
                    NavigationManager.GoBack();
                });
            });
        }
        public dynamic GetHq(int idMarvel)
        {
            var hq = new Hq();

            try
            {
                var unprocessedOutput = _marvelClient.GetObject("comics", idMarvel);


                hq.IdMarvel    = unprocessedOutput.data.results[0].id;
                hq.Title       = unprocessedOutput.data.results[0].title;
                hq.Description = unprocessedOutput.data.results[0].description;
                hq.Price       = unprocessedOutput.data.results[0].prices[0].price;
                hq.ImageLink   = $"{unprocessedOutput.data.results[0].thumbnail.path}.{unprocessedOutput.data.results[0].thumbnail.extension}";
                hq.WikiLink    = unprocessedOutput.data.results[0].urls[0].url;
            }
            catch
            {
                _notificator.Resolve(new Notification(NotificationType.Erro, message: "An integration error has occur"));
            }

            return(hq);
        }
Example #24
0
        public override Hq GetHqInfo(string link)
        {
            lock (Lock1) {
                try {
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
                    var source = HtmlHelper.GetSourceCodeFromUrl(link);
                    var hqInfo = new Hq();
                    if (source == null)
                    {
                        throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq");
                    }
                    var title = source.QuerySelector(".title-widget .entry-title")?.TextContent;
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando informações de {title}"));
                    var img      = source.QuerySelector("div#page img");
                    var synopsis = source.QuerySelector(".pull-left article")?.TextContent;
                    hqInfo.Title       = CleanTitle(title);
                    hqInfo.CoverSource = img?.GetAttribute("src");
                    hqInfo.Synopsis    = synopsis?.Replace("\n", "").Trim().Replace("\n", "").Trim().Replace("'", "`").Trim();
                    hqInfo.Link        = link; var hqInfos = source.QuerySelectorAll("ul.descricao  li");
                    foreach (var info in hqInfos)
                    {
                        if (info.TextContent.Contains("Autor"))
                        {
                            hqInfo.Author = info.TextContent.Replace("Autor:", "").Trim().Replace("\n", "").Trim().Replace("'", "`").Trim();
                        }
                    }
                    var chapters = GetListChapters(source).Reverse <Chapter>().ToList();
                    hqInfo.Chapters = chapters;

                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto!"));
                    return(hqInfo);
                } catch (Exception e) {
                    OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, link, e));
                    return(null);
                }
            }
        }
Example #25
0
        public List <Chapter> GetUpdates(string hqLink)
        {
            var update    = new List <Chapter>();
            Hq  hq        = null;
            var startTime = DateTime.Now;

            if (!(_followContext.Hq.FindOne(hqLink) is Hq followedHq) || !followedHq.Followed)
            {
                return(update);
            }
            hq = followedHq;
            FollowUpdateEventHub.OnUpdateStart(this, new UpdateEventArgs(hq, startTime));
            var hqInfo = _sourceManager.GetInfo <Hq>(hqLink, false, -1);

            foreach (var chap in hqInfo.Chapters)
            {
                if (!hq.Chapters.Contains(chap))
                {
                    update.Add(chap);
                }
            }

            return(update);
        }
Example #26
0
 public override LibraryPage GetLibrary(String linkPage)
 {
     lock (Lock2) {
         try {
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando Biblioteca..."));
             var driver     = BrowserHelper.GetDriver(linkPage);
             var pageSource = driver.PageSource;
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
             IDocument source = HtmlHelper.GetSourceCodeFromHtml(pageSource);
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
             driver.Quit();
             BrowserHelper.CloseDriver();
             var hqs = new List <Hq>();
             if (source == null)
             {
                 throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq");
             }
             var hqsEl = source.QuerySelectorAll("#mangas .two");
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"{hqsEl.Count()} mangas encontrados!"));
             var nextPage      = source.QuerySelector("#mangas a.next")?.GetAttribute("href");
             var finalizadosEl = source.QuerySelectorAll("#mangas ul.nav-tabs li a");
             var finalizedPage = "";
             foreach (var el in finalizadosEl)
             {
                 if (el.TextContent.Contains("Completos"))
                 {
                     finalizedPage = el.GetAttribute("href");
                 }
             }
             var lethers    = source.QuerySelectorAll("#mangas .letters a");
             var letherLink = new Dictionary <string, string>();
             foreach (var lether in lethers)
             {
                 letherLink[lether.TextContent] = lether.GetAttribute("href");
             }
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Preparando para retornar mangas!"));
             foreach (var hq in hqsEl)
             {
                 var title = hq.QuerySelector("h3")?.TextContent;
                 title = CleanTitle(title);
                 var img  = hq.QuerySelector("a img")?.GetAttribute("src");
                 var link = hq.QuerySelector("h3 a")?.GetAttribute("href");
                 if (!string.IsNullOrEmpty(link))
                 {
                     var manga = new Hq {
                         Link = link, Title = title, CoverSource = img
                     };
                     if (!hqs.Contains(manga))
                     {
                         hqs.Add(manga);
                         OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, manga, $"{title} Adicionado"));
                     }
                 }
             }
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto"));
             return(new LibraryPage {
                 Link = linkPage, Hqs = hqs, NextPage = nextPage,
                 FinalizedPage = finalizedPage, Letras = letherLink
             });
         } catch (Exception e) {
             BrowserHelper.CloseDriver();
             OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, linkPage, e));
             return(null);
         }
     }
 }
Example #27
0
 public HqEntry GetHqEntry(Hq hq) =>
 _context.HqEntry.Find().Where(x => x.Hq == hq).GetOne();
Example #28
0
 public void AddTo(ReadStatus status, Hq hq) =>
 _context.HqEntry.SaveOrReplace(new HqEntry {
     Hq = hq, ReadStatus = status.ToString()
 });
Example #29
0
 public override LibraryPage GetLibrary(String linkPage)
 {
     lock (Lock2) {
         try {
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, "Processando os Mangas..."));
             Uri site = new Uri(linkPage);
             BaseAdress = $"{site.Scheme}://{site.Host}";
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Abrindo Internet Explorer"));
             var driver     = BrowserHelper.GetDriver(linkPage);
             var pageSource = driver.PageSource;
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
             IDocument source = HtmlHelper.GetSourceCodeFromHtml(pageSource);
             driver.Quit();
             var hqs = new List <Hq>();
             if (source == null)
             {
                 throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq");
             }
             var hqsEl = source.QuerySelectorAll(".content-wraper ul.seriesList li");
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"{hqsEl.Count()} mangas encontrados!"));
             var nextPage      = source.QuerySelector("ul.content-pagination li.next a")?.GetAttribute("href");
             var finalizadosEl = source.QuerySelectorAll("#subtopnav ul#menu-titulos li a");
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando links"));
             var finalizedPage = "";
             foreach (var el in finalizadosEl)
             {
                 var test = el.TextContent;
                 if (el.TextContent.Contains("Recém Finalizados"))
                 {
                     finalizedPage = el.GetAttribute("href");
                 }
             }
             var lethers    = source.QuerySelectorAll("#az-order div a");
             var letherLink = new Dictionary <string, string>();
             foreach (var lether in lethers)
             {
                 letherLink[lether.TextContent.Trim()] = $"{BaseAdress}{lether.GetAttribute("href")}";
             }
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Preparando para retornar mangas!"));
             foreach (var hq in hqsEl)
             {
                 var title = hq.QuerySelector(".series-title h1")?.TextContent;
                 title = title.Replace("(BR)", "").Trim();
                 title = title.Replace("(PT-BR)", "").Trim();
                 title = title.Replace("(Novel)", "").Trim();
                 title = title.Replace("(Manhwa)", "").Trim();
                 title = title.Replace("(Manhua)", "").Trim();
                 var imgEl = hq.QuerySelector(".cover-image")?.GetAttribute("style");
                 imgEl = imgEl?.Replace("background-image: url(", "");
                 imgEl = imgEl?.Replace(")", "");
                 imgEl = imgEl?.Replace("'", "");
                 imgEl = imgEl?.Replace("\"", "");
                 var img  = imgEl?.Replace(";", "");
                 var link = hq.QuerySelector("a")?.GetAttribute("href");
                 if (title != null)
                 {
                     OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados de {title}"));
                     if (!img.Contains(site.Scheme))
                     {
                         img = $"{BaseAdress}{img}";
                     }
                     if (!string.IsNullOrEmpty(link))
                     {
                         var manga = new Hq {
                             Link = $"{BaseAdress}{link}", Title = title, CoverSource = img
                         };
                         if (!hqs.Contains(manga))
                         {
                             hqs.Add(manga);
                             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, manga, $"{title} Adicionado"));
                         }
                     }
                 }
             }
             OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto"));
             return(new LibraryPage {
                 Link = linkPage, Hqs = hqs, NextPage = $"{BaseAdress}{nextPage}",
                 FinalizedPage = $"{BaseAdress}{finalizedPage}", Letras = letherLink
             });
         } catch (Exception e) {
             OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, linkPage, e));
             return(null);
         }
     }
 }
        public override List <Update> GetUpdates(string url)
        {
            lock (Lock7) {
                try {
                    Site       = new Uri(url);
                    BaseAdress = $"{Site.Scheme}://{Site.Host}";
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando Atualizações..."));
                    var source = HtmlHelper.GetSourceCodeFromUrl(url);
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página"));
                    var updates  = new List <Update>();
                    var chapters = new List <Chapter>();
                    var dic      = new Dictionary <string, (Hq Hq, List <Chapter> Chappters)>();
                    if (source == null)
                    {
                        throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq");
                    }
                    var updatesEl = source.QuerySelectorAll("div.cap-card");
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"{updatesEl.Count()} mangas encontrados!"));
                    foreach (var update in updatesEl)
                    {
                        var chapterTitle = update.QuerySelector(".title-area")?.TextContent;
                        if (!string.IsNullOrEmpty(chapterTitle))
                        {
                            chapterTitle = chapterTitle.Replace("\n", "").Trim();
                            var lastIndex = chapterTitle.LastIndexOf("-");
                            var title     = "";
                            if (lastIndex == -1)
                            {
                                title = chapterTitle;
                            }
                            else
                            {
                                title = chapterTitle.Substring(0, lastIndex).Trim();
                                title = title.Replace("(BR)", "").Trim();
                                title = title.Replace("(PT-BR)", "").Trim();
                                title = title.Replace("(Novel)", "").Trim();
                                title = title.Replace("(Manhwa)", "").Trim();
                                title = title.Replace("(Manhua)", "").Trim();
                            }
                            var hqLink      = update.QuerySelector("a.container")?.GetAttribute("href");
                            var chapterLink = update.QuerySelector("a.read-wrapper")?.GetAttribute("href");

                            if (!string.IsNullOrEmpty(hqLink) && !string.IsNullOrEmpty(chapterLink))
                            {
                                if (dic.ContainsKey(hqLink))
                                {
                                    var chap = new Chapter {
                                        Title = chapterTitle, Link = $"{BaseAdress}{chapterLink}"
                                    };
                                    dic[hqLink].Chappters.Add(chap);
                                }
                                else
                                {
                                    var img = update.QuerySelector("a.container img")?.GetAttribute("src");
                                    var hq  = new Hq {
                                        Link = $"{BaseAdress}{hqLink}", Title = title, CoverSource = $"{Site.Scheme}:{img}"
                                    };
                                    var chap = new Chapter {
                                        Title = chapterTitle, Link = $"{BaseAdress}{chapterLink}"
                                    };
                                    chapters = new List <Chapter>();
                                    chapters.Add(chap);
                                    dic[hqLink] = (hq, chapters);
                                }
                            }
                        }
                    }

                    foreach (var updt in dic)
                    {
                        var up = new Update {
                            Hq = updt.Value.Hq, Chapters = updt.Value.Chappters
                        };
                        updates.Add(up);
                        OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, up.Hq, $"{up.Hq.Title} Adicionado"));
                    }
                    OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto"));
                    return(updates);
                } catch (Exception e) {
                    OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, url, e));
                    return(null);
                }
            }
        }