~ d e s i g n ~

This commit is contained in:
wryk
2020-01-07 19:23:49 +01:00
commit 8633b8534b
8 changed files with 7575 additions and 0 deletions

25
src/util.js Normal file
View File

@ -0,0 +1,25 @@
import getUrls from 'get-urls'
export async function fetchEntries(domain, hashtags) {
const response = await fetch(`https://${domain}/api/v1/timelines/tag/${hashtags[0]}`)
const statuses = await response.json()
const entries = statuses
.map(status => {
const [url] = Array.from(getUrls(status.content)).filter(isSupportedUrl)
const tags = intersection(status.tags.map(tag => tag.name), hashtags)
return { status, url, tags }
})
.filter(entry => entry.url != null)
return entries
}
function isSupportedUrl(url) {
return (new URL(url)).hostname === 'youtube.com'
}
function intersection(xs, ys) {
return xs.filter(x => ys.includes(x));
}