Skip to content

Commit

Permalink
add search
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter21767 committed Nov 19, 2022
1 parent a4baf48 commit 6ea227e
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 23 deletions.
32 changes: 24 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ app.get('/:configuration/manifest.json', (req, res) => {

"id": "stremio_iptv_id:" + id,

"name": name
"name": name,

extra: [{ name: "search", isRequired: false }]
});
};
}
Expand All @@ -64,7 +66,9 @@ app.get('/:configuration/manifest.json', (req, res) => {

"id": "stremio_iptv_id:" + providors[i],

"name": regions[providors[i]].name
"name": regions[providors[i]].name,

extra: [{ name: "search", isRequired: false }]
});
};

Expand All @@ -79,35 +83,47 @@ app.get('/:configuration/manifest.json', (req, res) => {
});


app.get('/:configuration?/:resource/:type/:id.json', (req, res) => {
app.get('/:configuration?/:resource(catalog|meta|stream)/:type/:id/:extra?.json', (req, res) => {

res.setHeader('Cache-Control', 'max-age=86400,staleRevalidate=stale-while-revalidate, staleError=stale-if-error, public');
res.setHeader('Content-Type', 'application/json');



console.log(req.params);
let { configuration, resource, type, id } = req.params;
let { configuration, resource, type, id} = req.params;
let extra = Object.fromEntries(new URLSearchParams(req.params.extra));
let { providors, costume, costumeLists } = iptv.ConfigCache(configuration)

console.log(extra)
console.log("costume", costume)

let region = id.split(":")[1];
let costumeList = costumeLists[region] ? atob(costumeLists[region].url) : '';

if (resource == "catalog") {
if ((type == "tv")) {
console.log('id', id)
console.log("catalog", region);
iptv.catalog(region, costumeLists[region] ? atob(costumeLists[region].url) : '')
if(extra && extra.search){
console.log("search", extra.search);
iptv.search(region, costumeList,extra.search)
.then((metas) => {
res.send(JSON.stringify({ metas }));
res.end();
}).catch(error => console.error(error));
}else{
iptv.catalog(region, costumeList)
.then((metas) => {
res.send(JSON.stringify({ metas }));
res.end();
}).catch(error => console.error(error));
}
}
}
else if (resource == "meta") {
if ((type == "tv")) {
console.log("meta", id);
iptv.meta(id, costumeLists[region] ? atob(costumeLists[region].url) : '')
iptv.meta(id, costumeList)
.then((meta) => {
console.log(meta)
res.send(JSON.stringify({ meta }));
Expand All @@ -119,7 +135,7 @@ app.get('/:configuration?/:resource/:type/:id.json', (req, res) => {
else if (resource == "stream") {
if ((type == "tv")) {
console.log("stream", id);
iptv.stream(id, costumeLists[region] ? atob(costumeLists[region].url) : '')
iptv.stream(id, costumeList)
.then((stream) => {
console.log(stream)
res.send(JSON.stringify({ streams: stream }));
Expand Down
28 changes: 28 additions & 0 deletions iptv.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,31 @@ async function catalog(region, url) {
return metas;
}

async function search(region, url,param) {
try{
console.log("region", region, "url", url)
const metas = [];
var iptv = await get_iptv(region, url).catch(error => console.error(error));
if(!iptv) throw "error getting data";

for (let i = 0; i < iptv.length; i++) {
if(iptv[i].name.toLowerCase().match(param.toLowerCase())){
metas.push({
id: iptv[i].id,
name: iptv[i].name,
type: "tv",
poster: iptv[i].poster,
posterShape: 'landscape'
});
}
}
return metas;
}
catch(e){
console.error(e);
}
}

async function meta(id, url) {
var region = id.split(":")[1];
id = id.split(":")[2];
Expand All @@ -162,12 +187,15 @@ async function stream(id, url) {
};
if (iptv["behaviorHints"]) {
stream["behaviorHints"] = iptv["behaviorHints"];
}else if(region.match("max")){
// stream["behaviorHints"]= {"notWebReady":true,"proxyHeaders":{"request":{'User-Agent':"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"}}};
}
return [stream];
}

module.exports = {
catalog,
search,
meta,
stream,
ConfigCache
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "community.stremio-iptv",
"version": "0.1.0",
"version": "0.1.1",
"name": "Stremio IPTV by dexter21767",
"description": "Addon for International (country specific) TV channels! Huge thanks for iptv.org and u/RootByte!",
"logo": "https://i.imgur.com/982WZT3.png",
Expand Down
10 changes: 9 additions & 1 deletion regions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"beiniptv": {
"maxiptv": {
"name": "MaxTV",
"url": "https://bit.ly/3Oiqpa5",
"id": "maxiptv"
},"maxspiptv": {
"name": "MaxTV Spanish",
"url": "https://bit.ly/3V8lryX",
"id": "maxspiptv"
},"beiniptv": {
"name": "bein sports",
"url": "https://bit.ly/3eUaJfI",
"id": "beiniptv"
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vue/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- <link rel="icon" type="image/svg+xml" href="/vite.svg" /> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- <title>Trakt Lists</title> -->
<script type="module" crossorigin src="/assets/index.2f38b03d.js"></script>
<script type="module" crossorigin src="/assets/index.9606ae9c.js"></script>
<link rel="stylesheet" href="/assets/index.61b9d9b9.css">
</head>
<body>
Expand Down

0 comments on commit 6ea227e

Please sign in to comment.