Beispiel #1
0
        private static void Tests()
        {
            //ScrapedDataProvider.Initialize();

            WebUtils.Initialize(5);

            ScrapedDataProvider.BeatSaverSongs.WriteFile();
            var bsReader = new BeatSaverReader();
            //var bsSongs = bsReader.GetSongsFromFeed(new BeatSaverFeedSettings((int)BeatSaverFeeds.LATEST) { MaxPages = 10, searchOnline = true });
            var authorSongs = BeatSaverReader.GetSongsByAuthor("ruckasdfus");

            var song = ScrapedDataProvider.Songs.Values.Where(s => s.ScoreSaberInfo.Any(d => d.Value.uid == 155732)).FirstOrDefault();

            var found           = ScrapedDataProvider.TryGetSongByKey("3f57", out SongInfo badSong, false);
            var CustomSongsPath = Path.Combine(OldConfig.BeatSaberPath, "Beat Saber_Data", "CustomLevels");
            var tempFolder      = new DirectoryInfo(Path.Combine(Path.GetTempPath(), badSong.key + ".zip"));
            var outputFolder    = new DirectoryInfo(Path.Combine(CustomSongsPath, $"{badSong.key} ({Utilities.MakeSafeFilename(badSong.songName)} - {Utilities.MakeSafeFilename(badSong.authorName)})"));
            var job             = new DownloadJob(badSong, tempFolder.FullName, outputFolder.FullName);

            job.RunJobAsync().Wait();
            var br     = new BeastSaberReader("Zingabopp", 3);
            var text   = WebUtils.GetPageText("https://bsaber.com/wp-json/bsaber-api/songs/?bookmarked_by=Zingabopp&page=1");
            var bSongs = br.GetSongsFromPage(text);


            //ScrapedDataProvider.Initialize();


            //ScrapedDataProvider.Initialize();
            var bsScrape = ScrapedDataProvider.BeatSaverSongs;
            var ssScrape = ScrapedDataProvider.ScoreSaberSongs;

            ScrapedDataProvider.TryGetSongByHash("501f6b1bddb2af72abda0f1e6b7b89cb1eb3db67", out SongInfo deletedSong);
            //var job = new DownloadJob(deletedSong, "test.zip", @"ScrapedData\test");
            //var jobTask = job.RunJobAsync();
            //jobTask.Wait();
            bsScrape.AddOrUpdate(null);
            var resp = WebUtils.HttpClient.GetAsync("https://beatsaver.com/api/maps/detail/b");

            Task.WaitAll(resp);

            var rateHeaders = resp.Result.Headers.Where(h => h.Key.StartsWith("Rate-Limit")).ToDictionary(x => x.Key, x => x.Value.FirstOrDefault());
            var remoteTime  = resp.Result.Headers.Date;
            var rateInfo    = WebUtils.ParseRateLimit(rateHeaders);

            Console.WriteLine("Reset Timespan: " + rateInfo.TimeToReset.ToString());
            foreach (var item in resp.Result.Headers)
            {
                Console.WriteLine($"{item.Key}: {string.Join("|", item.Value)}");
            }

            var trending    = ScrapedDataProvider.Songs.Values.Where(s => s.ScoreSaberInfo.Count > 0).OrderByDescending(s => s.ScoreSaberInfo.Values.Select(ss => ss.scores).Aggregate((a, b) => a + b)).Take(100);
            var detTrending = trending.Select(s => (s.ScoreSaberInfo.Values.Select(ss => ss.scores).Aggregate((a, b) => a + b), s)).ToList();
        }
Beispiel #2
0
        private static void Tests()
        {
            var thing = new ScrappedSong();

            Web.HttpClientWrapper.Initialize(5);
            List <ScrappedSong> scrapedDict;

            using (StreamReader file = File.OpenText(@"C:\Users\Jared\source\repos\SyncSaberService\SyncSaberService\bin\Debug\ScrapedData\combinedScrappedData.json"))
            {
                JsonSerializer serializer = new JsonSerializer();
                scrapedDict = (List <ScrappedSong>)serializer.Deserialize(file, typeof(List <ScrappedSong>));
            }


            DownloadJob testJob = new DownloadJob(new SongInfo("111-111", "testName", "", "testAuthor"), "temp", "CustomSongs");

            var testTask = testJob.RunJobAsync();

            testTask.Wait();
            var searchTest = BeatSaverReader.Search("6A097D39A5FA94F3B736E6EEF5A519A2", BeatSaverReader.SearchType.hash);
            var testReader = new ScoreSaberReader();
            var sssongs    = testReader.GetSSSongsFromPage(HttpClientWrapper.GetPageText("https://scoresaber.com/api.php?function=get-leaderboards&cat=3&limit=5&page=39&ranked=1"));

            foreach (var sssong in sssongs)
            {
                sssong.PopulateFields();
            }
            var songs = testReader.GetSongsFromFeed(new ScoreSaberFeedSettings(0)
            {
                MaxPages = 10
            });

            SongInfo song = new SongInfo("18750-20381", "test", "testUrl", "testAuthor");

            song.PopulateFields();
            var test  = song["key"];
            var test2 = song["id"];
            var test3 = song["uploaderId"];
        }