style: auto-fix linting issues
This commit is contained in:
parent
5c6c342c64
commit
1188a2dcce
6 changed files with 115 additions and 101 deletions
|
|
@ -4,17 +4,17 @@ class ServerAPI {
|
|||
constructor() {
|
||||
this.INSTANCES_URLS = [
|
||||
'https://tidal-uptime.jiffy-puffs-1j.workers.dev/',
|
||||
'https://tidal-uptime.props-76styles.workers.dev/'
|
||||
'https://tidal-uptime.props-76styles.workers.dev/',
|
||||
];
|
||||
this.apiInstances = null;
|
||||
}
|
||||
|
||||
async getInstances() {
|
||||
if (this.apiInstances) return this.apiInstances;
|
||||
|
||||
|
||||
let data = null;
|
||||
const urls = [...this.INSTANCES_URLS].sort(() => Math.random() - 0.5);
|
||||
|
||||
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
|
|
@ -28,25 +28,25 @@ class ServerAPI {
|
|||
|
||||
if (data) {
|
||||
this.apiInstances = (data.api || [])
|
||||
.map(item => item.url || item)
|
||||
.filter(url => !url.includes('spotisaver.net'));
|
||||
.map((item) => item.url || item)
|
||||
.filter((url) => !url.includes('spotisaver.net'));
|
||||
return this.apiInstances;
|
||||
}
|
||||
|
||||
console.error('Failed to load instances from all uptime APIs');
|
||||
return [
|
||||
"https://eu-central.monochrome.tf",
|
||||
"https://us-west.monochrome.tf",
|
||||
"https://arran.monochrome.tf",
|
||||
"https://triton.squid.wtf",
|
||||
"https://api.monochrome.tf",
|
||||
"https://monochrome-api.samidy.com",
|
||||
"https://maus.qqdl.site",
|
||||
"https://vogel.qqdl.site",
|
||||
"https://katze.qqdl.site",
|
||||
"https://hund.qqdl.site",
|
||||
"https://tidal.kinoplus.online",
|
||||
"https://wolf.qqdl.site"
|
||||
'https://eu-central.monochrome.tf',
|
||||
'https://us-west.monochrome.tf',
|
||||
'https://arran.monochrome.tf',
|
||||
'https://triton.squid.wtf',
|
||||
'https://api.monochrome.tf',
|
||||
'https://monochrome-api.samidy.com',
|
||||
'https://maus.qqdl.site',
|
||||
'https://vogel.qqdl.site',
|
||||
'https://katze.qqdl.site',
|
||||
'https://hund.qqdl.site',
|
||||
'https://tidal.kinoplus.online',
|
||||
'https://wolf.qqdl.site',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@ class ServerAPI {
|
|||
constructor() {
|
||||
this.INSTANCES_URLS = [
|
||||
'https://tidal-uptime.jiffy-puffs-1j.workers.dev/',
|
||||
'https://tidal-uptime.props-76styles.workers.dev/'
|
||||
'https://tidal-uptime.props-76styles.workers.dev/',
|
||||
];
|
||||
this.apiInstances = null;
|
||||
}
|
||||
|
||||
async getInstances() {
|
||||
if (this.apiInstances) return this.apiInstances;
|
||||
|
||||
|
||||
let data = null;
|
||||
const urls = [...this.INSTANCES_URLS].sort(() => Math.random() - 0.5);
|
||||
|
||||
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
|
|
@ -28,25 +28,25 @@ class ServerAPI {
|
|||
|
||||
if (data) {
|
||||
this.apiInstances = (data.api || [])
|
||||
.map(item => item.url || item)
|
||||
.filter(url => !url.includes('spotisaver.net'));
|
||||
.map((item) => item.url || item)
|
||||
.filter((url) => !url.includes('spotisaver.net'));
|
||||
return this.apiInstances;
|
||||
}
|
||||
|
||||
console.error('Failed to load instances from all uptime APIs');
|
||||
return [
|
||||
"https://eu-central.monochrome.tf",
|
||||
"https://us-west.monochrome.tf",
|
||||
"https://arran.monochrome.tf",
|
||||
"https://triton.squid.wtf",
|
||||
"https://api.monochrome.tf",
|
||||
"https://monochrome-api.samidy.com",
|
||||
"https://maus.qqdl.site",
|
||||
"https://vogel.qqdl.site",
|
||||
"https://katze.qqdl.site",
|
||||
"https://hund.qqdl.site",
|
||||
"https://tidal.kinoplus.online",
|
||||
"https://wolf.qqdl.site"
|
||||
'https://eu-central.monochrome.tf',
|
||||
'https://us-west.monochrome.tf',
|
||||
'https://arran.monochrome.tf',
|
||||
'https://triton.squid.wtf',
|
||||
'https://api.monochrome.tf',
|
||||
'https://monochrome-api.samidy.com',
|
||||
'https://maus.qqdl.site',
|
||||
'https://vogel.qqdl.site',
|
||||
'https://katze.qqdl.site',
|
||||
'https://hund.qqdl.site',
|
||||
'https://tidal.kinoplus.online',
|
||||
'https://wolf.qqdl.site',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@ class ServerAPI {
|
|||
constructor() {
|
||||
this.INSTANCES_URLS = [
|
||||
'https://tidal-uptime.jiffy-puffs-1j.workers.dev/',
|
||||
'https://tidal-uptime.props-76styles.workers.dev/'
|
||||
'https://tidal-uptime.props-76styles.workers.dev/',
|
||||
];
|
||||
this.apiInstances = null;
|
||||
}
|
||||
|
||||
async getInstances() {
|
||||
if (this.apiInstances) return this.apiInstances;
|
||||
|
||||
|
||||
let data = null;
|
||||
const urls = [...this.INSTANCES_URLS].sort(() => Math.random() - 0.5);
|
||||
|
||||
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
|
|
@ -28,25 +28,25 @@ class ServerAPI {
|
|||
|
||||
if (data) {
|
||||
this.apiInstances = (data.api || [])
|
||||
.map(item => item.url || item)
|
||||
.filter(url => !url.includes('spotisaver.net'));
|
||||
.map((item) => item.url || item)
|
||||
.filter((url) => !url.includes('spotisaver.net'));
|
||||
return this.apiInstances;
|
||||
}
|
||||
|
||||
console.error('Failed to load instances from all uptime APIs');
|
||||
return [
|
||||
"https://eu-central.monochrome.tf",
|
||||
"https://us-west.monochrome.tf",
|
||||
"https://arran.monochrome.tf",
|
||||
"https://triton.squid.wtf",
|
||||
"https://api.monochrome.tf",
|
||||
"https://monochrome-api.samidy.com",
|
||||
"https://maus.qqdl.site",
|
||||
"https://vogel.qqdl.site",
|
||||
"https://katze.qqdl.site",
|
||||
"https://hund.qqdl.site",
|
||||
"https://tidal.kinoplus.online",
|
||||
"https://wolf.qqdl.site"
|
||||
'https://eu-central.monochrome.tf',
|
||||
'https://us-west.monochrome.tf',
|
||||
'https://arran.monochrome.tf',
|
||||
'https://triton.squid.wtf',
|
||||
'https://api.monochrome.tf',
|
||||
'https://monochrome-api.samidy.com',
|
||||
'https://maus.qqdl.site',
|
||||
'https://vogel.qqdl.site',
|
||||
'https://katze.qqdl.site',
|
||||
'https://hund.qqdl.site',
|
||||
'https://tidal.kinoplus.online',
|
||||
'https://wolf.qqdl.site',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@ class ServerAPI {
|
|||
constructor() {
|
||||
this.INSTANCES_URLS = [
|
||||
'https://tidal-uptime.jiffy-puffs-1j.workers.dev/',
|
||||
'https://tidal-uptime.props-76styles.workers.dev/'
|
||||
'https://tidal-uptime.props-76styles.workers.dev/',
|
||||
];
|
||||
this.apiInstances = null;
|
||||
}
|
||||
|
||||
async getInstances() {
|
||||
if (this.apiInstances) return this.apiInstances;
|
||||
|
||||
|
||||
let data = null;
|
||||
const urls = [...this.INSTANCES_URLS].sort(() => Math.random() - 0.5);
|
||||
|
||||
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
|
|
@ -40,25 +40,25 @@ class ServerAPI {
|
|||
|
||||
if (data) {
|
||||
this.apiInstances = (data.api || [])
|
||||
.map(item => item.url || item)
|
||||
.filter(url => !url.includes('spotisaver.net'));
|
||||
.map((item) => item.url || item)
|
||||
.filter((url) => !url.includes('spotisaver.net'));
|
||||
return this.apiInstances;
|
||||
}
|
||||
|
||||
console.error('Failed to load instances from all uptime APIs');
|
||||
return [
|
||||
"https://eu-central.monochrome.tf",
|
||||
"https://us-west.monochrome.tf",
|
||||
"https://arran.monochrome.tf",
|
||||
"https://triton.squid.wtf",
|
||||
"https://api.monochrome.tf",
|
||||
"https://monochrome-api.samidy.com",
|
||||
"https://maus.qqdl.site",
|
||||
"https://vogel.qqdl.site",
|
||||
"https://katze.qqdl.site",
|
||||
"https://hund.qqdl.site",
|
||||
"https://tidal.kinoplus.online",
|
||||
"https://wolf.qqdl.site"
|
||||
'https://eu-central.monochrome.tf',
|
||||
'https://us-west.monochrome.tf',
|
||||
'https://arran.monochrome.tf',
|
||||
'https://triton.squid.wtf',
|
||||
'https://api.monochrome.tf',
|
||||
'https://monochrome-api.samidy.com',
|
||||
'https://maus.qqdl.site',
|
||||
'https://vogel.qqdl.site',
|
||||
'https://katze.qqdl.site',
|
||||
'https://hund.qqdl.site',
|
||||
'https://tidal.kinoplus.online',
|
||||
'https://wolf.qqdl.site',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
17
js/api.js
17
js/api.js
|
|
@ -48,7 +48,7 @@ export class LosslessAPI {
|
|||
}
|
||||
|
||||
if (options.minVersion) {
|
||||
instances = instances.filter(instance => {
|
||||
instances = instances.filter((instance) => {
|
||||
if (!instance.version) return false;
|
||||
return parseFloat(instance.version) >= parseFloat(options.minVersion);
|
||||
});
|
||||
|
|
@ -789,7 +789,10 @@ export class LosslessAPI {
|
|||
if (cached) return cached;
|
||||
|
||||
try {
|
||||
const response = await this.fetchWithRetry(`/artist/similar/?id=${artistId}`, { type: 'api', minVersion: '2.3' });
|
||||
const response = await this.fetchWithRetry(`/artist/similar/?id=${artistId}`, {
|
||||
type: 'api',
|
||||
minVersion: '2.3',
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
// Handle various response structures
|
||||
|
|
@ -840,7 +843,10 @@ export class LosslessAPI {
|
|||
if (cached) return cached;
|
||||
|
||||
try {
|
||||
const response = await this.fetchWithRetry(`/album/similar/?id=${albumId}`, { type: 'api', minVersion: '2.3' });
|
||||
const response = await this.fetchWithRetry(`/album/similar/?id=${albumId}`, {
|
||||
type: 'api',
|
||||
minVersion: '2.3',
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
const items = data.items || data.albums || data.data || (Array.isArray(data) ? data : []);
|
||||
|
|
@ -987,7 +993,10 @@ export class LosslessAPI {
|
|||
if (cached) return cached;
|
||||
|
||||
try {
|
||||
const response = await this.fetchWithRetry(`/recommendations/?id=${id}`, { type: 'api', minVersion: '2.4' });
|
||||
const response = await this.fetchWithRetry(`/recommendations/?id=${id}`, {
|
||||
type: 'api',
|
||||
minVersion: '2.4',
|
||||
});
|
||||
const json = await response.json();
|
||||
const data = json.data || json;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export const apiSettings = {
|
|||
STORAGE_KEY: 'monochrome-api-instances-v9',
|
||||
INSTANCES_URLS: [
|
||||
'https://tidal-uptime.jiffy-puffs-1j.workers.dev/',
|
||||
'https://tidal-uptime.props-76styles.workers.dev/'
|
||||
'https://tidal-uptime.props-76styles.workers.dev/',
|
||||
],
|
||||
defaultInstances: { api: [], streaming: [] },
|
||||
instancesLoaded: false,
|
||||
|
|
@ -58,30 +58,30 @@ export const apiSettings = {
|
|||
console.error('Failed to load instances from all uptime APIs:', fetchError);
|
||||
this.defaultInstances = {
|
||||
api: [
|
||||
{ url: "https://eu-central.monochrome.tf", version: "2.4" },
|
||||
{ url: "https://us-west.monochrome.tf", version: "2.4" },
|
||||
{ url: "https://arran.monochrome.tf", version: "2.4" },
|
||||
{ url: "https://triton.squid.wtf", version: "2.4" },
|
||||
{ url: "https://api.monochrome.tf", version: "2.3" },
|
||||
{ url: "https://monochrome-api.samidy.com", version: "2.3" },
|
||||
{ url: "https://maus.qqdl.site", version: "2.2" },
|
||||
{ url: "https://vogel.qqdl.site", version: "2.2" },
|
||||
{ url: "https://katze.qqdl.site", version: "2.2" },
|
||||
{ url: "https://hund.qqdl.site", version: "2.2" },
|
||||
{ url: "https://tidal.kinoplus.online", version: "2.2" },
|
||||
{ url: "https://wolf.qqdl.site", version: "2.2" }
|
||||
{ url: 'https://eu-central.monochrome.tf', version: '2.4' },
|
||||
{ url: 'https://us-west.monochrome.tf', version: '2.4' },
|
||||
{ url: 'https://arran.monochrome.tf', version: '2.4' },
|
||||
{ url: 'https://triton.squid.wtf', version: '2.4' },
|
||||
{ url: 'https://api.monochrome.tf', version: '2.3' },
|
||||
{ url: 'https://monochrome-api.samidy.com', version: '2.3' },
|
||||
{ url: 'https://maus.qqdl.site', version: '2.2' },
|
||||
{ url: 'https://vogel.qqdl.site', version: '2.2' },
|
||||
{ url: 'https://katze.qqdl.site', version: '2.2' },
|
||||
{ url: 'https://hund.qqdl.site', version: '2.2' },
|
||||
{ url: 'https://tidal.kinoplus.online', version: '2.2' },
|
||||
{ url: 'https://wolf.qqdl.site', version: '2.2' },
|
||||
],
|
||||
streaming: [
|
||||
{ url: "https://arran.monochrome.tf", version: "2.4" },
|
||||
{ url: "https://triton.squid.wtf", version: "2.4" },
|
||||
{ url: "https://api.monochrome.tf", version: "2.3" },
|
||||
{ url: "https://monochrome-api.samidy.com", version: "2.3" },
|
||||
{ url: "https://maus.qqdl.site", version: "2.2" },
|
||||
{ url: "https://vogel.qqdl.site", version: "2.2" },
|
||||
{ url: "https://katze.qqdl.site", version: "2.2" },
|
||||
{ url: "https://hund.qqdl.site", version: "2.2" },
|
||||
{ url: "https://wolf.qqdl.site", version: "2.2" }
|
||||
]
|
||||
{ url: 'https://arran.monochrome.tf', version: '2.4' },
|
||||
{ url: 'https://triton.squid.wtf', version: '2.4' },
|
||||
{ url: 'https://api.monochrome.tf', version: '2.3' },
|
||||
{ url: 'https://monochrome-api.samidy.com', version: '2.3' },
|
||||
{ url: 'https://maus.qqdl.site', version: '2.2' },
|
||||
{ url: 'https://vogel.qqdl.site', version: '2.2' },
|
||||
{ url: 'https://katze.qqdl.site', version: '2.2' },
|
||||
{ url: 'https://hund.qqdl.site', version: '2.2' },
|
||||
{ url: 'https://wolf.qqdl.site', version: '2.2' },
|
||||
],
|
||||
};
|
||||
this.instancesLoaded = true;
|
||||
this._loadPromise = null;
|
||||
|
|
@ -91,11 +91,13 @@ export const apiSettings = {
|
|||
let groupedInstances = { api: [], streaming: [] };
|
||||
|
||||
if (data.api && Array.isArray(data.api)) {
|
||||
groupedInstances.api = data.api.filter(instance => !instance.url.includes('spotisaver.net'));
|
||||
groupedInstances.api = data.api.filter((instance) => !instance.url.includes('spotisaver.net'));
|
||||
}
|
||||
|
||||
if (data.streaming && Array.isArray(data.streaming)) {
|
||||
groupedInstances.streaming = data.streaming.filter(instance => !instance.url.includes('spotisaver.net'));
|
||||
groupedInstances.streaming = data.streaming.filter(
|
||||
(instance) => !instance.url.includes('spotisaver.net')
|
||||
);
|
||||
} else if (groupedInstances.api.length > 0) {
|
||||
groupedInstances.streaming = [...groupedInstances.api];
|
||||
}
|
||||
|
|
@ -104,10 +106,13 @@ export const apiSettings = {
|
|||
this.instancesLoaded = true;
|
||||
|
||||
try {
|
||||
localStorage.setItem(this.STORAGE_KEY, JSON.stringify({
|
||||
timestamp: Date.now(),
|
||||
data: groupedInstances
|
||||
}));
|
||||
localStorage.setItem(
|
||||
this.STORAGE_KEY,
|
||||
JSON.stringify({
|
||||
timestamp: Date.now(),
|
||||
data: groupedInstances,
|
||||
})
|
||||
);
|
||||
} catch (e) {
|
||||
console.warn('Failed to cache instances:', e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue