Skip to content

Commit

Permalink
docs(readme): update to follow new implementation
Browse files Browse the repository at this point in the history
After cli implementation, update usage, download and add streaming
information.  Also removes outdated things and updates all command
examples
  • Loading branch information
vinnyA3 committed Jun 21, 2022
1 parent 86d61b2 commit 5ac0899
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 60 deletions.
82 changes: 32 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AnimeGo-DL
![NPM Latest](https://img.shields.io/npm/v/animego-dl/latest?style=flat-square)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

A simple node-based cli tool that downloads your desired anime series from `gogoanimes`!
A *blazing fast* :rocket: node-based cli tool that streams (or downloads) anime from `gogoanimes`!

---

Expand All @@ -16,10 +16,8 @@ A simple node-based cli tool that downloads your desired anime series from `gogo
* [Dependencies](#dependencies)
* [Installation](#installation)
* [Usage](#usage)
- [Downloaded output examples](#output)
- [Dub](#dub)
- [Sub](#sub)
- [Docker](#docker)
- [Streaming](#streaming)
- [Downloading](#downloading)
* [Contributing](#contributing)
* [Development](#development)
- [Testing](#testing)
Expand Down Expand Up @@ -62,71 +60,55 @@ Install from source:
## Usage

```sh
Usage: animego-dl [options] <anime name>
Usage: animego-dl [options]

CLI tool to download your favorite anime series.

Arguments:
anime name The name of anime series to download [string] [required]

Options:
-V, --version output the version number
-d, --directory <string> the download directory for your anime [string] [required]
-h, --help display help for command
-v, --version output the current version
-d, --download choose to download your desired anime
-h, --help display help for command
```

**note**: if you installed the package globally, you can simply run:

```sh
animego-dl -d ./my-anime-directory '<anime series name>'`
animego-dl
```

If you did not install globally & installed from source, you can run the following from the root of the project:
If you did not install globally & installed from source (but do not want to link to your machine), you can run the following from the root of the project (after running `npm run build` - to compile from typescript):
```
node ./dist/bin -d ./my-anime-directory '<anime series name>'`
node ./dist/bin
```

---
### Output
### Streaming

The anime, of your choosing, will be downloaded to the directory that you
specfied at the `-d` option's argument. A directory of the anime will be
created and named like: `Neon Genesis Evangelion (Dub) (1995)/`. Each episode will be
numbered & named like: `episode-00.mp4`, `episode-01.mp4` .. etc.
To stream, just run the tool (`animego-dl`) and you're good to go! You will
prompted to search for you desired anime, then will be presented a range(s) of
episode numbers to select from. Using the CLI, input the episode number you
wish to watch.

Example:
```
my-anime
└── Neon\ Genesis\ Evangelion\ (Dub)\ (1995)
└── episode-01.mp4
└── episode-02.mp4
└── episode-03.mp4
└── episode-04.mp4
```
---
> :notebook: The tool will try to spin up [MPV](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjU26PJnb34AhXAIzQIHbX9BqsQFnoECAkQAQ&url=https%3A%2F%2Fmpv.io%2F&usg=AOvVaw1b8_yCiS5ge8PPghViO-l-) by default. If MPV isn't
> detected, you'll receive the video source in the output -- you can use this
> source, and plug into a stream client of your choice (more default player
> support coming soon!)
> :warning: Please make sure that your input anime series title is properly
> formatted (improvements to tool will be made in the near future).
### Downloading

### Dub
You can specify a dub selection by suffixing your anime name with 'dub'.
Example(s):
* specify dub: `animego-dl -d ./my-anime-directory 'Berserk dub'`
- no special characters, params, or dashes
To download an anime episode, pass the `-d` option when starting the tool:
```bash
animego-dl -d
```

### Sub
Next, search & select the episode you'd like to download via the cli. Enjoy!

Sub versions can be downloaded by providing just the title of the desired anime.
> :warning: The tool will download to your current working directory (where you
> ran the command), and under a directory named `animego-dl` -- options to
> choose your destination directory will be added soon!
Examples:
* specify sub: `animego-dl -d ./my-anime-directory 'sono bisque doll wa koi wo suru'`
- no special characters, params, or dashes
---

### Docker
## Docker

First, make sure you installed the [Docker image](https://hub.docker.com/r/vinnya3/animego-dl).

Expand Down Expand Up @@ -169,10 +151,10 @@ npm run build
The aforementioned will compile to `/dist`. For here, you can execute the
program with:
```bash
node ./dist/bin -d ./my-anime-directory '<anime series name>'
node ./dist/bin
```

### Testing
## Testing

To run local tests: `npm run test`

Expand Down
15 changes: 10 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const ytDLPDownload = async (
if (checkExecutableSync("yt-dlp")) {
process.cwd();
await mkdirAsync(location, { recursive: true });
await downloadAndSaveVideo(source, name);
await downloadAndSaveVideo(source, location, name);
return locales.downloadSuccess(name);
}

Expand All @@ -38,18 +38,23 @@ const ytDLPDownload = async (

const init = async (cliOptions: { download?: boolean }) => {
const { download: shouldDownload } = cliOptions;
const resultPayload = await Gogoanime.processing.searchAndDownloadEpisode(
const result = await Gogoanime.processing.searchAndDownloadEpisode(
shouldDownload
);

if (!(resultPayload?.videoSourceUrl && resultPayload?.title)) {
if (!(result?.videoSourceUrl && result?.title && result?.episodeNumber)) {
return errorLocales.couldNotExtractVideo;
}

const { videoSourceUrl, title } = resultPayload;
const { videoSourceUrl, title, episodeNumber } = result;

if (shouldDownload) {
ytDLPDownload(path.join("./animego-dl", title), videoSourceUrl, title);
ytDLPDownload(
path.join("./animego-dl", title),
videoSourceUrl,
`episode-${episodeNumber}`
);

return;
}

Expand Down
13 changes: 11 additions & 2 deletions src/providers/gogoanime/processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ const downloadSeries = async (cliOptions: {

if (videoSourceUrl) {
console.info(`Now downloading: ${episodeUrl}\n`);
await downloadAndSaveVideo(videoSourceUrl, videoName);
await downloadAndSaveVideo(
videoSourceUrl,
seriesTargetLocation,
videoName
);

console.info("The video has been downloaded!\n");
}
}
Expand Down Expand Up @@ -217,7 +222,11 @@ const searchAndDownloadEpisode = async (download?: boolean) => {
.then(decryptAndGetVideoSources)
.then(parseSourcesAndGetVideo);

return { title: theChosenOne, videoSourceUrl };
return {
title: theChosenOne,
episodeNumber: selectedEpisodeNumber,
videoSourceUrl,
};
}

console.log("Episode not in range ...");
Expand Down
12 changes: 9 additions & 3 deletions src/utils/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ import { spawn } from "child_process";

import locales from "../locales";

const downloadAndSaveVideo = (videoSourceUrl: string, videoName: string) =>
const downloadAndSaveVideo = (
source: string,
location: string,
videoName: string
) =>
new Promise((resolve, reject) => {
if (!videoSourceUrl) {
if (!source) {
return reject(locales.errors.downloadAndSave);
}

const ytDl = spawn("yt-dlp", [
"-P",
location,
"-o",
`${videoName}.%(ext)s`,
videoSourceUrl,
source,
]);

ytDl.stdout.on("data", (buf) => console.log(buf.toString("utf8")));
Expand Down

0 comments on commit 5ac0899

Please # to comment.