Skip to content

Commit

Permalink
Remove run player. Fix output
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Mar 20, 2016
1 parent b082458 commit abc0c98
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

'use strict';

import {spawn} from 'child_process';
import program from 'commander';
import animeDl from 'anime-dl';
import chalk from 'chalk';
Expand All @@ -17,18 +16,15 @@ program
.description('CLI for get chapter link')
.option('-a, --anime [anime]', 'Add name')
.option('-c, --chapter [chapter]', 'Add chapter')
.option('-p, --player', 'Run player (optional). Availables: mpv|vlc|mplayer|omxplayer|smplayer|cvlc. Default: mpv', /(mpv|vlc|mplayer|omxplayer|smplayer|cvlc)/i, 'mpv')
.parse(process.argv);

if (program.anime && program.chapter) {
console.log(chalk.green('Searching...'));
animeDl.getLinksByNameAndChapter(program.anime, program.chapter).then((data) => {
if (data.urls.length === 0) return console.log(chalk.red('Not found a link'));
const chapter = data.urls[data.urls.length - 1];
if (program.player) {
console.log(chalk.green(`Wait running ${program.player} ${chapter} ...`));
spawn(program.player, [chapter], {detached: true, stdio: 'ignore'});
} else {
console.log(chalk.green(`Run ${chapter} in any player`));
console.log(chalk.green('Run any this links in your video player'));
for (let url of data.urls) {
console.log(chalk.green(url));
}
}).catch((err) => console.log(chalk.red(`Error: ${err.message}`)));
} else {
Expand Down

0 comments on commit abc0c98

Please sign in to comment.