Skip to content

Commit

Permalink
EPG frissítés + config fájlban beállítható a napi vagy heti műsorújsá…
Browse files Browse the repository at this point in the history
…g típusa
  • Loading branch information
szabbenjamin committed Jan 22, 2021
1 parent fa88423 commit b37ae91
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
4 changes: 3 additions & 1 deletion config.sample.ts
Expand Up @@ -27,7 +27,9 @@ const CONFIG = {
// minden inditaskor generaljunk EPG-t?
forceUpdate: false,
// EPG idohatar oraban
timeout: 72
timeout: 72,
// heti vagy aznapi lista letoltese: "mai"|"heti"
type: 'heti'
},
/**
* SSL biztonsagos kapcsolat hasznalata. Csak akkor kapcsold ki ha feltetlenul szukeges!
Expand Down
13 changes: 12 additions & 1 deletion helpers/epg_channel_urls.json
Expand Up @@ -54,5 +54,16 @@
"id297": "https://musor.tv/heti/tvmusor/TV2",
"id306": "https://musor.tv/heti/tvmusor/TV2_COMEDY",
"id291": "https://musor.tv/heti/tvmusor/SUPERTV2",
"id258": "https://musor.tv/heti/tvmusor/FILMNOW"
"id258": "https://musor.tv/heti/tvmusor/FILMNOW",

"id313": "https://musor.tv/heti/tvmusor/AXN",
"id314": "https://musor.tv/heti/tvmusor/CBSREALITY",
"id312": "https://musor.tv/heti/tvmusor/FILMCAFE",
"id315": "https://musor.tv/heti/tvmusor/FILM4",
"id316": "https://musor.tv/heti/tvmusor/NICKJR",
"id310": "https://musor.tv/heti/tvmusor/PARAMOUNT",
"id317": "https://musor.tv/heti/tvmusor/SONY_MAX",
"id319": "https://musor.tv/heti/tvmusor/TEENNICK",
"id309": "https://musor.tv/heti/tvmusor/TV2_SEF",
"id318": "https://musor.tv/heti/tvmusor/VIASAT3"
}
36 changes: 32 additions & 4 deletions lib/epg.ts
Expand Up @@ -42,6 +42,30 @@ class Epg {
this.channelTemplate = '<channel id="id:id"><display-name lang="hu">:channelName</display-name></channel>\n';
this.programmeTemplate = '<programme start=":start :startOffset" stop=":end :endOffset" channel="id:id"><title lang="hu">:programme</title></programme>\n';
this.xmlContainer = '<?xml version="1.0" encoding="utf-8" ?><tv>:content</tv>';

Log.write(`EPG lista típusa: ${this.getEpgType()}`);
}

/**
* Hack arra, hogy ne csak a heti hanem napi EPG listát is le lehessen tölteni
* @param epgUrl
*/
private modifyEpgType(epgUrl : string) : string {
if (this.getEpgType() === 'mai') {
return epgUrl.replace('heti', 'mai');
}
return epgUrl;
}

private getEpgType() : string {
//@ts-ignore
if (typeof CONFIG.epg.type !== 'undefined') {
//@ts-ignore
if (CONFIG.epg.type === 'mai') {
return 'mai';
}
}
return 'heti';
}

public setChannels (channelList : Array<ChannelInterface>) : void {
Expand Down Expand Up @@ -133,7 +157,7 @@ class Epg {
}
});
}

/**
* Műsorok letöltése
* @param epgUrl
Expand All @@ -145,10 +169,12 @@ class Epg {
'Content-Type' : 'application/x-www-form-urlencoded'
};

let shows = [];
let shows = [],
// a későbbi felülírás esetére
channelEpgUrl = this.modifyEpgType(epgUrl);

request.get(
epgUrl,
channelEpgUrl,
{
headers: headers
},
Expand Down Expand Up @@ -266,7 +292,9 @@ class Epg {
}
});
}
}, 4 * 1000);
}, (this.getEpgType() === 'mai' ? 1 : 4) * 1000);



/**
* XML újragyártása beállított időközönként
Expand Down

0 comments on commit b37ae91

Please sign in to comment.