Skip to content

Commit ebcf9e4

Browse files
committed
chore(YouTube): Add URL tests
This currently vendors the YouTube.js npm package with LuanRT/YouTube.js#983 applied, because the deno.land version has some dependency resolution issues when running `deno test` (and is deprecated anyways), and the npm version cannot be used on deno without workarounds due to LuanRT/YouTube.js#991. I will ammend/rebase this commit once LuanRT/YouTube.js#983 gets merged and there is a new release so we won't have the complete YouTube.js sources in the git history.
1 parent 5e3a7c8 commit ebcf9e4

File tree

1,983 files changed

+174133
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,983 files changed

+174133
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ snaps/
1010

1111
# Temporary files
1212
local/
13+
14+
node_modules

.ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
youtubei.js

deno.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://raw.githubusercontent.com/denoland/deno/refs/heads/main/cli/schemas/config-file.v1.json",
23
"compilerOptions": {
34
"jsx": "react-jsx",
45
"jsxImportSource": "preact"
@@ -30,8 +31,10 @@
3031
"tabler-icons/": "https://deno.land/x/[email protected]/tsx/",
3132
"ts-custom-error": "https://esm.sh/[email protected]",
3233
"utils/": "https://deno.land/x/[email protected]/",
33-
"youtubei.js": "https://deno.land/x/youtubei@v14.0.0-deno/deno.ts"
34+
"youtubei.js": "npm:youtubei.js@^14.0.0"
3435
},
36+
"links": ["./youtubei.js"],
37+
"nodeModulesDir": "auto",
3538
"lock": false,
3639
"tasks": {
3740
"check": "deno check server/fresh.gen.ts cli.ts",
@@ -46,5 +49,5 @@
4649
"tags": ["fresh", "recommended"]
4750
}
4851
},
49-
"exclude": ["**/_fresh/*"]
52+
"exclude": ["**/_fresh/*", "youtubei.js"]
5053
}

providers/YouTubeMusic/mod.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { describeProvider, makeProviderOptions } from '@/providers/test_spec.ts';
2+
import { stubProviderLookups } from '@/providers/test_stubs.ts';
3+
import { afterAll, describe } from '@std/testing/bdd';
4+
5+
import YouTubeMusicProvider from './mod.ts';
6+
7+
describe('YouTube Music provider', () => {
8+
const youtubeMusic = new YouTubeMusicProvider(makeProviderOptions());
9+
const stub = stubProviderLookups(youtubeMusic);
10+
11+
describeProvider(youtubeMusic, {
12+
urls: [
13+
{
14+
description: 'channel page',
15+
url: new URL('https://music.youtube.com/channel/UCxgN32UVVztKAQd2HkXzBtw'),
16+
id: { type: 'channel', id: 'UCxgN32UVVztKAQd2HkXzBtw' },
17+
isCanonical: true,
18+
},
19+
{
20+
description: 'playlist page',
21+
url: new URL('https://music.youtube.com/playlist?list=OLAK5uy_ncbxWnjKunOOgJ7N1XELrneNgiaMMPXxA'),
22+
id: { type: 'playlist', id: 'OLAK5uy_ncbxWnjKunOOgJ7N1XELrneNgiaMMPXxA' },
23+
isCanonical: true,
24+
serializedId: 'OLAK5uy_ncbxWnjKunOOgJ7N1XELrneNgiaMMPXxA',
25+
},
26+
{
27+
description: 'playlist page with additional query parameters',
28+
url: new URL(
29+
'https://music.youtube.com/playlist?list=OLAK5uy_ncbxWnjKunOOgJ7N1XELrneNgiaMMPXxA&feature=shared',
30+
),
31+
id: { type: 'playlist', id: 'OLAK5uy_ncbxWnjKunOOgJ7N1XELrneNgiaMMPXxA' },
32+
serializedId: 'OLAK5uy_ncbxWnjKunOOgJ7N1XELrneNgiaMMPXxA',
33+
},
34+
{
35+
description: 'album (browse) page',
36+
url: new URL('https://music.youtube.com/browse/MPREb_q16Gzaa1WK8'),
37+
id: { type: 'browse', id: 'MPREb_q16Gzaa1WK8' },
38+
isCanonical: true,
39+
serializedId: 'MPREb_q16Gzaa1WK8',
40+
},
41+
{
42+
description: 'track page',
43+
url: new URL('https://music.youtube.com/watch?v=-C_rvt0SwLE'),
44+
id: { type: 'watch', id: '-C_rvt0SwLE' },
45+
isCanonical: true,
46+
},
47+
],
48+
releaseLookup: [],
49+
});
50+
51+
afterAll(() => {
52+
stub.restore();
53+
});
54+
});

