Refactor
This commit is contained in:
parent
195484b42e
commit
eb99cbe544
29
be/src/fetchItemsFromJellyfin.ts
Normal file
29
be/src/fetchItemsFromJellyfin.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import fetch from "node-fetch";
|
||||
|
||||
import { API_BASE, API_TOKEN } from "../config.ts";
|
||||
|
||||
const API_ENDPOINT_WITH_PARAMS = "/Items?isMovie=true&isSeries=true&recursive=true&fields=ProviderIds&filters=&mediaTypes=Video&enableTotalRecordCount=true&enableImages=false";
|
||||
const API_URL = API_BASE + API_ENDPOINT_WITH_PARAMS;
|
||||
|
||||
export const fetchFromApi = async () => {
|
||||
const init = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `MediaBrowser Token=${API_TOKEN}`,
|
||||
},
|
||||
};
|
||||
|
||||
const response = await fetch(API_URL, init)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => console.log(data))
|
||||
.catch(error => console.error('Error:', error));
|
||||
console.log("response:", response);
|
||||
}
|
||||
|
|
@ -1,33 +1,3 @@
|
|||
import fetch from "node-fetch";
|
||||
|
||||
import { API_BASE, API_TOKEN } from "../config.ts";
|
||||
|
||||
const API_ENDPOINT_WITH_PARAMS = "/Items?isMovie=true&isSeries=true&recursive=true&fields=ProviderIds&filters=&mediaTypes=Video&enableTotalRecordCount=true&enableImages=false";
|
||||
const API_URL = API_BASE + API_ENDPOINT_WITH_PARAMS;
|
||||
|
||||
const fetchFromApi = async () => {
|
||||
const init = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `MediaBrowser Token=${API_TOKEN}`,
|
||||
},
|
||||
};
|
||||
|
||||
const response = await fetch(API_URL, init)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
console.log("response:", response);
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => console.log(data))
|
||||
.catch(error => console.error('Error:', error));
|
||||
console.log("response:", response);
|
||||
console.log("API_URL:", API_URL);
|
||||
console.log("init:", init);
|
||||
}
|
||||
import { fetchFromApi } from "./fetchItemsFromJellyfin.ts";
|
||||
|
||||
fetchFromApi();
|
||||
|
|
Loading…
Reference in a new issue