Exemplo n.º 1
0
        public void SingleThreaded_FirstSongNotFound()
        {
            var songsPath = Path.Combine(DefaultSongsPath, "SingleThreaded_FirstSongNotFound");

            if (Directory.Exists(songsPath))
            {
                Directory.Delete(songsPath, true);
            }
            var downloader = new SongDownloader(defaultConfig, null, null, songsPath);
            var testSong1  = new PlaylistSong("A65C4B43A6BC543AC6B534A65CB43B6AC354", "NotFoundSong", "fff0", "MapperName");
            var testSong2  = new PlaylistSong("19f2879d11a91b51a5c090d63471c3e8d9b7aee3", "Believer", "b", "rustic");

            downloader.DownloadQueue.Enqueue(testSong1);
            downloader.DownloadQueue.Enqueue(testSong2);
            var results = downloader.RunDownloaderAsync(1).Result;

            Assert.AreEqual(2, results.Count);
            Assert.AreEqual(404, results[0].DownloadResult.HttpStatusCode);
            Assert.AreEqual(true, results[1].Successful);
        }
Exemplo n.º 2
0
        public IEnumerator <WaitUntil> ScrapeSongsCoroutine()
        {
            Logger.log?.Debug("Starting ScrapeSongsCoroutine");
            var readTask = Downloader.RunReaders();
            var readWait = new WaitUntil(() => readTask.IsCompleted);

            yield return(readWait);

            var downloadTask = Downloader.RunDownloaderAsync(Plugin.config.Value.MaxConcurrentDownloads);
            var downloadWait = new WaitUntil(() => downloadTask.IsCompleted);

            yield return(downloadWait);

            PlaylistManager.WriteAllPlaylists();
            HistoryManager.WriteToFile();
            int numDownloads = downloadTask.Result.Count;

            IsRunning = false;
            Logger.log?.Info($"BeatSync finished reading feeds, downloaded {(numDownloads == 1 ? "1 song" : numDownloads + " songs")}.");
            Plugin.config.Value.LastRun = DateTime.Now;
            Plugin.configProvider.Store(Plugin.config.Value);
            Plugin.config.Value.ResetFlags();
            StartCoroutine(UpdateLevelPacks());
        }