MCPcopy Create free account
hub / github.com/MALSync/MALSync / malSync

Method malSync

src/_provider/Search/searchClass.ts:330–369  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

328 }
329
330 public async malSync(): Promise<SearchResult | false> {
331 const logger = this.logger.m('API');
332
333 if (!this.page) return false;
334 const dbPl = this.page.database;
335 if (!dbPl) return false;
336 const url = `https://api.malsync.moe/page/${dbPl}/${encodeURIComponent(
337 this.identifierToDbKey(this.identifier),
338 ).toLowerCase()}`;
339 logger.log(url);
340
341 const response = await api.request.xhr('GET', url);
342 logger.log('Response', response);
343
344 if (response.status !== 400 && response.status !== 200) throw new Error('malsync offline');
345
346 if (response.status === 400 && response.responseText?.includes('error')) return false;
347
348 const res = JSON.parse(response.responseText);
349
350 let pageUrl = res.malUrl;
351
352 if (
353 !pageUrl &&
354 res.aniUrl &&
355 ['ANILIST', 'MANGABAKA'].includes(getSyncMode(this.getNormalizedType()))
356 ) {
357 pageUrl = res.aniUrl;
358 }
359
360 return {
361 url: pageUrl,
362 offset: 0,
363 provider: 'firebase',
364 similarity: {
365 same: true,
366 value: 1,
367 },
368 };
369 }
370
371 public async malSearch(): Promise<SearchResult | false> {
372 const logger = this.logger.m('MAL');

Callers 1

searchForItMethod · 0.95

Calls 4

identifierToDbKeyMethod · 0.95
getNormalizedTypeMethod · 0.95
getSyncModeFunction · 0.90
xhrMethod · 0.80

Tested by

no test coverage detected