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

Method firebase

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

Source from the content-addressed store, hash-verified

283 }
284
285 public async firebase(): Promise<SearchResult | false> {
286 if (!this.page || !this.page.database) return false;
287
288 const logger = this.logger.m('Firebase');
289
290 const url = `https://kissanimelist.firebaseio.com/Data2/${
291 this.page.database
292 }/${encodeURIComponent(this.identifierToDbKey(this.identifier)).toLowerCase()}/Mal.json`;
293 logger.log(url);
294 const response = await api.request.xhr('GET', url);
295
296 logger.log('response', response.responseText);
297 if (
298 !response.responseText ||
299 response.responseText === 'null' ||
300 response.responseText.includes('error')
301 )
302 return false;
303 let matches;
304 try {
305 matches = JSON.parse(response.responseText);
306 } catch (e) {
307 logger.info('Parse failed');
308 return false;
309 }
310
311 if (!matches || Object.keys(matches).length === 0) return false;
312
313 const id = Object.keys(matches)[0];
314
315 let returnUrl = '';
316
317 if (id !== 'Not-Found') returnUrl = `https://myanimelist.net/${this.page.type}/${id}`;
318
319 return {
320 url: returnUrl,
321 offset: 0,
322 provider: 'firebase',
323 similarity: {
324 same: true,
325 value: 1,
326 },
327 };
328 }
329
330 public async malSync(): Promise<SearchResult | false> {
331 const logger = this.logger.m('API');

Callers

nothing calls this directly

Calls 4

identifierToDbKeyMethod · 0.95
xhrMethod · 0.80
keysMethod · 0.80
infoMethod · 0.45

Tested by

no test coverage detected