proto youtube video viewer

This commit is contained in:
wryk
2020-01-08 20:37:46 +01:00
parent 8633b8534b
commit 3e9ac5f2e8
5 changed files with 84 additions and 7 deletions

View File

@ -1,4 +1,5 @@
import getUrls from 'get-urls'
import getYoutubeId from 'get-youtube-id'
export async function fetchEntries(domain, hashtags) {
const response = await fetch(`https://${domain}/api/v1/timelines/tag/${hashtags[0]}`)
@ -7,11 +8,16 @@ export async function fetchEntries(domain, hashtags) {
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 }
return { status, url }
})
.filter(entry => entry.url != null)
.map(({ status, url }) => {
const id = getYoutubeId(url)
const tags = intersection(status.tags.map(tag => tag.name), hashtags)
return { status, url, id, tags }
})
return entries
}