Cleanup and created Gallery.cs
This commit is contained in:
parent
00cd7b3dcc
commit
d4cd70c7de
22
Gallery.cs
22
Gallery.cs
@ -4,10 +4,28 @@ namespace Gallery
|
||||
// Class Gallery Here are informations about the current random stored
|
||||
public class Gallery{
|
||||
public int Gallery_id { get; set; }
|
||||
public Gallery(int gallery_id){
|
||||
public string Tags_Section { get; set; }
|
||||
public Gallery(int gallery_id, string HttpGalleryString){
|
||||
Gallery_id = gallery_id;
|
||||
Tags_Section = Tags(HttpGalleryString);
|
||||
}
|
||||
|
||||
|
||||
public string Tags(string HttpGalleryString){
|
||||
|
||||
int index_of_tags = HttpGalleryString.IndexOf("Tags:");
|
||||
int index_of_artists = HttpGalleryString.IndexOf("Artists:");
|
||||
string tags_section = "";
|
||||
|
||||
for (int i = index_of_tags; i < index_of_artists; i++){
|
||||
tags_section += HttpGalleryString[i];
|
||||
}
|
||||
|
||||
return tags_section;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
53
Program.cs
53
Program.cs
@ -3,46 +3,41 @@ using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.IO;
|
||||
using Gallery;
|
||||
|
||||
namespace rhentai
|
||||
{
|
||||
class Program
|
||||
{
|
||||
namespace rhentai{
|
||||
|
||||
// Program class
|
||||
class Program{
|
||||
|
||||
// Creating a HttpClient
|
||||
private static readonly HttpClient client = new HttpClient();
|
||||
|
||||
|
||||
// Main function
|
||||
static async Task Main(string[] args){
|
||||
await ProcessRepositories();
|
||||
|
||||
// Get Result from HttpGetGallery
|
||||
string HttpGalleryString = await HttpGetGallery();
|
||||
|
||||
string variable = new Gallery.Gallery(1,HttpGalleryString).Tags_Section;
|
||||
|
||||
Console.Write(variable);
|
||||
}
|
||||
|
||||
private static async Task ProcessRepositories(){
|
||||
|
||||
//
|
||||
private static async Task<string> HttpGetGallery(){
|
||||
|
||||
// Create Task
|
||||
client.DefaultRequestHeaders.Accept.Clear();
|
||||
client.DefaultRequestHeaders.Accept.Add(
|
||||
new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"));
|
||||
// client.DefaultRequestHeaders.Add("User-Agent", ".NET Foundation Repository Reporter");
|
||||
|
||||
var stringTask = client.GetStringAsync("https://nhentai.net/random/");
|
||||
|
||||
var msg = await stringTask;
|
||||
|
||||
//Console.Write(msg);
|
||||
|
||||
await File.WriteAllTextAsync("output.txt", msg);
|
||||
|
||||
var fileRead = File.ReadAllTextAsync("output.txt");
|
||||
|
||||
var textread = await fileRead;
|
||||
int index_tags_start = textread.IndexOf("Tags:");
|
||||
int index_tags_end = textread.IndexOf("Artists:");
|
||||
|
||||
string filteredoutput = "";
|
||||
|
||||
for (int i = index_tags_start; i < index_tags_end; i++){
|
||||
filteredoutput += textread[i];
|
||||
}
|
||||
|
||||
Console.Write(filteredoutput);
|
||||
|
||||
// Return Task Result
|
||||
return (await stringTask).ToString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
dbcbf6bb51b27451db101b7859889f98f56ebf31
|
||||
b33c1e170e7280d0cab6abdd3208808f440527cb
|
||||
|
Binary file not shown.
Binary file not shown.
22
output.txt
22
output.txt
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user