File size: 2,135 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
73
74
75
76
import { PresetMetadata } from '../db';
import { EasynewsPreset } from './easynews';
import { constants, Env } from '../utils';
import { baseOptions } from './preset';

export class EasynewsPlusPreset extends EasynewsPreset {
  static override get METADATA(): PresetMetadata {
    return {
      ...super.METADATA,
      ID: 'easynewsPlus',
      NAME: 'Easynews+',
      DESCRIPTION:
        'Easynews+ provides content from Easynews & includes a search catalog',
      URL: Env.EASYNEWS_PLUS_URL,
      TIMEOUT: Env.DEFAULT_EASYNEWS_PLUS_TIMEOUT || Env.DEFAULT_TIMEOUT,
      USER_AGENT:
        Env.DEFAULT_EASYNEWS_PLUS_USER_AGENT || Env.DEFAULT_USER_AGENT,
      SUPPORTED_RESOURCES: [
        ...super.METADATA.SUPPORTED_RESOURCES,
        constants.CATALOG_RESOURCE,
        constants.META_RESOURCE,
      ],
      OPTIONS: [
        ...baseOptions(
          'Easynews+',
          [
            ...super.METADATA.SUPPORTED_RESOURCES,
            constants.CATALOG_RESOURCE,
            constants.META_RESOURCE,
          ],
          Env.DEFAULT_EASYNEWS_PLUS_TIMEOUT || Env.DEFAULT_TIMEOUT
        ),
        {
          id: 'socials',
          name: '',
          description: '',
          type: 'socials',
          socials: [
            {
              id: 'github',
              url: 'https://github.com/sleeyax/stremio-easynews-addon',
            },
            {
              id: 'patreon',
              url: 'https://patreon.com/sleeyax',
            },
            {
              id: 'buymeacoffee',
              url: 'https://buymeacoffee.com/sleeyax',
            },
          ],
        },
      ],
    };
  }

  protected static override generateConfig(
    easynewsCredentials: {
      username: string;
      password: string;
    },
    options: Record<string, any>
  ): string {
    return this.urlEncodeJSON({
      username: easynewsCredentials.username,
      password: easynewsCredentials.password,
      sort1: 'Size',
      sort1Direction: 'Descending',
      sort2: 'Relevance',
      sort2Direction: 'Descending',
      sort3: 'Date & Time',
      sort3Direction: 'Descending',
    });
  }
}