mirror of
https://github.com/ION606/ion-cli.git
synced 2026-05-14 22:16:56 +00:00
bug fixes
This commit is contained in:
@@ -5,10 +5,7 @@ import chalk from 'chalk';
|
|||||||
export default async function donwloadFromStream(url, newpath) {
|
export default async function donwloadFromStream(url, newpath) {
|
||||||
try {
|
try {
|
||||||
const vpath = await getJSON("vpath");
|
const vpath = await getJSON("vpath");
|
||||||
const command = `${vpath} ${url}`;
|
|
||||||
// start "C:\Program Files\VideoLAN\VLC\vlc.exe" url
|
// start "C:\Program Files\VideoLAN\VLC\vlc.exe" url
|
||||||
console.log(chalk.green('done! Hit enter to watch!'));
|
|
||||||
console.log(command);
|
|
||||||
|
|
||||||
execFileSync(vpath, [url], {
|
execFileSync(vpath, [url], {
|
||||||
stdio: ['ignore']
|
stdio: ['ignore']
|
||||||
|
|||||||
+3
-29
@@ -71,7 +71,6 @@ async function getAnime9(id, episode = null) {
|
|||||||
console.log(chalk.green('Fetching video sources...'));
|
console.log(chalk.green('Fetching video sources...'));
|
||||||
url = `https://api.consumet.org/anime/9anime/watch/${episodeData.id}`; //?server={serverName}`
|
url = `https://api.consumet.org/anime/9anime/watch/${episodeData.id}`; //?server={serverName}`
|
||||||
const epResp = await axios.get(url);
|
const epResp = await axios.get(url);
|
||||||
console.log(epResp.data)
|
|
||||||
const epSource = epResp.data.sources[0];
|
const epSource = epResp.data.sources[0];
|
||||||
|
|
||||||
const vidPath = await getJSON("apath");
|
const vidPath = await getJSON("apath");
|
||||||
@@ -79,15 +78,10 @@ async function getAnime9(id, episode = null) {
|
|||||||
const newpath = path.resolve(vidPath, data.title + ' - ' + episodeData.title + '.m3u8');
|
const newpath = path.resolve(vidPath, data.title + ' - ' + episodeData.title + '.m3u8');
|
||||||
|
|
||||||
console.log(chalk.green('done!'));
|
console.log(chalk.green('done!'));
|
||||||
console.log(chalk.green('writing to local file...'));
|
console.log(chalk.green(`Now playing ${chalk.bold(`${data.title} episode ${epNumber} - ${episodeData.title}`)}`));
|
||||||
|
|
||||||
console.log(epSource);
|
|
||||||
|
|
||||||
//Download the file
|
//Download the file
|
||||||
downloadStream(epSource.url, newpath);
|
downloadStream(epSource.url, newpath);
|
||||||
|
|
||||||
|
|
||||||
console.log(chalk.green('done!'));
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return console.log(chalk.red(`ERROR: ${err.message}\n\nTask aborted`));
|
return console.log(chalk.red(`ERROR: ${err.message}\n\nTask aborted`));
|
||||||
@@ -114,7 +108,6 @@ async function getSearchTerm(name, episode = null) {
|
|||||||
url = `https://api.consumet.org/anime/9anime/${name}`;
|
url = `https://api.consumet.org/anime/9anime/${name}`;
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.get(url);
|
const { data } = await axios.get(url);
|
||||||
|
|
||||||
if (data.results.length == 0) {
|
if (data.results.length == 0) {
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
return console.log(chalk.red("No results found (is the API down?)"));
|
return console.log(chalk.red("No results found (is the API down?)"));
|
||||||
@@ -131,24 +124,10 @@ async function getSearchTerm(name, episode = null) {
|
|||||||
|
|
||||||
|
|
||||||
async function getUrl(name, episode = null) {
|
async function getUrl(name, episode = null) {
|
||||||
const animeTerm = await getSearchTerm(name, episode);
|
getSearchTerm(name, episode);
|
||||||
return console.log(animeTerm);
|
|
||||||
const animeEpisode = animeTerm.episodesList.find((a) => (a.episodeNum == episode));
|
|
||||||
|
|
||||||
console.log(animeEpisode);
|
|
||||||
|
|
||||||
fetch(`https://api.consumet.stream/vidcdn/watch/${animeEpisode.episodeId}`)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((animelist) => console.log(animelist));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// fetch(`https://gogoanime.consumet.stream/search?keyw=${"jojo"}`)
|
|
||||||
// .then((response) => response.json())
|
|
||||||
// .then((animelist) => console.log(animelist));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function getAnime(name, subcommand, episode = null) {
|
async function getAnime(name, subcommand, episode = null) {
|
||||||
|
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
@@ -187,17 +166,12 @@ export default async function animeMain(command) {
|
|||||||
const episodeOpt = command.find((o) => (o.indexOf('episode=') != -1));
|
const episodeOpt = command.find((o) => (o.indexOf('episode=') != -1));
|
||||||
|
|
||||||
if (command.length == 0 || nameOpt.length == 0) {
|
if (command.length == 0 || nameOpt.length == 0) {
|
||||||
console.log(chalk.red("Please specify an anime title!"));
|
console.log(chalk.red("Please specify an anime title like so: " + chalk.bold("--anime name=name_here")));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(episodeOpt);
|
|
||||||
|
|
||||||
const name = nameOpt.split('=')[1];
|
const name = nameOpt.split('=')[1];
|
||||||
const subCommand = (subCommandOpt && subCommandOpt.length != 0) ? subCommandOpt.split('=')[1] : null;
|
const subCommand = (subCommandOpt && subCommandOpt.length != 0) ? subCommandOpt.split('=')[1] : null;
|
||||||
const episode = (episodeOpt && episodeOpt.length != 0) ? Number(episodeOpt.split('=')[1]) : null;
|
const episode = (episodeOpt && episodeOpt.length != 0) ? Number(episodeOpt.split('=')[1]) : null;
|
||||||
getAnime(name, subCommand, episode);
|
getAnime(name, subCommand, episode);
|
||||||
return true;
|
|
||||||
// m3u8stream('http://somesite.com/link/to/the/playlist.m3u8')
|
|
||||||
// .pipe(fs.createWriteStream('videofile.mp4'));
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -10,7 +10,7 @@ export default function generateQuery(context) {
|
|||||||
query += chalk.yellow("episodes-all");
|
query += chalk.yellow("episodes-all");
|
||||||
query += ", therwise, enter the " + chalk.yellow("episode number\n");
|
query += ", therwise, enter the " + chalk.yellow("episode number\n");
|
||||||
query += chalk.italic("Note: to compile with an episode number use");
|
query += chalk.italic("Note: to compile with an episode number use");
|
||||||
query += chalk.blueBright(" --anime name=\"name\" episode=#\n");
|
query += chalk.blueBright(" --anime name=name episode=#\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
|||||||
Reference in New Issue
Block a user