B: switched to using config service in tmdb service
This commit is contained in:
1 parent
2d7bf91543
commit
cc1d1cdadf
2 files changed
+18
-5
No files matched your search
@@ -20,6 +20,7 @@ class ConfigService {
|
|||||||
constructor() {
|
constructor() {
|
||||||
if (!ConfigService.instance) {
|
if (!ConfigService.instance) {
|
||||||
ConfigService.instance = this;
|
ConfigService.instance = this;
|
||||||
|
this.settings = this.getSettings();
|
||||||
}
|
}
|
||||||
return ConfigService.instance;
|
return ConfigService.instance;
|
||||||
}
|
}
|
||||||
@@ -87,6 +88,15 @@ class ConfigService {
|
|||||||
fs.mkdirSync(collectionsPostersDir, { recursive: true });
|
fs.mkdirSync(collectionsPostersDir, { recursive: true });
|
||||||
fs.mkdirSync(collectionsBackdropsDir, { recursive: true });
|
fs.mkdirSync(collectionsBackdropsDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTmdbApiUrl() {
|
||||||
|
return this.settings.tmdbApiUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTmdbApiKey() {
|
||||||
|
return this.settings.tmdbApiKey;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// const instance = new ConfigService();
|
// const instance = new ConfigService();
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const { logToFile } = require('./logService');
|
const { logToFile } = require('./logService');
|
||||||
const tmdb_apiKey = "5323ef3dc430df54dcb9e58c37fd22bb";
|
const configService = require('./configService');
|
||||||
|
|
||||||
|
const TMDB_APIURL = configService.getTmdbApiUrl();
|
||||||
|
const TMDB_APIKEY = configService.getTmdbApiKey();
|
||||||
|
|
||||||
async function fetchEntryData(tmdb_id, is_tvserie) {
|
async function fetchEntryData(tmdb_id, is_tvserie) {
|
||||||
try {
|
try {
|
||||||
let type = is_tvserie ? "tv" : "movie";
|
let type = is_tvserie ? "tv" : "movie";
|
||||||
let url = `http://api.themoviedb.org/3/${type}/${tmdb_id}?api_key=${tmdb_apiKey}&language=en-US`
|
let url = `${TMDB_APIURL}${type}/${tmdb_id}?api_key=${TMDB_APIKEY}&language=en-US`
|
||||||
logToFile(`Fetching Entry Data From: ${url}`)
|
logToFile(`Fetching Entry Data From: ${url}`)
|
||||||
let data;
|
let data;
|
||||||
await axios.get(url)
|
await axios.get(url)
|
||||||
@@ -28,7 +31,7 @@ async function fetchEntryData(tmdb_id, is_tvserie) {
|
|||||||
async function fetchSeasonData(tmdbTvId, seasonNumber) {
|
async function fetchSeasonData(tmdbTvId, seasonNumber) {
|
||||||
// fetching the informations
|
// fetching the informations
|
||||||
try {
|
try {
|
||||||
let url = `http://api.themoviedb.org/3/tv/${tmdbTvId}/season/${seasonNumber}?api_key=${tmdb_apiKey}&language=en-US`
|
let url = `${TMDB_APIURL}tv/${tmdbTvId}/season/${seasonNumber}?api_key=${TMDB_APIKEY}&language=en-US`
|
||||||
logToFile(`Fetching Season Data From: ${url}`)
|
logToFile(`Fetching Season Data From: ${url}`)
|
||||||
let data;
|
let data;
|
||||||
await axios.get(url)
|
await axios.get(url)
|
||||||
@@ -50,7 +53,7 @@ async function fetchSeasonData(tmdbTvId, seasonNumber) {
|
|||||||
async function fetchEntryMedia(tmdb_id, is_tvserie) {
|
async function fetchEntryMedia(tmdb_id, is_tvserie) {
|
||||||
try {
|
try {
|
||||||
let type = is_tvserie ? "tv" : "movie";
|
let type = is_tvserie ? "tv" : "movie";
|
||||||
let url = `http://api.themoviedb.org/3/${type}/${tmdb_id}/images?api_key=${tmdb_apiKey}`
|
let url = `${TMDB_APIURL}${type}/${tmdb_id}/images?api_key=${TMDB_APIKEY}`
|
||||||
logToFile(`Fetching Entry Media Data From: ${url}`)
|
logToFile(`Fetching Entry Media Data From: ${url}`)
|
||||||
let data;
|
let data;
|
||||||
await axios.get(url)
|
await axios.get(url)
|
||||||
@@ -71,7 +74,7 @@ async function fetchEntryMedia(tmdb_id, is_tvserie) {
|
|||||||
|
|
||||||
async function fetchCollectionData(collectionId) {
|
async function fetchCollectionData(collectionId) {
|
||||||
try {
|
try {
|
||||||
let url = `http://api.themoviedb.org/3/collection/${collectionId}?api_key=${tmdb_apiKey}&language=en-US`
|
let url = `${TMDB_APIURL}collection/${collectionId}?api_key=${TMDB_APIKEY}&language=en-US`
|
||||||
logToFile(`Fetching Collection Data From: ${url}`)
|
logToFile(`Fetching Collection Data From: ${url}`)
|
||||||
let data;
|
let data;
|
||||||
await axios.get(url)
|
await axios.get(url)
|
||||||
|
|||||||
Reference in new issue
Block a user