• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Nikorag / iplayarr / 14726106855

29 Apr 2025 07:49AM UTC coverage: 41.803% (+3.9%) from 37.949%
14726106855

push

github

web-flow
Merge pull request #124 from Nikorag/ytdlp

YT-DLP Support

214 of 563 branches covered (38.01%)

Branch coverage included in aggregate %.

334 of 892 new or added lines in 61 files covered. (37.44%)

26 existing lines in 15 files now uncovered.

755 of 1755 relevant lines covered (43.02%)

3.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/validators/ConfigFormValidator.ts
1
import Handlebars from 'handlebars';
×
2

3
import nzbFacade from '../facade/nzbFacade';
×
4
import { FilenameTemplateContext } from '../types/FilenameTemplateContext';
5
import { Validator } from './Validator';
×
6

7
const cronRegex: RegExp =
NEW
8
    /^(\*|([0-5]?[0-9])) (\*|([01]?[0-9]|2[0-3])) (\*|([01]?[1-9]|[12][0-9]|3[01])) (\*|([1-9]|1[0-2])) (\*|([0-6]))(\s(\d{4}))?$/;
×
9

10
export class ConfigFormValidator extends Validator {
×
11
    async validate(input: any): Promise<{ [key: string]: string }> {
NEW
12
        const validatorError: { [key: string]: string } = {};
×
NEW
13
        if (!this.directoryExists(input.DOWNLOAD_DIR)) {
×
UNCOV
14
            validatorError['DOWNLOAD_DIR'] = `Directory ${input.DOWNLOAD_DIR} does not exist`;
×
15
        }
NEW
16
        if (!this.directoryExists(input.COMPLETE_DIR)) {
×
17
            validatorError['COMPLETE_DIR'] = `Directory ${input.COMPLETE_DIR} does not exist`;
×
18
        }
NEW
19
        if (!this.isNumber(input.ACTIVE_LIMIT)) {
×
20
            validatorError['ACTIVE_LIMIT'] = 'Download limit must be a number';
×
21
        } else if (input.ACTIVE_LIMIT < 0) {
×
22
            validatorError['ACTIVE_LIMIT'] = 'Download limit must be a positive number';
×
23
        }
24

NEW
25
        if (!this.isNumber(input.RSS_FEED_HOURS)) {
×
26
            validatorError['RSS_FEED_HOURS'] = 'RSS Feed Hours must be a number';
×
27
        } else if (input.RSS_FEED_HOURS < 0) {
×
28
            validatorError['RSS_FEED_HOURS'] = 'RSS Feed Hours must be a positive number';
×
29
        }
30

NEW
31
        if (!input.AUTH_USERNAME) {
×
32
            validatorError['AUTH_USERNAME'] = 'Please provide a Username';
×
33
        }
NEW
34
        if (!input.AUTH_PASSWORD) {
×
35
            validatorError['AUTH_PASSWORD'] = 'Please provide a Password';
×
36
        }
NEW
37
        if (!this.matchesRegex(input.REFRESH_SCHEDULE, cronRegex)) {
×
38
            validatorError['REFRESH_SCHEDULE'] = 'Please provide a valid cron expression';
×
39
        }
NEW
40
        if (!this.compilesSuccessfully(input.TV_FILENAME_TEMPLATE)) {
×
41
            validatorError['TV_FILENAME_TEMPLATE'] = 'Template does not compile';
×
42
        }
NEW
43
        if (!this.compilesSuccessfully(input.MOVIE_FILENAME_TEMPLATE)) {
×
44
            validatorError['MOVIE_FILENAME_TEMPLATE'] = 'Template does not compile';
×
45
        }
NEW
46
        if (input.NZB_URL || input.NZB_API_KEY || input.NZB_TYPE || input.NZB_USERNAME || input.NZB_PASSWORD) {
×
NEW
47
            const response: string | boolean = await nzbFacade.testConnection(
×
48
                input.NZB_TYPE,
49
                input.NZB_URL,
50
                input.NZB_API_KEY,
51
                input.NZB_USERNAME,
52
                input.NZB_PASSWORD
53
            );
NEW
54
            if (response != true) {
×
55
                validatorError['NZB_URL'] = response as string;
×
56
                validatorError['NZB_API_KEY'] = response as string;
×
57
                validatorError['NZB_USERNAME'] = response as string;
×
58
                validatorError['NZB_PASSWORD'] = response as string;
×
59
            }
60
        }
61
        return validatorError;
×
62
    }
63

64
    compilesSuccessfully(template: string): boolean {
65
        try {
×
NEW
66
            const hbTemplate = Handlebars.compile(template, { strict: true });
×
NEW
67
            const dummyContext: FilenameTemplateContext = {
×
68
                title: 'title',
69
                season: '01',
70
                episode: '01',
71
                quality: '720p',
72
            };
73
            hbTemplate(dummyContext);
×
74
            return true;
×
75
        } catch {
76
            return false;
×
77
        }
78
    }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc