Tags and ID getter functional

This commit is contained in:
sevi-kun 2021-05-29 01:41:22 +02:00
parent d4cd70c7de
commit 1933774a24
8 changed files with 80 additions and 18 deletions

View File

@ -1,31 +1,83 @@
using System.Collections.Generic;
using System;
namespace Gallery
{
// Class Gallery Here are informations about the current random stored
public class Gallery{
public int Gallery_id { get; set; }
public string Tags_Section { get; set; }
public Gallery(int gallery_id, string HttpGalleryString){
Gallery_id = gallery_id;
Tags_Section = Tags(HttpGalleryString);
public int GalleryId { get; }
public List<string> Tags { get; }
public Gallery(string HttpGalleryString)
{
GalleryId = GetGalleryId(HttpGalleryString);
Tags = GetTags(HttpGalleryString);
}
public string Tags(string HttpGalleryString){
int index_of_tags = HttpGalleryString.IndexOf("Tags:");
int index_of_artists = HttpGalleryString.IndexOf("Artists:");
string tags_section = "";
private List<string> GetTags(string HttpGalleryString){
for (int i = index_of_tags; i < index_of_artists; i++){
tags_section += HttpGalleryString[i];
List<string> Tags = new List<string>();
string TagsSection = "";
string Tag = "";
int LastStartTagName;
int StartTagName;
int EndTagName;
string Pattern1 = "class=\"name\">";
string Pattern2 = "</span>";
int IndexOfTags = HttpGalleryString.IndexOf("Tags:");
int IndexOfArtists = HttpGalleryString.IndexOf("Artists:");
for (int i = IndexOfTags; i < IndexOfArtists; i++){
TagsSection += HttpGalleryString[i];
}
return tags_section;
StartTagName = TagsSection.IndexOf(Pattern1) + Pattern1.Length;
EndTagName = TagsSection.IndexOf(Pattern2, StartTagName);
do{
Tag = "";
for (int i = StartTagName; i < EndTagName; i++){
Tag += TagsSection[i];
}
Tags.Add(Tag);
LastStartTagName = StartTagName;
StartTagName = TagsSection.IndexOf(Pattern1, EndTagName) + Pattern1.Length;
EndTagName = TagsSection.IndexOf(Pattern2, StartTagName);
} while (LastStartTagName < StartTagName);
for (int i = 0; i < Tags.Count; i++){
if (Tags[i].Contains('=')){
Tags.Clear();
Tags.Add("Haha, kei Tags UmU");
}
}
return Tags;
}
private int GetGalleryId(string HttpGalleryString){
string Pattern1 = "#</span>";
string Pattern2 = "</h3>";
string GalleryId = "";
int StartIndex = HttpGalleryString.IndexOf(Pattern1) + Pattern1.Length;
for (int i = StartIndex; i < HttpGalleryString.IndexOf(Pattern2, StartIndex); i++){
GalleryId += HttpGalleryString[i];
}
return int.Parse(GalleryId);
}
}
}

View File

@ -3,6 +3,7 @@ using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
using System.IO;
using System.Collections.Generic;
using Gallery;
namespace rhentai{
@ -18,10 +19,19 @@ namespace rhentai{
// Get Result from HttpGetGallery
string HttpGalleryString = await HttpGetGallery();
var Tags = new List<string>();
string variable = new Gallery.Gallery(1,HttpGalleryString).Tags_Section;
Tags = new Gallery.Gallery(HttpGalleryString).Tags;
int ID = new Gallery.Gallery(HttpGalleryString).GalleryId;
Console.Write(variable);
foreach (var Tag in Tags)
{
Console.Write(Tag);
}
Console.WriteLine(ID);
Console.WriteLine();
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.