Skip to content

Commit

Permalink
chore: cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed Jul 9, 2021
1 parent 939b6aa commit c95d6d6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ▶️ dex

[![Actions Status: test](https://github.com/holodata/dex/workflows/test/badge.svg)](https://github.com/holodata/dex/actions?query=test)
[![npm](https://badgen.net/npm/v/@holodata/dex)](https://npmjs.org/package/@holodata/dex)

Node.js library & CLI for [Holodex](https://holodex.net).

Expand Down
1 change: 1 addition & 0 deletions sake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: dex
40 changes: 20 additions & 20 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function live(argv: any) {
const filters = argv.filter
? argv.filter.map((exp: string) => compileExpression(exp))
: undefined;
const org = ORGS[argv.scope] || "All Vtubers";
const org = ORGS[argv.scope] || ORGS["all"];

const client = holodex(process.env.API_KEY);

Expand All @@ -25,12 +25,12 @@ async function live(argv: any) {
}

if (jsonOutput) {
console.log(JSON.stringify(videos, null, 2));
} else {
for (const video of videos) {
console.log(video.title);
console.log(`https://www.youtube.com/watch?v=${video.id}`);
}
return console.log(JSON.stringify(videos, null, 2));
}

for (const video of videos) {
console.log(video.title);
console.log(`https://www.youtube.com/watch?v=${video.id}`);
}
}

Expand All @@ -43,15 +43,15 @@ async function channel(argv: any) {
const channel = await client.channels[id]();

if (jsonOutput) {
console.log(JSON.stringify(channel, null, 2));
} else {
console.log(channel.name, channel.english_name);
console.log(channel.description);
console.log(channel.org, channel.suborg);
console.log(channel.view_count, channel.video_count);
console.log(channel.twitter);
console.log(`https://www.youtube.com/watch?v=${channel.id}`);
return console.log(JSON.stringify(channel, null, 2));
}

console.log(channel.name, channel.english_name);
console.log(channel.description);
console.log(channel.org, channel.suborg);
console.log(channel.view_count, channel.video_count);
console.log(channel.twitter);
console.log(`https://www.youtube.com/watch?v=${channel.id}`);
}

async function search(argv: any) {
Expand All @@ -67,11 +67,11 @@ async function search(argv: any) {

if (jsonOutput) {
console.log(JSON.stringify(result, null, 2));
} else {
for (const video of result) {
console.log(video.title);
console.log(`https://www.youtube.com/watch?v=${video.id}`);
}
}

for (const video of result) {
console.log(video.title);
console.log(`https://www.youtube.com/watch?v=${video.id}`);
}
}

Expand Down
6 changes: 6 additions & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ it("can fetch index", async () => {
const index = await dex.live();
expect(index).toBeInstanceOf(Array);
});

it("can search videos", async () => {
const dex = holodex();
const result = await dex.search.videoSearch({ org: ["Hololive"] });
expect(result).toBeInstanceOf(Array);
});

0 comments on commit c95d6d6

Please sign in to comment.