Skip to content

Commit

Permalink
Add option to download.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Gatica committed Feb 15, 2015
1 parent 6b453bf commit 31baae9
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
26 changes: 16 additions & 10 deletions Gulpfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@
gulp = require "gulp"
plugins = require("gulp-load-plugins")()
runSequence = require "run-sequence"
yargs = require("yargs")
.alias("m", "message")

gulp.task "coffeelint", ->
gulp.src("./src/index.coffee")
.pipe plugins.coffeelint()
.pipe plugins.coffeelint.reporter()

gulp.task "coffee", ->
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", (cb) ->
runSequence(
"coffeelint"
"coffee"
cb
)
gulp.task "build", ["coffee"]

inc = (importance) ->
gulp.src("./package.json")
.pipe(plugins.bump(type: importance))
.pipe(gulp.dest("./"))
.pipe(plugins.git.commit("bumps package version"))
.pipe(plugins.filter("package.json"))
.pipe(plugins.tagVersion())

gulp.task "patch", ->
inc("patch")
Expand All @@ -38,3 +32,15 @@ gulp.task "feature", ->

gulp.task "release", ->
inc("major")

gulp.task "commit", ->
gulp.src("./*")
.pipe(plugins.git.commit(yargs.argv.m, args: "--amend"))

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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
anime-dl
========

[![npm version](https://badge.fury.io/js/anime-dl.svg)](http://badge.fury.io/js/anime-dl)

CLI for show anime whit subs in spanish.

Requirements
------------

- [mpv](http://mpv.io/installation/)
- [wget](https://www.gnu.org/software/wget/)
- [vlc (optional)](http://www.videolan.org/vlc/#download)
- [mplayer2 (optional)](http://www.mplayer2.org/downloads/)
- [omxplayer (optional)](https://github.com/huceke/omxplayer/)
Expand Down Expand Up @@ -41,3 +44,9 @@ Show a chapter of a anime in vlc
``` bash
anime-dl -c [number] -t [title-anime] -v
```

Download a chapter of a anime. Example of title: dragon-ball. Require wget

``` bash
anime-dl -c [number] -t [title-anime] -f video.mp4
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anime-dl",
"version": "1.1.0",
"version": "1.2.0",
"description": "CLI for show anime whit subs in spanish.",
"main": "lib",
"dependencies": {
Expand Down
24 changes: 23 additions & 1 deletion src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ yargs = require("yargs")
.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")
.version(version, "version").alias("version", "V")
.help("help").alias("help", "h")

Expand Down Expand Up @@ -75,6 +76,20 @@ runPlayer = (url, player) ->
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.t and yargs.argv.c
animeUrl = "#{url}#{yargs.argv.title}/"
player = "mpv"
Expand All @@ -83,7 +98,14 @@ if yargs.argv.t and yargs.argv.c
player = "vlc" if yargs.argv.v
player = "omxplayer" if yargs.argv.o
getUrlVideo animeUrl, yargs.argv.chapter, (err, url) ->
runPlayer url, player
if err
console.log "An error has occurred :("
exit
if yargs.argv.file
file = yargs.argv.file
download url, file
else
runPlayer url, player
else
options =
type: "input"
Expand Down

0 comments on commit 31baae9

Please sign in to comment.