Spaces:
Build error
Build error
File size: 1,938 Bytes
0bfe2e3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
import { ParsedStream } from '@aiostreams/types';
import { formatDuration, formatSize } from './utils';
const imposters = [
'Disney+',
'Netflix',
'HBO',
'Amazon Prime Video',
'Hulu',
'Apple TV+',
'Peacock',
'Paramount+',
];
export function imposterFormat(stream: ParsedStream): {
name: string;
description: string;
} {
let name: string = '';
if (stream.torrent?.infoHash) {
name += `[P2P] `;
}
const chosenImposter =
imposters[Math.floor(Math.random() * imposters.length)];
name += `${chosenImposter} ${stream.personal ? '(Your Media) ' : ''}`;
name += stream.resolution !== 'Unknown' ? stream.resolution + '' : '';
let description: string = `${stream.quality !== 'Unknown' ? 'π₯ ' + stream.quality + ' ' : ''}${stream.encode !== 'Unknown' ? 'ποΈ ' + stream.encode : ''}`;
if (stream.visualTags.length > 0 || stream.audioTags.length > 0) {
description += '\n';
description +=
stream.visualTags.length > 0
? `πΊ ${stream.visualTags.join(' | ')} `
: '';
description +=
stream.audioTags.length > 0 ? `π§ ${stream.audioTags.join(' | ')}` : '';
}
if (
stream.size ||
stream.torrent?.seeders ||
stream.usenet?.age ||
stream.duration
) {
description += '\n';
description += `π¦ ${formatSize(stream.size || 0)} `;
description += stream.duration
? `β±οΈ ${formatDuration(stream.duration)} `
: '';
description += stream.torrent?.seeders
? `π₯ ${stream.torrent.seeders}`
: '';
description += stream.usenet?.age ? `π
${stream.usenet.age}` : '';
}
if (stream.languages.length !== 0) {
let languages = stream.languages;
description += `\nπ ${languages.join(' | ')}`;
}
description += `\nπ ${stream.filename ? stream.filename : 'Unknown'}`;
if (stream.message) {
description += `\nπ’${stream.message}`;
}
return { name, description };
}
|