| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using System.Net;
- using System.Text.Json;
- using System.Text.Json.Serialization;
- namespace NexusMods.Responses {
- /*
- {
- "category_id": 7,
- "category_name": "ARCHIVED",
- "changelog_html": "Added: Infinite Logs toggle",
- "content_preview_link": "https://file-metadata.nexusmods.com/file/nexus-files-s3-meta/5165/46/SOTFModMenu-v2.0.0-46-2-0-0-1679156402.rar.json",
- "description": "",
- "external_virus_scan_url": "https://www.virustotal.com/gui/file/982036f24b1d3eaf05bf59607a779378fdd1677d0b69029d0f5f50602bee2518/detection/f-982036f24b1d3eaf05bf59607a779378fdd1677d0b69029d0f5f50602bee2518-1679156408",
- "file_id": 117,
- "file_name": "SOTFModMenu-v2.0.0-46-2-0-0-1679156402.rar",
- "id": [
- 117,
- 5165
- ],
- "is_primary": false,
- "mod_version": "2.0.0",
- "name": "SOTFModMenu-v2.0.0",
- "size": 246,
- "size_in_bytes": 252382,
- "size_kb": 246,
- "uid": 22183506083957,
- "uploaded_time": "2023-03-18T16:20:02.000+00:00",
- "uploaded_timestamp": 1679156402,
- "version": "2.0.0"
- }
- */
- public class FileResponse {
- public int category_id { get; set; }
- public string category_name { get; set; }
- public string changelog_html { get; set; }
- public Uri? content_preview_link { get; set; }
- private Preview _prev;
- public Preview content_preview {
- get {
- if (this.content_preview == null && this.content_preview_link != null) {
- WebRequest? webRequest = null;
- WebResponse? response = null;
- try {
- webRequest = WebRequest.Create(this.content_preview_link);
- webRequest.Method = "GET";
- using (response = webRequest.GetResponse()) {
- response.Close();
- }
- } finally {
- response?.Dispose();
- }
- webRequest = null;
- response = null;
- StreamReader? streamReader = null;
- string? responseData;
- try {
- using (streamReader = new StreamReader(response.GetResponseStream())) {
- responseData = streamReader.ReadToEnd();
- streamReader.Close();
- }
- } finally {
- streamReader?.Dispose();
- }
- streamReader = null;
- this._prev = JsonSerializer.Deserialize<Preview>(responseData);
- }
- return this._prev;
- }
- }
- public string description { get; set; }
- public Uri external_virus_scan_url { get; set; }
- public int file_id { get; set; }
- public string file_name { get; set; }
- public int[] id { get; set; }
- public bool is_primary { get; set; }
- public Version mod_version { get; set; }
- public string name { get; set; }
- public long size { get; set; }
- public long size_in_bytes { get; set; }
- public long size_kb { get; set; }
- public long uid { get; set; }
- public DateTime uploaded_time { get; set; }
- public int uploaded_timestamp { get; set; }
- public Version version { get; set; }
- }
- }
|