Skip to content

Commit

Permalink
Add suppor for download from url.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Gatica committed Mar 29, 2015
1 parent a1a7a01 commit 4873922
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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.2.5",
"version": "1.3.0",
"description": "CLI for show and download anime from jkanime.net.",
"main": "lib",
"dependencies": {
Expand Down
14 changes: 9 additions & 5 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ yargs = require("yargs")
.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")

Expand All @@ -46,8 +47,8 @@ searchAnime = (search, cb) ->
else
cb err, null

getUrlVideo = (animeUrl, chapter, cb) ->
urllib.request "#{animeUrl}#{chapter}",
getUrlVideo = (animeUrl, cb) ->
urllib.request "#{animeUrl}",
method: "GET"
, (err, data, response) ->
if not err and response.statusCode is 200
Expand Down Expand Up @@ -91,14 +92,17 @@ download = (url, file) ->
detached: true
stdio: "ignore"

if yargs.argv.t and yargs.argv.c
animeUrl = "#{url}#{yargs.argv.title}/"
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, yargs.argv.chapter, (err, url) ->
getUrlVideo animeUrl, (err, url) ->
if err
console.log "An error has occurred :("
process.exit 1
Expand Down

0 comments on commit 4873922

Please sign in to comment.