Skip to content

Commit

Permalink
quotes feature now pulls in year, source.
Browse files Browse the repository at this point in the history
  • Loading branch information
lavedon committed Apr 19, 2021
1 parent ff4e0be commit 85eac0b
Show file tree
Hide file tree
Showing 19 changed files with 736 additions and 6 deletions.
42 changes: 36 additions & 6 deletions API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,41 @@ public static void APICalls(CurrentQuery query)
getQuotes.RunSynchronously();
Trace.WriteLine("Ran quotations synchronously.");
Trace.WriteLine("Parsing quotations JSON.");


JsonElement root = JSONResponse.RootElement;
JsonElement quoteData = root.GetProperty("data");
foreach (JsonElement item in quoteData.EnumerateArray())
{
try {
// Print the quote
JsonElement quoteInfoBlock = item.GetProperty("text");
JsonElement actualQuote = quoteInfoBlock.GetProperty("full_text");

// Get the source of the quote
JsonElement quoteSourceBlock = item.GetProperty("source");
JsonElement quoteTitle = quoteSourceBlock.GetProperty("title");
JsonElement quoteAuthor = quoteSourceBlock.GetProperty("author");


// quoteSourceBlock.TryGetProperty("author", out JsonElement quoteAuthor);


// Get what year the quote is from
JsonElement quoteYear = item.GetProperty("year");
Console.WriteLine("\"{0}\", Year: {1}, Source: {2} {3}",
actualQuote.ToString(), quoteYear.ToString(), quoteAuthor.ToString(), quoteTitle.ToString());
Console.WriteLine();
Console.WriteLine("----Enter for more - X to exit----");
string input = Console.ReadLine().Trim().ToLower();
if (input == "x")
break;
}
catch (Exception ex) {
Console.WriteLine(ex);
}

}
/*
string quotesDataString = JSONResponse.RootElement.GetProperty("data").ToString();
// (?<="full_text":\s")(.*?)(?=",)
var quotesRegex = new Regex("(?<=\"full_text\":\\s\")(.*?)(?=\",)");
Expand All @@ -284,12 +318,8 @@ public static void APICalls(CurrentQuery query)
{
string input = "";
Console.WriteLine("\"{0}\"", match.Value);
Console.WriteLine();
Console.WriteLine("----Enter for more - X to exit----");
input = Console.ReadLine().Trim().ToLower();
if (input == "x")
break;
}
*/

Trace.WriteLine("First quote grabbed as:");
Trace.WriteLine(query.Quote);
Expand Down
Binary file modified bin/Debug/net5.0/OxfordV2.dll
Binary file not shown.
Binary file modified bin/Debug/net5.0/OxfordV2.pdb
Binary file not shown.
53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1056.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1110.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1112.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1124.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1125.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1134.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1135.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1141.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1145.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1147.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1148.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions logs/Log_OxfordApplication_20210419-1149.txt

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions logs/Log_OxfordApplication_20210419-1151.txt

Large diffs are not rendered by default.

Binary file modified obj/Debug/net5.0/OxfordV2.assets.cache
Binary file not shown.
Binary file modified obj/Debug/net5.0/OxfordV2.dll
Binary file not shown.
Binary file modified obj/Debug/net5.0/OxfordV2.pdb
Binary file not shown.

0 comments on commit 85eac0b

Please sign in to comment.