mirror of
https://github.com/snobu/destreamer.git
synced 2026-02-24 07:18:24 +00:00
Moved things around
This commit is contained in:
29
Metadata.ts
29
Metadata.ts
@@ -2,12 +2,14 @@ import axios from 'axios';
|
|||||||
import { terminal as term } from 'terminal-kit';
|
import { terminal as term } from 'terminal-kit';
|
||||||
import { Metadata, Session } from './Types';
|
import { Metadata, Session } from './Types';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
|
|
||||||
export async function getVideoMetadata(videoGuids: string[], session: Session): Promise<Metadata[]> {
|
export async function getVideoMetadata(videoGuids: string[], session: Session): Promise<Metadata[]> {
|
||||||
let metadata: Metadata[] = [];
|
let metadata: Metadata[] = [];
|
||||||
let title: string;
|
let title: string;
|
||||||
let playbackUrl: string;
|
let playbackUrl: string;
|
||||||
|
let posterImage: string;
|
||||||
|
|
||||||
await Promise.all(videoGuids.map(async guid => {
|
await Promise.all(videoGuids.map(async guid => {
|
||||||
let apiUrl = `${session.ApiGatewayUri}videos/${guid}?api-version=${session.ApiGatewayVersion}`;
|
let apiUrl = `${session.ApiGatewayUri}videos/${guid}?api-version=${session.ApiGatewayVersion}`;
|
||||||
@@ -25,35 +27,14 @@ export async function getVideoMetadata(videoGuids: string[], session: Session):
|
|||||||
item["mimeType"] == "application/vnd.apple.mpegurl")
|
item["mimeType"] == "application/vnd.apple.mpegurl")
|
||||||
.map((item: { [x: string]: string }) => { return item["playbackUrl"]; })[0];
|
.map((item: { [x: string]: string }) => { return item["playbackUrl"]; })[0];
|
||||||
|
|
||||||
let posterImageUrl = response.data["posterImage"]["medium"]["url"];
|
posterImage = response.data["posterImage"]["medium"]["url"];
|
||||||
|
|
||||||
let a = async () => {
|
|
||||||
response = await axios.get(posterImageUrl, {
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${session.AccessToken}`
|
|
||||||
},
|
|
||||||
responseType: 'stream'
|
|
||||||
});
|
|
||||||
|
|
||||||
const writer = fs.createWriteStream('.thumbnail.png');
|
|
||||||
response.data.pipe(writer);
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
writer.on('finish', resolve);
|
|
||||||
writer.on('error', reject);
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
await a();
|
|
||||||
|
|
||||||
term.drawImage('.thumbnail.png', { shrink: { width: 50, height: 50 } });
|
|
||||||
|
|
||||||
term.brightMagenta(`\n title = ${title}\n playbackUrl = ${playbackUrl}\n`);
|
term.brightMagenta(`\n title = ${title}\n playbackUrl = ${playbackUrl}\n`);
|
||||||
|
|
||||||
metadata.push({
|
metadata.push({
|
||||||
title: title,
|
title: title,
|
||||||
playbackUrl: playbackUrl
|
playbackUrl: playbackUrl,
|
||||||
|
posterImage: posterImage
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
27
Thumbnail.ts
Normal file
27
Thumbnail.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import os from 'os';
|
||||||
|
import { terminal as term } from 'terminal-kit';
|
||||||
|
|
||||||
|
|
||||||
|
if (os.platform() !== "win32") {
|
||||||
|
term.brightWhite("Platform is not Windows, let's draw some thumbnails!\n");
|
||||||
|
let a = async () => {
|
||||||
|
response = await axios.get(posterImageUrl, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${session.AccessToken}`
|
||||||
|
},
|
||||||
|
responseType: 'stream'
|
||||||
|
});
|
||||||
|
|
||||||
|
const writer = fs.createWriteStream('.thumbnail.png');
|
||||||
|
response.data.pipe(writer);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
writer.on('finish', resolve);
|
||||||
|
writer.on('error', reject);
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
await a();
|
||||||
|
}
|
||||||
|
|
||||||
|
term.drawImage('.thumbnail.png', { shrink: { width: 50, height: 50 } });
|
||||||
Reference in New Issue
Block a user