mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Remove obscure embed attribute and remove cache
The cache is a possible memory leak: It grows over time and never gets cleaned.
This commit is contained in:
parent
7a9d9339f8
commit
d81c38c4e3
@ -31,9 +31,6 @@ const metascraper = Metascraper([
|
|||||||
// require('./rules/metascraper-embed')()
|
// require('./rules/metascraper-embed')()
|
||||||
])
|
])
|
||||||
|
|
||||||
// quick in memory cache
|
|
||||||
let cache = {}
|
|
||||||
|
|
||||||
let oEmbedProviders = []
|
let oEmbedProviders = []
|
||||||
const getEmbedProviders = async () => {
|
const getEmbedProviders = async () => {
|
||||||
let providers = await request('https://oembed.com/providers.json')
|
let providers = await request('https://oembed.com/providers.json')
|
||||||
@ -92,12 +89,6 @@ export default async function scrape(targetUrl) {
|
|||||||
targetUrl.hostname = 'youtube.com'
|
targetUrl.hostname = 'youtube.com'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cache[targetUrl]) {
|
|
||||||
return cache[targetUrl]
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = new URL(targetUrl)
|
|
||||||
|
|
||||||
let meta = {}
|
let meta = {}
|
||||||
let embed = {}
|
let embed = {}
|
||||||
|
|
||||||
@ -137,18 +128,5 @@ export default async function scrape(targetUrl) {
|
|||||||
throw new ApolloError('Not found', 'NOT_FOUND')
|
throw new ApolloError('Not found', 'NOT_FOUND')
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix youtube start parameter
|
|
||||||
const YouTubeStartParam = url.searchParams.t || url.searchParams.start
|
|
||||||
if (output.publisher === 'YouTube' && YouTubeStartParam) {
|
|
||||||
output.embed = output.embed.replace(
|
|
||||||
'?feature=oembed',
|
|
||||||
`?feature=oembed&start=${YouTubeStartParam}`,
|
|
||||||
)
|
|
||||||
output.url += `&start=${YouTubeStartParam}`
|
|
||||||
}
|
|
||||||
|
|
||||||
// write to cache
|
|
||||||
cache[targetUrl] = output
|
|
||||||
|
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,6 @@ type Embed {
|
|||||||
video: String
|
video: String
|
||||||
lang: String
|
lang: String
|
||||||
logo: String
|
logo: String
|
||||||
embed: String
|
|
||||||
sources: [String]
|
sources: [String]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user