Make tslint happy!

This commit is contained in:
Godzil 2018-06-01 21:23:05 +01:00
parent 849c7612aa
commit 7c04fb7282
10 changed files with 60 additions and 55 deletions

View File

@ -32,7 +32,7 @@ export default function(args: string[], done: (err?: Error) => void)
}
catch (e)
{
log.warn(`Invalid resolution ${config.resolution}p. Setting to 1080p`);
log.warn('Invalid resolution ' + config.resolution + 'p. Setting to 1080p');
config.video_format = resol_table['1080'].format;
config.video_quality = resol_table['1080'].quality;
}
@ -46,7 +46,10 @@ export default function(args: string[], done: (err?: Error) => void)
tasks(config, batchPath, (err, tasksArr) =>
{
if (err) return done(err);
if (err)
{
return done(err);
}
let i = 0;

View File

@ -8,6 +8,6 @@ batch(process.argv, (err: any) =>
console.error(err.stack || err);
process.exit(-1);
}
console.log('Done!');
console.info('Done!');
process.exit(0);
});

View File

@ -271,7 +271,7 @@ function scrapePage(config: IConfig, address: string, done: (err: Error, page?:
const regexp = /\s*([^\n\r\t\f]+)\n?\s*[^0-9]*([0-9][\-0-9.]*)?,?\n?\s\s*[^0-9]*((PV )?[S0-9][P0-9.]*[a-fA-F]?)/;
const look = $('#showmedia_about_media').text();
const seasonTitle = $('span[itemprop="title"]').text();
let episodeTitle = $('#showmedia_about_name').text().replace(/[“”]/g, '');
const episodeTitle = $('#showmedia_about_name').text().replace(/[“”]/g, '');
const data = regexp.exec(look);
if (!swf || !data)

View File

@ -13,33 +13,33 @@ const cloudscraper = require('cloudscraper');
let isAuthenticated = false;
let isPremium = false;
const defaultHeaders: request.Headers =
const defaultHeaders: request.Headers =
{
'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64; x64; rv:58.0) Gecko/20100101 Firefox/58.0',
'Connection': 'keep-alive',
'Referer': 'https://www.crunchyroll.com/login',
};
function generateDeviceId(): string
function generateDeviceId(): string
{
let id = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 32; i++)
for (let i = 0; i < 32; i++)
{
id += possible.charAt(Math.floor(Math.random() * possible.length));
id += possible.charAt(Math.floor(Math.random() * possible.length));
}
return id;
}
function startSession(): Promise<string>
function startSession(): Promise<string>
{
return rp(
{
method: 'GET',
url: 'CR_SESSION_URL',
qs:
qs:
{
device_id: generateDeviceId(),
device_type: 'CR_DEVICE_TYPE',
@ -49,7 +49,7 @@ function startSession(): Promise<string>
},
json: true,
})
.then((response: any) =>
.then((response: any) =>
{
return response.data.session_id;
});
@ -61,7 +61,7 @@ function login(sessionId: string, user: string, pass: string): Promise<any>
{
method: 'POST',
url: 'CR_LOGIN_URL',
form:
form:
{
account: user,
password: pass,
@ -210,10 +210,10 @@ function modify(options: string|request.Options, reqMethod: string): request.Opt
options.method = reqMethod;
return options;
}
return {
jar: true,
headers: defaultHeaders,
url: options.toString(),
method: reqMethod
return {
jar: true,
headers: defaultHeaders,
url: options.toString(),
method: reqMethod
};
}

View File

@ -2,7 +2,7 @@
import cheerio = require('cheerio');
import episode from './episode';
import fs = require('fs');
const fse = require('fs-extra');
import fse = require('fs-extra');
import my_request = require('./my_request');
import path = require('path');
import url = require('url');
@ -153,7 +153,7 @@ function page(config: IConfig, address: string, done: (err: Error, result?: ISer
episode: '',
volume: 0,
});
done(null, {episodes: episodes.reverse(), series: ""});
done(null, {episodes: episodes.reverse(), series: ''});
}
else
{
@ -195,7 +195,7 @@ function page(config: IConfig, address: string, done: (err: Error, result?: ISer
});
if (episodeCount === 0)
{
log.warn("No episodes found for " + title + ". Could it be a movie?");
log.warn('No episodes found for ' + title + '. Could it be a movie?');
}
done(null, {episodes: episodes.reverse(), series: title});
});

View File

@ -33,10 +33,10 @@ export default function(input: string|Buffer, done: (err: Error, subtitle?: stri
*/
function event(block: ISubtitleEvent): string
{
var format = 'Layer,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text';
const format = 'Layer,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text';
return '[Events]\n' +
'Format: ' + format + '\n' + [].concat(block.event).map(style => ('Dialogue: 0,' +
'Format: ' + format + '\n' + [].concat(block.event).map((style) => ('Dialogue: 0,' +
style.$.start + ',' +
style.$.end + ',' +
style.$.style + ',' +
@ -70,13 +70,13 @@ function script(block: ISubtitle): string
*/
function style(block: ISubtitleStyle): string
{
var format = 'Name,Fontname,Fontsize,PrimaryColour,SecondaryColour,' +
const format = 'Name,Fontname,Fontsize,PrimaryColour,SecondaryColour,' +
'OutlineColour,BackColour,Bold,Italic,Underline,StrikeOut,ScaleX,' +
'ScaleY,Spacing,Angle,BorderStyle,Outline,Shadow,Alignment,' +
'MarginL,MarginR,MarginV,Encoding';
return '[V4+ Styles]\n' +
'Format: ' + format + '\n' + [].concat(block.style).map(style => 'Style: ' +
'Format: ' + format + '\n' + [].concat(block.style).map((style) => 'Style: ' +
style.$.name + ',' +
style.$.font_name + ',' +
style.$.font_size + ',' +

View File

@ -2,7 +2,7 @@
import ass from './ass';
import srt from './srt';
export default <IFormatterTable> {
ass: ass,
srt: srt
};
export default {
ass,
srt
} as IFormatterTable;

View File

@ -17,7 +17,7 @@ export default function(config: IConfig, isSubtitled: boolean, rtmpInputPath: st
if (streamMode === 'RTMP')
{
videoPath += path.extname(rtmpInputPath);
videoPath += path.extname(rtmpInputPath);
}
else
{

View File

@ -11,30 +11,31 @@ import log = require('../log');
export default function(rtmpUrl: string, rtmpInputPath: string, swfUrl: string, filePath: string,
fileExt: string, mode: string, done: (err: Error) => void)
{
if (mode === 'RTMP')
{
childProcess.exec(command('rtmpdump') + ' ' +
'-r "' + rtmpUrl + '" ' +
'-y "' + rtmpInputPath + '" ' +
'-W "' + swfUrl + '" ' +
'-o "' + filePath + fileExt + '"', {
maxBuffer: Infinity,
}, done);
}
else if (mode === 'HLS')
{
const cmd = command('ffmpeg') + ' ' +
'-i "' + rtmpInputPath + '" ' +
'-c copy -bsf:a aac_adtstoasc ' +
'"' + filePath + '.mp4"';
childProcess.exec(cmd, {
maxBuffer: Infinity,
}, done);
}
else
{
log.error('No such mode: ' + mode);
}
if (mode === 'RTMP')
{
childProcess.exec(command('rtmpdump') + ' ' +
'-r "' + rtmpUrl + '" ' +
'-y "' + rtmpInputPath + '" ' +
'-W "' + swfUrl + '" ' +
'-o "' + filePath + fileExt + '"', {
maxBuffer: Infinity,
}, done);
}
else if (mode === 'HLS')
{
const cmd = command('ffmpeg') + ' ' +
'-i "' + rtmpInputPath + '" ' +
'-c copy -bsf:a aac_adtstoasc ' +
'"' + filePath + '.mp4"';
childProcess.exec(cmd,
{
maxBuffer: Infinity,
}, done);
}
else
{
log.error('No such mode: ' + mode);
}
}
/**
@ -44,7 +45,7 @@ function command(exe: string): string
{
if (os.platform() !== 'win32')
{
return exe;
return exe;
}
return '"' + path.join(__dirname, '../../bin/' + exe + '.exe') + '"';

View File

@ -17,11 +17,12 @@
"member-ordering": false,
"no-shadowed-variable": false,
"array-type": [true, "array"],
"object-literal-sort-keys": false,
"trailing-comma": false,
"no-any": false,
"no-arg": true,
"no-bitwise": true,
"space-within-parens": false,
"no-object-literal-type-assertion": false,
"no-console": [true,
"debug",
"time",