-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from pheyvaer/feature/refactor+cli
Major refactor
- Loading branch information
Showing
11 changed files
with
865 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# MIT License | ||
|
||
Copyright © 2018 Between Our Worlds | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF | ||
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# kitsu-downloader | ||
|
||
This tool downloads the anime and character data from [Kitsu](https://kitsu.io). | ||
Linked Data can then be generated from this data via the corresponding [rules](https://github.com/betweenourworlds/generation-rules). | ||
|
||
## Installation | ||
|
||
1. Clone this repo | ||
2. Navigate into the folder: `cd kitsu-downloader` | ||
3. Install Node dependencies: `npm i` | ||
4. Link the bin: `npm link` | ||
|
||
## Usage | ||
|
||
The tool takes the following arguments | ||
|
||
- `-V, --version`: output the version number | ||
- `-e, --entity [entity]`: Choose between "anime" and "character" | ||
- `-s, --start [start]`: Number of start page | ||
- `-t, --stop [stop]`: Number of stop page | ||
- `-o, --output [output]`: Path to output folder (default: "") | ||
- `-v, --verbose`: Make the application more talkative | ||
- `-h, --help`: output usage information | ||
|
||
When you execute `kitsu-downloader -e anime -s 0 -t 199 -o test`, | ||
the first 200 pages of anime data will be downloaded and the 200 files will be put in the folder `test`. | ||
|
||
## License | ||
|
||
2018 Between Our Worlds, [MIT License](https://github.com/betweenourworlds/kitsu-downloader/blob/master/LICENSE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#! /usr/bin/env node | ||
|
||
const program = require('commander'); | ||
const logger = require('../lib/logger'); | ||
const AnimeDownloader = require('../lib/animeDownloader'); | ||
const CharacterDownloader = require('../lib/characterDownloader'); | ||
const Writer = require('../lib/writer'); | ||
|
||
program | ||
.version('0.0.1') | ||
.option('-e, --entity [entity]', 'Choose between "anime" and "character"') | ||
.option('-s, --start [start]', 'Number of start page') | ||
.option('-t, --stop [stop]', 'Number of stop page') | ||
.option('-o, --output [output]', 'Path to output folder', '') | ||
.option('-v, --verbose', 'Make the application more talkative', '') | ||
.parse(process.argv); | ||
|
||
if (program.verbose) { | ||
//todo set level of logger | ||
} | ||
|
||
if (program.entity === undefined || program.start === undefined || program.start === undefined) { | ||
logger.error('Not all required parameters are provided.'); | ||
process.exit(1); | ||
} else { | ||
if (program.output === undefined) { | ||
program.output = process.cwd(); | ||
} | ||
|
||
const writer = new Writer(program.output); | ||
let Downloader; | ||
|
||
if (program.entity === 'anime') { | ||
Downloader = AnimeDownloader; | ||
} else if (program.entity === 'character') { | ||
Downloader = CharacterDownloader; | ||
} else { | ||
logger.error(`-e expects the value "anime" or "character"`); | ||
process.exit(1); | ||
} | ||
|
||
const downloader = new Downloader(writer); | ||
downloader.downloadRecursive(parseInt(program.start), parseInt(program.stop)); | ||
} |
Oops, something went wrong.