fix simple status iterator
This commit is contained in:
parent
d7bc1fd266
commit
0587cff625
@ -18,7 +18,7 @@ export const fetchStatus = (domain, id) => fetch(`https://${domain}/api/v1/statu
|
|||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
|
|
||||||
export async function* statusIterator({ domain, id }) {
|
export async function* statusIterator({ domain, id }) {
|
||||||
const partialTrack = await fetchStatus(domain, id)
|
const partialTrack = processStatus(domain, await fetchStatus(domain, id))
|
||||||
|
|
||||||
if (partialTrack !== null) {
|
if (partialTrack !== null) {
|
||||||
yield partialTrack
|
yield partialTrack
|
||||||
|
@ -50,7 +50,7 @@ export const secondsToElapsedTime = (seconds) => {
|
|||||||
.join(':')
|
.join(':')
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function* tracksIterator(refererGenerator, cache) {
|
export async function* tracksIterator(partialTrackGenerator, cache) {
|
||||||
const notKnow = (values) => {
|
const notKnow = (values) => {
|
||||||
if (cache.has(values)) {
|
if (cache.has(values)) {
|
||||||
console.log(`Drop already processed ${values.join(':')}`)
|
console.log(`Drop already processed ${values.join(':')}`)
|
||||||
@ -63,7 +63,7 @@ export async function* tracksIterator(refererGenerator, cache) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
yield* execPipe(
|
yield* execPipe(
|
||||||
refererGenerator,
|
partialTrackGenerator,
|
||||||
asyncFilter(({ referer: { credentials: { domain, id } } }) => notKnow(['referer', 'mastodon', domain, id])),
|
asyncFilter(({ referer: { credentials: { domain, id } } }) => notKnow(['referer', 'mastodon', domain, id])),
|
||||||
asyncFilter(({ partialMedia: { credentials: { id } } }) => notKnow(['media', 'youtube', id])),
|
asyncFilter(({ partialMedia: { credentials: { id } } }) => notKnow(['media', 'youtube', id])),
|
||||||
asyncMap(async ({ referer, partialMedia }) => {
|
asyncMap(async ({ referer, partialMedia }) => {
|
||||||
@ -82,7 +82,7 @@ export async function* tracksIterator(refererGenerator, cache) {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
} finally {
|
} finally {
|
||||||
refererGenerator.return()
|
partialTrackGenerator.return()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user