-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaddon.js
More file actions
81 lines (72 loc) · 2.51 KB
/
addon.js
File metadata and controls
81 lines (72 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const { addonBuilder, serveHTTP } = require('stremio-addon-sdk');
const axios = require('axios');
const ONE_PACE_JSON_URL = 'https://onepace.net/_next/data/WgqGRQw6mCdLCxZ1iFx5J/en/watch.json';
const manifest = {
id: 'one.pace',
name: 'One Pace Addon',
version: '1.0.0',
description: 'Watch One Pace | The Definitive One Piece Viewing Experience',
resources: ['catalog', 'meta', 'stream'],
types: ['serie', 'anime'],
catalogs: [{
type: 'anime',
id: 'one.pace',
name: 'One Pace',
extra: [{ name: 'search' }],
}],
behaviorHints: { configurable: false, configurationRequired: false },
logo: "https://dl.strem.io/addon-logo.png",
icon: "https://dl.strem.io/addon-logo.png",
background: "https://dl.strem.io/addon-background.jpg",
}
const builder = new addonBuilder(manifest)
builder.defineCatalogHandler(async ({ type, id }) => {
if (type === 'anime' && id === 'one.pace') {
const response = await axios.get(ONE_PACE_JSON_URL)
const arcs = response.data.pageProps.arcs
const metas = arcs.map(arc => ({
id: arc.id,
type: 'anime',
name: arc.invariant_title,
poster: arc.images[0]?.src, // Assuming an image is available
}))
return { metas }
}
return { metas: [] }
})
builder.defineMetaHandler(async ({ type, id }) => {
if (type === 'anime') {
const response = await axios.get(ONE_PACE_JSON_URL)
const arcs = response.data.pageProps.arcs
const arc = arcs.find(a => a.id === id)
if (arc) {
const meta = {
id: arc.id,
type: 'anime',
name: arc.invariant_title,
poster: arc.images[0]?.src,
description: arc.anime_episodes, // Example description
// Additional metadata
}
return { meta }
}
}
return { meta: null }
})
builder.defineStreamHandler(async ({ type, id }) => {
if (type === 'anime') {
const response = await axios.get(ONE_PACE_JSON_URL)
const arcs = response.data.pageProps.arcs
const arc = arcs.find(a => a.id === id)
if (arc) {
const streams = arc.downloads.map(download => ({
title: download.type,
infoHash: download.uri.split('hash=')[1],
}))
return { streams }
}
}
return { streams: [] }
})
const addonInterface = builder.getInterface()
serveHTTP(addonInterface, { port: 3000 })