Beispiel #1
0
        private async void GoToSearch_Click(object sender, RoutedEventArgs e)
        {
            ContinueToSearch.IsEnabled = false;
            SearchTabItem.IsSelected   = await Task.Run(() => AnimepaheExtractor.InitializePuppeteer());

            ContinueToSearch.IsEnabled = true;
        }
Beispiel #2
0
        public Extract()
        {
            InitializeComponent();
            StartExtraction_SetWhenEnableable();

            DataContext = ExtractCM;

            ExtractCM.Title = CurrentSerie.Title;

            IsEnableable = AnimepaheExtractor.InitializePuppeteer();
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        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;
                }
            }
        }