brunner56's picture
implement app
0bfe2e3
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 };
}