mirror of
https://github.com/snobu/destreamer.git
synced 2026-01-16 21:12:13 +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 { forEachAsync } from './Utils';
|
||||
|
||||
import { parse } from 'iso8601-duration';
|
||||
import axios from 'axios';
|
||||
@@ -29,7 +30,7 @@ export async function getVideoMetadata(videoGuids: string[], session: Session, v
|
||||
let playbackUrl: 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}`;
|
||||
|
||||
if (verbose)
|
||||
@@ -59,7 +60,7 @@ export async function getVideoMetadata(videoGuids: string[], session: Session, v
|
||||
playbackUrl: playbackUrl,
|
||||
posterImage: posterImage
|
||||
});
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,10 @@ function readFileToArray(path: string) {
|
||||
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) {
|
||||
let t = videoUrls[0] as string;
|
||||
|
||||
Reference in New Issue
Block a user