Skip to content

Commit 587129c

Browse files
committed
Initial commit
0 parents  commit 587129c

File tree

8 files changed

+805
-0
lines changed

8 files changed

+805
-0
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Create plugin.zip
17+
run: zip -r plugin.zip src package.json README.md
18+
19+
- name: Create Release
20+
uses: softprops/action-gh-release@v2
21+
with:
22+
files: plugin.zip
23+
generate_release_notes: true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
build

LICENSE

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# YouTube Streaming Plugin for Nuclear
2+
3+
A streaming provider plugin that plays audio from Youtube using yt-dlp.
4+
5+
## Requirements
6+
7+
[yt-dlp](https://github.com/yt-dlp/yt-dlp) must be installed and available in your PATH.
8+
9+
## Installation
10+
11+
Install from the Nuclear plugin browser.

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "nuclear-plugin-youtube",
3+
"version": "0.1.0",
4+
"description": "YouTube streaming provider for Nuclear music player",
5+
"author": "nukeop",
6+
"license": "AGPL-3.0-only",
7+
"main": "src/index.ts",
8+
"type": "module",
9+
"nuclear": {
10+
"displayName": "YouTube",
11+
"category": "streaming",
12+
"icon": {
13+
"type": "link",
14+
"link": "https://www.youtube.com/s/desktop/26a583e4/img/favicon_144x144.png"
15+
},
16+
"permissions": []
17+
},
18+
"keywords": [
19+
"nuclear",
20+
"plugin",
21+
"youtube",
22+
"streaming"
23+
],
24+
"files": [
25+
"src",
26+
"README.md"
27+
],
28+
"dependencies": {
29+
"@nuclearplayer/plugin-sdk": "^0.0.14"
30+
},
31+
"packageManager": "pnpm@10.16.1"
32+
}

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import type {
2+
NuclearPlugin,
3+
NuclearPluginAPI,
4+
StreamingProvider,
5+
} from '@nuclearplayer/plugin-sdk';
6+
7+
const PROVIDER_ID = 'youtube';
8+
9+
const createProvider = (api: NuclearPluginAPI): StreamingProvider => ({
10+
id: PROVIDER_ID,
11+
kind: 'streaming',
12+
name: 'YouTube',
13+
14+
searchForTrack: async (artist, title) => {
15+
const query = `${artist} ${title}`;
16+
const results = await api.Ytdlp.search(query);
17+
18+
return results.map((result) => ({
19+
id: result.id,
20+
title: result.title,
21+
durationMs: result.duration ? result.duration * 1000 : undefined,
22+
thumbnail: result.thumbnail ?? undefined,
23+
failed: false,
24+
source: { provider: PROVIDER_ID, id: result.id },
25+
}));
26+
},
27+
28+
getStreamUrl: async (candidateId) => {
29+
const info = await api.Ytdlp.getStream(candidateId);
30+
31+
return {
32+
url: info.stream_url,
33+
protocol: 'https',
34+
durationMs: info.duration ? info.duration * 1000 : undefined,
35+
source: { provider: PROVIDER_ID, id: candidateId },
36+
};
37+
},
38+
});
39+
40+
const plugin: NuclearPlugin = {
41+
onEnable(api: NuclearPluginAPI) {
42+
api.Providers.register(createProvider(api));
43+
},
44+
45+
onDisable(api: NuclearPluginAPI) {
46+
api.Providers.unregister(PROVIDER_ID);
47+
},
48+
};
49+
50+
export default plugin;

tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"strict": true,
7+
"esModuleInterop": true,
8+
"skipLibCheck": true,
9+
"noEmit": true
10+
},
11+
"include": ["src"]
12+
}

0 commit comments

Comments
 (0)