MCPcopy Index your code
hub / github.com/MALSync/MALSync / apiCall

Function apiCall

src/pages/Jellyfin/main.ts:321–347  ·  view source on GitHub ↗
(url, needsUser = false, filterByUser = false)

Source from the content-addressed store, hash-verified

319
320// Helper
321async function apiCall(url, needsUser = false, filterByUser = false) {
322 const apiKey = await getApiKey();
323 const base = await getBase();
324 let pre;
325 if (url.indexOf('?') !== -1) {
326 pre = '&';
327 } else {
328 pre = '?';
329 }
330 if (needsUser) {
331 const user = await getUser();
332 url = `/Users/${user}${url}`;
333 }
334 url = `${base + url + pre}api_key=${apiKey}`;
335 if (filterByUser) {
336 const user = await getUser();
337 url = `${url}&ControllableByUserId=${user}`;
338 }
339 con.log('Api Call', url);
340 return api.request.xhr('GET', url).then(res => {
341 if (res.status === 500) {
342 con.error('Something went wrong', url, res);
343 throw 'Something went wrong';
344 }
345 return res;
346 });
347}
348
349export const Jellyfin: pageInterface = {
350 name: 'Jellyfin',

Callers 4

checkItemIdFunction · 0.70
isAnimeFunction · 0.70
getSessionFunction · 0.70
testApiFunction · 0.70

Calls 5

getUserFunction · 0.85
xhrMethod · 0.80
errorMethod · 0.80
getApiKeyFunction · 0.70
getBaseFunction · 0.70

Tested by

no test coverage detected