mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
refactor: update text track types and clean up imports across multiple stream providers
This commit is contained in:
@@ -1,35 +1,29 @@
|
||||
import { cacheStorageService } from '../storage';
|
||||
|
||||
// 1 hour
|
||||
const expireTime = 60 * 60 * 1000;
|
||||
|
||||
export const getBaseUrl = async (providerValue: string) => {
|
||||
try {
|
||||
let baseUrl = '';
|
||||
const cacheKey = 'CacheBaseUrl' + providerValue;
|
||||
const timeKey = 'baseUrlTime' + providerValue;
|
||||
|
||||
const cachedUrl = cacheStorageService.getString(cacheKey);
|
||||
const cachedTime = cacheStorageService.getObject<number>(timeKey);
|
||||
|
||||
if (
|
||||
cachedUrl &&
|
||||
cachedTime &&
|
||||
Date.now() - cachedTime < expireTime
|
||||
) {
|
||||
baseUrl = cachedUrl;
|
||||
} else {
|
||||
const baseUrlRes = await fetch(
|
||||
'https://himanshu8443.github.io/providers/modflix.json',
|
||||
);
|
||||
const baseUrlData = await baseUrlRes.json();
|
||||
baseUrl = baseUrlData[providerValue].url;
|
||||
cacheStorageService.setString(cacheKey, baseUrl);
|
||||
cacheStorageService.setObject(timeKey, Date.now());
|
||||
}
|
||||
let baseUrl = "";
|
||||
const cacheKey = "CacheBaseUrl" + providerValue;
|
||||
const timeKey = "baseUrlTime" + providerValue;
|
||||
|
||||
// const cachedUrl = cacheStorageService.getString(cacheKey);
|
||||
// const cachedTime = cacheStorageService.getObject<number>(timeKey);
|
||||
|
||||
// if (cachedUrl && cachedTime && Date.now() - cachedTime < expireTime) {
|
||||
// baseUrl = cachedUrl;
|
||||
// } else {
|
||||
const baseUrlRes = await fetch(
|
||||
"https://himanshu8443.github.io/providers/modflix.json"
|
||||
);
|
||||
const baseUrlData = await baseUrlRes.json();
|
||||
baseUrl = baseUrlData[providerValue].url;
|
||||
// cacheStorageService.setString(cacheKey, baseUrl);
|
||||
// cacheStorageService.setObject(timeKey, Date.now());
|
||||
// }
|
||||
return baseUrl;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching baseUrl: ${providerValue}`, error);
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user