mirror of
https://github.com/snobu/destreamer.git
synced 2026-02-16 19:49:41 +00:00
Preserve input URL array order
* Implement forEachAsync * Preserve input URL array order Co-authored-by: kylon <kylonux@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Metadata, Session } from './Types';
|
import { Metadata, Session } from './Types';
|
||||||
|
import { forEachAsync } from './Utils';
|
||||||
|
|
||||||
import { parse } from 'iso8601-duration';
|
import { parse } from 'iso8601-duration';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
@@ -29,7 +30,7 @@ export async function getVideoMetadata(videoGuids: string[], session: Session, v
|
|||||||
let playbackUrl: string;
|
let playbackUrl: string;
|
||||||
let posterImage: string;
|
let posterImage: string;
|
||||||
|
|
||||||
await Promise.all(videoGuids.map(async guid => {
|
await forEachAsync(videoGuids, async (guid: string) => {
|
||||||
let apiUrl = `${session.ApiGatewayUri}videos/${guid}?api-version=${session.ApiGatewayVersion}`;
|
let apiUrl = `${session.ApiGatewayUri}videos/${guid}?api-version=${session.ApiGatewayVersion}`;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
@@ -59,7 +60,7 @@ export async function getVideoMetadata(videoGuids: string[], session: Session, v
|
|||||||
playbackUrl: playbackUrl,
|
playbackUrl: playbackUrl,
|
||||||
posterImage: posterImage
|
posterImage: posterImage
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
|
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ function readFileToArray(path: string) {
|
|||||||
return fs.readFileSync(path).toString('utf-8').split(/[\r\n]/);
|
return fs.readFileSync(path).toString('utf-8').split(/[\r\n]/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function forEachAsync(array: any, callback: any) {
|
||||||
|
for (let i=0, l=array.length; i<l; ++i)
|
||||||
|
await callback(array[i], i, array);
|
||||||
|
}
|
||||||
|
|
||||||
export function parseVideoUrls(videoUrls: any) {
|
export function parseVideoUrls(videoUrls: any) {
|
||||||
let t = videoUrls[0] as string;
|
let t = videoUrls[0] as string;
|
||||||
|
|||||||
Reference in New Issue
Block a user