コード例 #1
0
        /// <summary>
        /// method to parse html file from bloodcat website
        /// </summary>
        /// <param name="html">Search criteria</param>
        /// <returns></returns>
        public async Task Parse(string html)
        {
            var contentToParse = await websiteLoader.GetPageContent(html);

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(contentToParse);
            var node = htmlDoc.DocumentNode.SelectNodes("//a[@href]");

            foreach (var n in node)
            {
                if (n.Attributes.Count < 2)
                {
                    continue;
                }
                else
                {
                    string address = n.Attributes[1].Value;
                    string name    = n.InnerHtml;
                    Regex  regex   = new Regex(@"^s/\d");
                    Match  match   = regex.Match(address);

                    if (match.Success)
                    {
                        string mapNumber        = new string(address.Skip(2).ToArray());
                        string thumbnailAddress = $"//b.ppy.sh/thumb/{mapNumber}l.jpg";
                        address = "https://bloodcat.com/osu/" + address;
                        SongsInfo infoToAdd = new SongsInfo(name, thumbnailAddress, address);
                        SongsList.Add(infoToAdd);
                    }
                }
            }
        }
コード例 #2
0
        // GET: SongsInfo
        public async Task <ActionResult> Index()
        {
            var songsInfo = new SongsInfo();
            var table     = TableStorageService.ConnectToTable(Constants.CurrentSongTableName);
            var queryCS   = await table.ExecuteQuerySegmentedAsync(new TableQuery <AzureTableSong>(), null);

            songsInfo.CurrentSong = queryCS.Results.FirstOrDefault();

            var bytes = await ImageService.DownloadImage(songsInfo.CurrentSong.OriginalGame);

            if (bytes == null)
            {
                bytes = await ImageService.DownloadImage(Constants.DefaultBlobImage);
            }

            songsInfo.GamePicture = bytes;

            var songs = await TableStorageService.RetrieveAllEntities <AzureTableSong>(Constants.QueueTableName);

            songsInfo.SongsQueue = songs.OrderBy(x => x.Position);
            return(View(songsInfo));
        }