This commit is contained in:
Shiba 2022-01-27 11:24:35 +00:00
parent bb0dc3c4f4
commit 3692ccba89
2 changed files with 4 additions and 2 deletions

View file

@ -52,8 +52,9 @@ async function put(url: string | null, id: string): Promise<void> {
return await new Promise((resolve, reject) => {
const store = db?.transaction("store", "readwrite").objectStore("store")
if (!store) return resolve()
const request = store.put({ value: url, expireAt: !url ? new Date(Date.now() + 1 * 60 * 60 * 1000) : new Date(Date.now() + 15 * 24 * 60 * 60 * 1000) }, id)
console.log('caching', id, url)
const expireAt = !url ? new Date(Date.now() + 1 * 60 * 60 * 1000) : new Date(Date.now() + 15 * 24 * 60 * 60 * 1000)
const request = store.put({ value: url, expireAt }, id)
console.log('caching', id, url, 'until:', expireAt)
request.addEventListener('success', () => resolve())
request.addEventListener('error', () => reject(request.error))
})

View file

@ -1,4 +1,5 @@
import { resolveById, YtIdResolverDescriptor } from '../common/yt/urlResolve'
async function resolveYT(descriptor: YtIdResolverDescriptor) {
const lbryProtocolUrl: string | null = (await resolveById([descriptor]).then(a => a[0])) ?? null
if (!lbryProtocolUrl) return null