Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export * from './twitch/twitch';
export * from './twitch/clip-fetcher';
export * from './twitch/clip-url-fetcher';
export * from './twitch/clips-downloader';
export * from './twitch/clip-downloader';

export * from './twitch/video-downloader';
export * from './twitch/video-fragments-fetcher';
Expand Down
6 changes: 4 additions & 2 deletions src/twitch/clip-downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ClipDownloader extends EventEmitter {
}
}

async download(): Promise<void> {
async download(): Promise<Clip> {
await this.resolveClip();

const clip = this.clipOrUrl as Clip;
Expand All @@ -38,7 +38,7 @@ export class ClipDownloader extends EventEmitter {
if (existsSync(appPath(mp4Path))) {
logger.verbose(`Clip ${clip.title} found at ${appPath(mp4Path)}`);

return;
return clip;
}

const promises: Promise<any>[] = [];
Expand All @@ -59,5 +59,7 @@ export class ClipDownloader extends EventEmitter {
}

await Promise.all(promises);

return clip;
}
}
17 changes: 17 additions & 0 deletions tests/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {twitchClipUrlToId} from '../src';

const urls = [
[
'https://clips.twitch.tv/SassyKawaiiMallardTTours-7vNzQmvsJDGoicMB',
'SassyKawaiiMallardTTours-7vNzQmvsJDGoicMB',
], [
'https://clips.twitch.tv/EnthusiasticAnnoyingCockroachNotLikeThis-HJPYZFxKOH5mF2oP',
'EnthusiasticAnnoyingCockroachNotLikeThis-HJPYZFxKOH5mF2oP'
]
];

test.each(urls)('clip id is extracted from url', async (url, expectedId) => {
const id = twitchClipUrlToId(url);

expect(id).toStrictEqual(expectedId);
});