youtubei.js/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 LuanRT
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

youtubei.js/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!-- BADGE LINKS -->
2+
[npm]: https://www.npmjs.com/package/youtubei.js
3+
[versions]: https://www.npmjs.com/package/youtubei.js?activeTab=versions
4+
[codefactor]: https://www.codefactor.io/repository/github/luanrt/youtube.js
5+
[actions]: https://github.com/LuanRT/YouTube.js/actions
6+
[discord]: https://discord.gg/syDu7Yks54
7+
8+
<div align="center">
9+
<br/>
10+
<p>
11+
<a href="https://github.com/LuanRT/YouTube.js">
12+
<img src="https://luanrt.github.io/assets/img/ytjs.svg" alt="YouTube.js Logo" width="200" />
13+
</a>
14+
</p>
15+
<p>A JavaScript client for YouTube's private API</p>
16+
17+
[![Discord](https://img.shields.io/badge/discord-online-brightgreen.svg)][discord]
18+
[![CI](https://github.com/LuanRT/YouTube.js/actions/workflows/test.yml/badge.svg)][actions]
19+
[![NPM Version](https://img.shields.io/npm/v/youtubei.js?color=%2335C757)][versions]
20+
[![Downloads](https://img.shields.io/npm/dt/youtubei.js)][npm]
21+
[![Codefactor](https://www.codefactor.io/repository/github/luanrt/youtube.js/badge)][codefactor]
22+
23+
</div>
24+
25+
YouTube.js is a JavaScript client for YouTube's private API, known as "InnerTube". It allows you to interact with YouTube programmatically, providing access to videos, comments, live chats, streaming data and more. It works seamlessly across Node.js, Deno, and modern browsers.
26+
27+
## Installation
28+
29+
Before installing, make sure your environment meets the [prerequisites](https://ytjs.dev/guide/getting-started.html#prerequisites).
30+
31+
```bash
32+
# NPM
33+
npm install youtubei.js@latest
34+
35+
# Yarn
36+
yarn add youtubei.js@latest
37+
38+
# Git (edge version)
39+
npm install github:LuanRT/YouTube.js
40+
41+
# Deno
42+
deno add npm:youtubei.js@latest
43+
```
44+
45+
Deno (deprecated):
46+
```ts
47+
import { Innertube } from 'https://deno.land/x/youtubei/deno.ts';
48+
```
49+
50+
## Basic Usage
51+
52+
```ts
53+
// const { Innertube } = require('youtubei.js');
54+
import { Innertube } from 'youtubei.js';
55+
const innertube = await Innertube.create(/* options */);
56+
```
57+
58+
For detailed usage, check out the [YouTube.js Guide and API Documentation](https://ytjs.dev).
59+
60+
## Contributing
61+
We welcome all contributions, issues and feature requests, whether small or large. If you want to contribute, feel free to check out our [issues page](https://github.com/LuanRT/YouTube.js/issues) and our [guidelines](https://github.com/LuanRT/YouTube.js/blob/main/CONTRIBUTING.md).
62+
63+
## Contributors
64+
<a href="https://github.com/LuanRT/YouTube.js/graphs/contributors">
65+
<img src="https://contrib.rocks/image?repo=LuanRT/YouTube.js" />
66+
</a>
67+
68+
## Disclaimer
69+
This project is not affiliated with, endorsed, or sponsored by YouTube or any of its affiliates or subsidiaries. All trademarks, logos, and brand names used in this project are the property of their respective owners and are used solely to describe the services provided.
70+
71+
As such, any usage of trademarks to refer to such services is considered nominative use. If you have any questions or concerns, please contact me.
72+
73+
## License
74+
Distributed under the [MIT](https://choosealicense.com/licenses/mit/) License.
75+
76+
<p align="right">
77+
(<a href="#top">back to top</a>)
78+
</p>

youtubei.js/bundle/browser.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../dist/src/platform/lib.js';

0 commit comments

Comments
 (0)