private async void GoToSearch_Click(object sender, RoutedEventArgs e) { ContinueToSearch.IsEnabled = false; SearchTabItem.IsSelected = await Task.Run(() => AnimepaheExtractor.InitializePuppeteer()); ContinueToSearch.IsEnabled = true; }
public Extract() { InitializeComponent(); StartExtraction_SetWhenEnableable(); DataContext = ExtractCM; ExtractCM.Title = CurrentSerie.Title; IsEnableable = AnimepaheExtractor.InitializePuppeteer(); }
public async Task <bool> GatherEpisodeLinksData(int serieId) { EpisodeLinksData = await AnimepaheExtractor.GetEpisodeLinksData(serieId, Session); if (EpisodeLinksData != null) { return(true); } else { return(false); } }
public static async void ReadyToExtract(Serie _serie, Range _range = null) { AnimePaheExtractorWPF.Extract.CurrentSerie = _serie; DefExtract = new Extract(); _mainWindow.ExtractTabItem.Content = DefExtract; _mainWindow.MainMenuTabControl.SelectedIndex = 2; // Bring puppeteer to life, from the nothing it's become AnimepaheExtractor.InitializePuppeteer(); IList <Episode> _episodes = await AnimepaheExtractor.GetEpisodesList(Extract.CurrentSerie.Id, _range); foreach (Episode _episode in _episodes) { bool _gathered = await _episode.GatherEpisodeLinksData(Extract.CurrentSerie.Id); if (_gathered) { ExtractGridItem _item = new ExtractGridItem() { EpisodeNumber = _episode.EpisodeNumber, Quality = _episode.EpisodeLinksData[0].Quality, FanSub = _episode.EpisodeLinksData[0].FanSub, Progress = 0, StatusEnum = ExtractionStatus.Queued, Episode = _episode }; DefExtract.ExtractsGrid.DataContext = _item; DefExtract.ExtractsGrid.Items.Add(_item); DefExtract.ExtractsGrid_AddItem(_item); } } // After gathering all episodes, extract could start DefExtract.AllEpisodesReadyToExtract = true; }
void DataWindow_Closing(object sender, CancelEventArgs e) { try { // Try to destroy everything AnimepaheExtractor.FinishPuppeteer(); if (DefExtract != null && DefExtract.Downloader != null) { DefExtract.Downloader.StopDownload(); if (DefExtract.Downloader.dThread != null) { DefExtract.Downloader.dThread.Abort(); } } } catch { } // Terminate process System.Environment.Exit(1); }
public void Startup() { // Jokes keep my mind calm, that and Animes/Games OST while I code garbage. I like lofi lately as well SetStatusBar(StatusBarEnum.Default); string rawDataURL = "https://pastebin.com" + "/raw/" + "pKZLJWPe"; string rawData = AnimepaheExtractor.GetRequest(rawDataURL, 3); if (rawData != string.Empty) { Thread.Sleep(1000); var dataArray = rawData.Split('\n'); Random _random = new Random(); int rIndex = _random.Next(dataArray.Length); StatusBar = dataArray[rIndex]; } else { StatusBar = "Nothing to see here :("; } Application.Current.Dispatcher.Invoke(() => MainWindow._mainWindow.ContinueToSearch.IsEnabled = true); }
private async Task ExtractStart() { // This block suspends the task until the episodes list is full do { Thread.Sleep(500); }while (!AllEpisodesReadyToExtract); if (CurrentGridItem != null) { Downloader = new Downloader(); Downloader.ProgressChanged += _downloader_ProgressChanged; Downloader.Completed += _downloader_Completed; CurrentGridItem.StatusEnum = ExtractionStatus.Starting; // Sets Serie path string _title = CurrentSerie.Title; string _epNumber = CurrentGridItem.Episode.EpisodeNumber.ToString(); foreach (var _c in Path.GetInvalidFileNameChars()) { _title = _title.Replace(_c, '-'); } foreach (var _c in Path.GetInvalidFileNameChars()) { _epNumber = _epNumber.Replace(_c, '-'); } DirectoryInfo _directory = Directory.CreateDirectory($"{ Directory.GetCurrentDirectory()}\\{_title}"); string _fileName = $"{_directory.FullName}\\Episode {_epNumber}.mp4"; // File already exists, then ERROR if (File.Exists(_fileName)) { CurrentGridItem.StatusEnum = ExtractionStatus.Error; // Next file SetNextFile(); } else { // Continue if file doesn't exist // Get url string _urlToExtract = null; while (_urlToExtract == null) { try { AnimepaheExtractor.InitializePuppeteer(); // Try to bring to life the browser _urlToExtract = await AnimepaheExtractor.GetUrlToExtract(CurrentGridItem.Episode.EpisodeLinksData[0].Url); } catch { Thread.Sleep(500); } } // Aborts last thread if (currentDownloadThread != null) { currentDownloadThread.Abort(); } // Starts Download Downloader.DownloadFile(_urlToExtract, _fileName); CurrentGridItem.StatusEnum = ExtractionStatus.Downloading; } } }
private async void Search_Click(object sender, RoutedEventArgs e) { if (SearchCriteria.Text.Length > 3) { SearchCriteria.IsEnabled = false; SearchButton.IsEnabled = false; Results = await AnimepaheExtractor.Search(SearchCriteria.Text); SearchCriteria.IsEnabled = true; SearchButton.IsEnabled = true; IList <SearchResult> searchResultsList = new List <SearchResult>(); SearchResultsStackPanel.Children.Clear(); SearchResultPreview.Children.Clear(); if (Results.Total > 0) { foreach (Dictionary <string, string> _data in Results.Data) { _data.TryGetValue("id", out string _id); _data.TryGetValue("title", out string _title); _data.TryGetValue("type", out string _type); _data.TryGetValue("episodes", out string _episodes); _data.TryGetValue("season", out string _season); _data.TryGetValue("poster", out string _uriImage); SearchResult _r = new SearchResult { Id = _id, Title = _title, Type = _type, Episodes = _episodes, Season = _season, }; _r.SearchResultDropDown.Click += (s, ev) => { _r.ExtractOptions.Visibility = Visibility.Visible; Poster.Source = _r.Image; if (LastSearchResultClicked != null && LastSearchResultClicked != _r) { LastSearchResultClicked.ExtractOptions.Visibility = Visibility.Collapsed; } LastSearchResultClicked = _r; }; _r.StartExtraction.Click += (s, ev) => { Serie _serie = new Serie(_r.Title, Convert.ToInt32(_r.Id)); if (_r.ExtractAllRadioButton.IsChecked == true) { MainWindow.ReadyToExtract(_serie); } else { Range _range = new Range() { From = Convert.ToInt32(_r.FromTextBox.Text), To = Convert.ToInt32(_r.ToTextBox.Text) }; MainWindow.ReadyToExtract(_serie, _range); } }; /* * Values: * id * slug * title * type * episodes * status * season * score * image * relevance */ // Temporary disabled //_r.Image = await AnimepaheExtractor.GetImage(_uriImage); SearchResultsStackPanel.Children.Add(_r); } SearchResultPreview.Children.Add(Poster); } else { TextBlock _tError = new TextBlock { Text = "Nothing was found.", FontSize = 32, Foreground = Brushes.White }; TextBlock _tHelp = new TextBlock { Text = "Maybe it's just a typo (I'm used to it). Try another search criteria.", FontSize = 18, Foreground = Brushes.DarkGray }; SearchResultsStackPanel.Children.Add(_tError); SearchResultsStackPanel.Children.Add(_tHelp); } UpdateLayout(); } }