Spaces:
Build error
Build error
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 }; | |
} | |