async public Task <List <VN> > GetVNSearch(string searchString) { List <VN> result = new List <VN>(); string url = "https://vndb.org/v/all?sq=" + searchString; //await VNDB.sem.WaitAsync(); try { var web = new HtmlAgilityPack.HtmlWeb(); web.CaptureRedirect = true; HtmlDocument doc = await web.LoadFromWebAsync(url); var searchList = doc.DocumentNode.SelectNodes("//table[@class='stripe']/tr"); foreach (var search in searchList) { string id = search.SelectSingleNode("./td[@class='tc1']/a").GetAttributeValue("href", ""); string japName = search.SelectSingleNode("./td[@class='tc1']/a").GetAttributeValue("title", ""); string engName = search.SelectSingleNode("./td[@class='tc1']").InnerText; string date = search.SelectSingleNode("./td[@class='tc4']").InnerText; VN vn = new VN(ExtractId(id), new Name(engName, japName), date); result.Add(vn); } } catch (Exception e) { } //VNDB.sem.Release(); return(result); }
async private void VNListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { VN vn = (VN)VNListBox.SelectedItem; if (vn == null) { return; } // if(vn.Color != "yellow") { vn.Color = "green"; CharacterInfoListBox.Items.Clear(); CharacterInfoListBox.Items.Add(vn.characters[0].name); CharacterImage.Source = loadingImage; CharacterImage.Source = await _db.GetCharacterImage(vn.id, vn.characters[0].id); } }
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedTag = ((ComboBoxItem)NameOption.SelectedItem).Tag.ToString(); int option; if (int.TryParse(selectedTag, out option)) { voiceduck.Name.option = option; if (VNListBox != null) { VN vn = (VN)VNListBox.SelectedItem; var temp = VNListBox.ItemsSource; VNListBox.ItemsSource = null; VNListBox.ItemsSource = temp; if (vn != null) { VNListBox.SelectedItem = vn; } } _db.Update(); } }
private async void VNListBox2_SelectionChanged(object sender, SelectionChangedEventArgs e) { VN vn = (VN)VNListBox2.SelectedItem; if (vn == null) { return; } if (vn.characters.Count == 0) { await _db.GetMoreVNInfo(vn); } CharacterListBox.ItemsSource = null; CharacterListBox.ItemsSource = vn.characters; VNImage.Source = loadingImage; VNImage.Source = await _db.GetVNImage(vn.id, vn.image); VNInfoListBox.Items.Clear(); VNInfoListBox.Items.Add(vn.name.japName); VNInfoListBox.Items.Add(vn.name.engName); VNInfoListBox.Items.Add(vn.playTIme); VNInfoListBox.Items.Add(vn.developer); }
public void PushVN(VN vn) { vns.Add(vn); }
public async Task <VN> GetMoreVNInfo(VN vn) { string url = "https://vndb.org/v" + vn.id; await VNDB.sem.WaitAsync(); try { var web = new HtmlAgilityPack.HtmlWeb(); HtmlDocument doc = await web.LoadFromWebAsync(url); var details = doc.DocumentNode.SelectNodes("//div[@class='vndetails']/table/tr"); foreach (var detail in details) { var key = detail.SelectSingleNode("./td").InnerText; if (key == "Length") { vn.playTIme = detail.SelectNodes("./td")[1].InnerText; } else if (key == "Developer") { vn.developer = detail.SelectNodes("./td")[1].InnerText; } } var imagePath = doc.DocumentNode.SelectSingleNode("//div[@class='vnimg']//img"); if (imagePath != null) { vn.image = imagePath.GetAttributeValue("src", ""); } var characterList = doc.DocumentNode.SelectNodes("//div[contains(@class,'charsum_bubble')]"); foreach (var character in characterList) { int id = ExtractId(character.SelectSingleNode("./div[@class='name']/a").GetAttributeValue("href", "")); string engName = character.SelectSingleNode("./div[@class='name']/a").InnerText; string japName = character.SelectSingleNode("./div[@class='name']/a").GetAttributeValue("title", ""); Character _character = new Character(id, new Name(engName, japName)); if (character.SelectSingleNode("./div[@class='actor']") != null) { int voiceId = ExtractId(character.SelectSingleNode("./div[@class='actor']/a").GetAttributeValue("href", "")); string voiceJapName = character.SelectSingleNode("./div[@class='actor']/a").GetAttributeValue("title", ""); string voiceEngName = character.SelectSingleNode("./div[@class='actor']/a").InnerText; _character.voice = new Voice(voiceId, new Name(voiceEngName, voiceJapName)); if (voices.ContainsKey(voiceId)) { _character.voice.Nickname = voices[voiceId]; } } vn.characters.Add(_character); } } catch (Exception e) { } VNDB.sem.Release(); return(vn); }
async public Task <Voice> GetVoice(int id) { Voice voice = new Voice(id); string url = "https://vndb.org/s" + id; await VNDB.sem.WaitAsync(); try { var web = new HtmlAgilityPack.HtmlWeb(); HtmlDocument doc = await web.LoadFromWebAsync(url); var profile = doc.DocumentNode.SelectSingleNode("//body/div[@id='maincontent']/div[@class='mainbox staffpage']"); string engName; string japName; engName = profile.SelectSingleNode("./h1").InnerText; japName = profile.SelectSingleNode("./h2").InnerText; Name name = new Name(engName, japName); voice.PushName(name); /*var aliases = profile.SelectNodes(".//tr[@class='nostripe']"); * * foreach (var alias in aliases) * { * var elem = alias.SelectNodes("./td"); * engName = elem[0].InnerText; * japName = elem[1].InnerText; * name = new Name(engName, japName); * voice.PushName(name); * }*/ var vns = doc.DocumentNode.SelectNodes("//div[@class='mainbox browse staffroles']/table/tr"); foreach (var vn in vns) { var characterTag = vn.SelectSingleNode("./td[@class='tc3']/a"); if (characterTag == null) { continue; } var date = vn.SelectSingleNode("./td[@class='tc2']").InnerText; var titleTag = vn.SelectSingleNode("./td[@class='tc1']/a"); int characterId = ExtractId(characterTag.GetAttributeValue("href", "")); japName = characterTag.GetAttributeValue("title", ""); engName = characterTag.InnerText; var character = new Character(characterId, new Name(engName, japName)); voice.PushCharacter(character); int vnId = ExtractId(titleTag.GetAttributeValue("href", "")); japName = titleTag.GetAttributeValue("title", ""); engName = titleTag.InnerText; name = new Name(engName, japName); string color = "red"; if (File.Exists(CreateCachePath(vnId, characterId))) { color = "green"; } var _vn = new VN(vnId, name, date); _vn.characters.Add(character); _vn.Color = color; voice.PushVN(_vn); } voice.vns.Reverse(); } catch (Exception e) { AddLog(e.Message); VNDB.sem.Release(); await Task.Delay(1000); return(await GetVoice(id)); } VNDB.sem.Release(); return(voice); }