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 };
}