haxwitcher commited on
Commit
e2bf2bf
·
verified ·
1 Parent(s): 398f0a9

Update addon.js

Browse files
Files changed (1) hide show
  1. addon.js +8 -10
addon.js CHANGED
@@ -2,6 +2,7 @@
2
  const { addonBuilder } = require('stremio-addon-sdk');
3
  const ytdl = require('ytdl-core');
4
 
 
5
  const CSV_URL = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vTe-SkouXuRu5EX8ApUjUe2mCbjHrd3OR4HJ46OH3ai2wLHwkWR5_1dIp3BDjQpq4wHgsi1_pDEeuSi/pub?output=csv';
6
 
7
  function extractId(url) {
@@ -19,11 +20,10 @@ async function fetchList() {
19
  const [ts, url, ...rest] = line.split(',');
20
  const title = rest.join(',');
21
  const id = extractId(url);
22
- if (!id) return null;
23
- return {
24
  id,
25
  name: title || id,
26
- poster: `https://img.youtube.com/vi/${id}/hqdefault.jpg`,
27
  };
28
  })
29
  .filter(Boolean);
@@ -32,7 +32,7 @@ async function fetchList() {
32
  const manifest = require('./manifest.json');
33
  const builder = new addonBuilder(manifest);
34
 
35
- // === Catalog for channel type ===
36
  builder.defineCatalogHandler(async ({ id }) => {
37
  if (id !== 'yt-sheet') {
38
  return { channels: [] };
@@ -42,14 +42,13 @@ builder.defineCatalogHandler(async ({ id }) => {
42
  id: video.id,
43
  type: 'channel',
44
  name: video.name,
45
- poster: video.poster, // Stremio v1 uses `icon` for channels; `poster` also works
46
  icon: video.poster,
47
- logo: video.poster
48
  }));
49
  return { channels };
50
  });
51
 
52
- // === Stream handler for channel type ===
53
  builder.defineStreamHandler(async ({ type, id }) => {
54
  if (type !== 'channel') {
55
  return { streams: [] };
@@ -70,7 +69,7 @@ builder.defineStreamHandler(async ({ type, id }) => {
70
  quality: 'highest'
71
  });
72
  if (!format || !format.url) {
73
- throw new Error('No suitable format found');
74
  }
75
  return {
76
  streams: [{
@@ -79,8 +78,7 @@ builder.defineStreamHandler(async ({ type, id }) => {
79
  isLive: false
80
  }]
81
  };
82
- }
83
- catch (err) {
84
  console.error('Stream error for', id, err.message);
85
  return { streams: [] };
86
  }
 
2
  const { addonBuilder } = require('stremio-addon-sdk');
3
  const ytdl = require('ytdl-core');
4
 
5
+ // Tvoj CSV URL
6
  const CSV_URL = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vTe-SkouXuRu5EX8ApUjUe2mCbjHrd3OR4HJ46OH3ai2wLHwkWR5_1dIp3BDjQpq4wHgsi1_pDEeuSi/pub?output=csv';
7
 
8
  function extractId(url) {
 
20
  const [ts, url, ...rest] = line.split(',');
21
  const title = rest.join(',');
22
  const id = extractId(url);
23
+ return id && {
 
24
  id,
25
  name: title || id,
26
+ poster: `https://img.youtube.com/vi/${id}/hqdefault.jpg`
27
  };
28
  })
29
  .filter(Boolean);
 
32
  const manifest = require('./manifest.json');
33
  const builder = new addonBuilder(manifest);
34
 
35
+ // --- Catalog handler (channels) ---
36
  builder.defineCatalogHandler(async ({ id }) => {
37
  if (id !== 'yt-sheet') {
38
  return { channels: [] };
 
42
  id: video.id,
43
  type: 'channel',
44
  name: video.name,
 
45
  icon: video.poster,
46
+ poster: video.poster, // opcionalno, za veći prikaz
47
  }));
48
  return { channels };
49
  });
50
 
51
+ // --- Stream handler ---
52
  builder.defineStreamHandler(async ({ type, id }) => {
53
  if (type !== 'channel') {
54
  return { streams: [] };
 
69
  quality: 'highest'
70
  });
71
  if (!format || !format.url) {
72
+ throw new Error('No valid format');
73
  }
74
  return {
75
  streams: [{
 
78
  isLive: false
79
  }]
80
  };
81
+ } catch (err) {
 
82
  console.error('Stream error for', id, err.message);
83
  return { streams: [] };
84
  }