Skip to content

Commit

Permalink
update docs and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alpacamybags118 committed Oct 24, 2021
1 parent 8308fe3 commit 96506d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A small wrapper around [yt-dlp](https://github.com/yt-dlp/yt-dlp), which allows you to invoke it as a child process in your node project. Inspired by [youtube-dl-exec](https://github.com/microlinkhq/youtube-dl-exec). Made for personal use/learning, but anyone is welcome to use/extend it.

## Features
* Downloads appropriate `yt-dlp` for OS
* Downloads appropriate `yt-dlp` for OS (see [`download-yt-dlp.js`](./hooks/download-yt-dlp.js))
* Allows you to pass any supported `yt-dlp` arguments

## Requirements
Expand All @@ -12,7 +12,7 @@ A small wrapper around [yt-dlp](https://github.com/yt-dlp/yt-dlp), which allows

## Install
```
npm install yt-dlp-exec
npm install @alpacamybags118/yt-dlp-exec
```

## Usage
Expand All @@ -36,15 +36,15 @@ result.on('exit', (exit) => {
import createYtDlpAsProcess from '@alpacamybags118/yt-dlp-exec'

const process = createYtDlpAsProcess(
'https://some.url',
{
o: '-',
q: '',
f: 'bestaudio',
preferFreeFormats: true,
r: '100K',
}
);
'https://some.url',
{
o: '-',
q: '',
f: 'bestaudio',
preferFreeFormats: true,
r: '100K',
}
);
```

Argument list fo commands uses [`dargs`](https://github.com/sindresorhus/dargs) formatting. Returned child process is in [`execa`](https://github.com/sindresorhus/execa) format
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alpacamybags118/yt-dlp-exec",
"version": "0.0.3",
"version": "0.0.4",
"description": "Wrapper around yp-dlp to execute it as a process in your project.",
"main": "src/index.js",
"scripts": {
Expand Down
16 changes: 8 additions & 8 deletions test/createYtDlpAsProcess.test.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const yt = require('../src/index');
const ChildProcess = require('child_process').ChildProcess
let execa = require('execa');
const ChildProcess = require('child_process').ChildProcess;

describe('createYtDlpAsProcess', () => {

test('should throw error if URL is missing', () => {
expect(() => yt.createYtDlpAsProcess()).toThrow('Media URL has not been provided!');
});

test('should return an object on completion', async () => {
const result = await yt.createYtDlpAsProcess('test', {h:true});

expect(result).toBeInstanceOf(Object);

expect(async () => await yt.createYtDlpAsProcess('test', {h:true})).toBeInstanceOf(Object);
});

test('should return a child process when invoked', async () => {
const result = yt.createYtDlpAsProcess('test', {h:true});

expect(result).toBeInstanceOf(ChildProcess);
const process = yt.createYtDlpAsProcess('test', {h:true});

await result;
expect(process).toBeInstanceOf(ChildProcess);
expect(async () => await process).toBeTruthy();
});
})

0 comments on commit 96506d1

Please sign in to comment.