forked from Mastodon/mastoradio-la-radio-di-mastodon
proto youtube video viewer
This commit is contained in:
10
src/util.js
10
src/util.js
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user