mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 14:56:06 +02:00
Remove userdialog playtime & fix screenshot search worldName
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Drawing.Processing;
|
using SixLabors.ImageSharp.Drawing.Processing;
|
||||||
@@ -16,6 +18,12 @@ namespace VRCX
|
|||||||
{
|
{
|
||||||
public partial class AppApi
|
public partial class AppApi
|
||||||
{
|
{
|
||||||
|
public void PopulateImageHosts(string json)
|
||||||
|
{
|
||||||
|
var hosts = JsonSerializer.Deserialize<List<string>>(json);
|
||||||
|
ImageCache.PopulateImageHosts(hosts);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<string> GetImage(string url, string fileId, string version)
|
public async Task<string> GetImage(string url, string fileId, string version)
|
||||||
{
|
{
|
||||||
return await ImageCache.GetImage(url, fileId, version);
|
return await ImageCache.GetImage(url, fileId, version);
|
||||||
|
|||||||
+19
-3
@@ -12,7 +12,7 @@ internal static class ImageCache
|
|||||||
{
|
{
|
||||||
private static readonly string cacheLocation;
|
private static readonly string cacheLocation;
|
||||||
private static readonly HttpClient httpClient;
|
private static readonly HttpClient httpClient;
|
||||||
private static readonly List<string> _imageHosts =
|
private static readonly List<string> ImageHosts =
|
||||||
[
|
[
|
||||||
"api.vrchat.cloud",
|
"api.vrchat.cloud",
|
||||||
"files.vrchat.cloud",
|
"files.vrchat.cloud",
|
||||||
@@ -31,6 +31,22 @@ internal static class ImageCache
|
|||||||
httpClient.DefaultRequestHeaders.Add("User-Agent", Program.Version);
|
httpClient.DefaultRequestHeaders.Add("User-Agent", Program.Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void PopulateImageHosts(List<string> hosts)
|
||||||
|
{
|
||||||
|
foreach (var host in hosts)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(host))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var uri = new Uri(host);
|
||||||
|
if (string.IsNullOrEmpty(uri.Host))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!ImageHosts.Contains(uri.Host))
|
||||||
|
ImageHosts.Add(uri.Host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<string> GetImage(string url, string fileId, string version)
|
public static async Task<string> GetImage(string url, string fileId, string version)
|
||||||
{
|
{
|
||||||
var directoryLocation = Path.Join(cacheLocation, fileId);
|
var directoryLocation = Path.Join(cacheLocation, fileId);
|
||||||
@@ -47,7 +63,7 @@ internal static class ImageCache
|
|||||||
Directory.CreateDirectory(directoryLocation);
|
Directory.CreateDirectory(directoryLocation);
|
||||||
|
|
||||||
var uri = new Uri(url);
|
var uri = new Uri(url);
|
||||||
if (!_imageHosts.Contains(uri.Host))
|
if (!ImageHosts.Contains(uri.Host))
|
||||||
throw new ArgumentException("Invalid image host", url);
|
throw new ArgumentException("Invalid image host", url);
|
||||||
|
|
||||||
var cookieString = string.Empty;
|
var cookieString = string.Empty;
|
||||||
@@ -91,7 +107,7 @@ internal static class ImageCache
|
|||||||
public static async Task<bool> SaveImageToFile(string url, string path)
|
public static async Task<bool> SaveImageToFile(string url, string path)
|
||||||
{
|
{
|
||||||
var uri = new Uri(url);
|
var uri = new Uri(url);
|
||||||
if (!_imageHosts.Contains(uri.Host))
|
if (!ImageHosts.Contains(uri.Host))
|
||||||
throw new ArgumentException("Invalid image host", url);
|
throw new ArgumentException("Invalid image host", url);
|
||||||
|
|
||||||
var cookieString = string.Empty;
|
var cookieString = string.Empty;
|
||||||
|
|||||||
@@ -101,7 +101,10 @@ namespace VRCX
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case ScreenshotSearchType.WorldName:
|
case ScreenshotSearchType.WorldName:
|
||||||
if (metadata.World.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) != -1)
|
if (metadata.World.Name == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (metadata.World.Name.Contains(query, StringComparison.OrdinalIgnoreCase))
|
||||||
result.Add(metadata);
|
result.Add(metadata);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ namespace VRCX
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The display name of the user.
|
/// The display name of the user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string DisplayName { get; set; }
|
public string? DisplayName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WorldDetail
|
public class WorldDetail
|
||||||
@@ -120,7 +120,7 @@ namespace VRCX
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the world.
|
/// The name of the world.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The full ID of the game instance.
|
/// The full ID of the game instance.
|
||||||
|
|||||||
@@ -22,6 +22,15 @@ export default class extends baseClass {
|
|||||||
args.ref = this.applyConfig(args.json);
|
args.ref = this.applyConfig(args.json);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
API.$on('CONFIG', function (args) {
|
||||||
|
if (typeof args.ref?.whiteListedAssetUrls !== 'object') {
|
||||||
|
console.error('Invalid config whiteListedAssetUrls');
|
||||||
|
}
|
||||||
|
AppApi.PopulateImageHosts(
|
||||||
|
JSON.stringify(args.ref.whiteListedAssetUrls)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
API.applyConfig = function (json) {
|
API.applyConfig = function (json) {
|
||||||
var ref = {
|
var ref = {
|
||||||
...json
|
...json
|
||||||
|
|||||||
Reference in New Issue
Block a user