diff --git a/Gulpfile.coffee b/Gulpfile.coffee deleted file mode 100644 index 796e55c..0000000 --- a/Gulpfile.coffee +++ /dev/null @@ -1,54 +0,0 @@ -"use strict" - -spawn = require("child_process").spawn -gulp = require "gulp" -plugins = require("gulp-load-plugins")() -yargs = require("yargs") - .alias("m", "message") - -gulp.task "coffeelint", -> - gulp.src("./src/index.coffee") - .pipe plugins.coffeelint() - .pipe plugins.coffeelint.reporter() - -gulp.task "coffee", ["coffeelint"], -> - gulp.src("./src/index.coffee") - .pipe(plugins.coffee(bare: true).on("error", plugins.util.log)) - .pipe(plugins.header("#!/usr/bin/env node\n")) - .pipe(gulp.dest("./lib")) - -gulp.task "build", ["coffee"] - -inc = (importance) -> - gulp.src("./package.json") - .pipe(plugins.bump(type: importance)) - .pipe(gulp.dest("./")) - -gulp.task "patch", -> - inc("patch") - -gulp.task "feature", -> - inc("minor") - -gulp.task "release", -> - inc("major") - -gulp.task "commit", -> - gulp.src("./*") - .pipe(plugins.git.commit(yargs.argv.m, args: "--amend")) - -gulp.task "tag", -> - gulp.src(["./package.json"]).pipe(plugins.tagVersion()) - -gulp.task "push-tags", -> - plugins.git.push "origin", "master", args: "--tags", (err) -> - throw err if err - -gulp.task "push", -> - plugins.git.push "origin", "master", (err) -> - throw err if err - -gulp.task "publish", (done) -> - spawn "npm", ["publish"], - stdio: "inherit" - .on "close", done diff --git a/src/index.coffee b/src/index.coffee deleted file mode 100644 index 2c3870c..0000000 --- a/src/index.coffee +++ /dev/null @@ -1,139 +0,0 @@ -"use strict" - -spawn = require("child_process").spawn -urllib = require "urllib" -cheerio = require "cheerio" -_ = require "lodash" -inquirer = require "inquirer" -url = "http://jkanime.net/" -version = require("../package").version -yargs = require("yargs") - .usage("Show anime\n\nUsage: $0") - .example("$0", "Choose interactive anime") - .example( - "$0 -t naruto-shippuden -c 380", - "Show chapter 380 of Naruto Shippuden") - .example( - "$0 -t naruto-shippuden -c 380 -v", - "Show chapter 380 of Naruto Shippuden in vlc") - .alias("c", "chapter").describe("c", "Choose a chapter anime") - .alias("t", "title").describe("t", "Choose a title anime") - .alias("v", "vlc").describe("v", "Autoplay in vlc").boolean("v") - .alias("k", "mpv").describe("k", "Autoplay in mpv (default)").boolean("k") - .alias("m", "mplayer").describe("m", "Autoplay in mplayer").boolean("m") - .alias("o", "omx").describe("o", "Autoplay in omxplayer").boolean("o") - .alias("f", "file").describe("f", "Download to file") - .alias("u", "url").describe("f", "Download from url") - .version(version, "version").alias("version", "V") - .help("help").alias("help", "h") - -ANIME = - title: "" - codeName: "" - chapter: "" - -searchAnime = (search, cb) -> - urllib.request "#{url}buscar/#{search}", - method: "GET" - , (err, data, response) -> - if not err and response.statusCode is 200 - $ = cheerio.load data.toString() - animes = [] - $(".listpage .titl").each -> - animes.push - value: $(this).attr("href") - name: $(this).text() - cb err, animes - else - cb err, null - -getUrlVideo = (animeUrl, cb) -> - urllib.request "#{animeUrl}", - method: "GET" - , (err, data, response) -> - if not err and response.statusCode is 200 - $ = cheerio.load data.toString() - ANIME.title = $(".vervideo").text().split(" - ")[0] - [ANIME.codeName, ANIME.chapter] = animeUrl.replace(url, "").split "/" - try - links = $(".player_conte param[value^=file]") - value = links[links.length - 1].attribs.value - url = value.split("file=")[1].split("/&provider")[0] - catch err - url = null - cb err, url - else - cb err, null - -runPlayer = (url, player) -> - console.log "INFO" - console.log "full title: #{ANIME.title}" - console.log "title: #{ANIME.codeName}" - console.log "chapter: #{ANIME.chapter}" - console.log "url: #{url}" - spawn player, [url], - detached: true - stdio: "ignore" - -download = (url, file) -> - console.log "INFO" - console.log "full title: #{ANIME.title}" - console.log "title: #{ANIME.codeName}" - console.log "chapter: #{ANIME.chapter}" - console.log "url: #{url}\n\n" - console.log "For download next chapter: #{yargs.argv["$0"]} -t " + - "#{ANIME.codeName} -c #{ANIME.chapter + 1} -f #{ANIME.codeName}_" + - "#{ANIME.chapter + 1}.mp4" - file = "#{ANIME.codeName}_#{ANIME.chapter}.mp4" if file is true - spawn "wget", [url, "-O", file], - detached: true - stdio: "ignore" - -if yargs.argv.u or (yargs.argv.t and yargs.argv.c) - if yargs.argv.u - animeUrl = yargs.argv.u - else - animeUrl = "#{url}#{yargs.argv.t}/yargs.argv.c" - player = "mpv" - player = "mpv" if yargs.argv.k - player = "mplayer" if yargs.argv.m - player = "vlc" if yargs.argv.v - player = "omxplayer" if yargs.argv.o - getUrlVideo animeUrl, (err, url) -> - if err - console.log "An error has occurred :(" - process.exit 1 - if yargs.argv.file - file = yargs.argv.file - download url, file - else - runPlayer url, player -else - options = - type: "input" - name: "search" - message: "Enter a anime name" - inquirer.prompt options, (answer) -> - searchAnime answer.search, (err, animes) -> - options = - type: "list" - name: "anime" - message: "Select a anime" - choices: animes - inquirer.prompt options, (answer) -> - animeUrl = answer.anime - options = - type: "input" - name: "chapter" - message: "Enter a number chapter" - default: "1" - inquirer.prompt options, (answer) -> - getUrlVideo animeUrl, answer.chapter, (err, url) -> - options = - type: "list" - name: "player" - message: "Select player" - default: "mpv" - choices: ["mpv", "vlc", "mplayer"] - inquirer.prompt options, (answer) -> - runPlayer url, answer.player