From 56df550b3802eee0e842373b13430ae23b0aeeb6 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 1 Feb 2022 19:02:14 +0300 Subject: [PATCH] Init --- app.js | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 74 +++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 app.js create mode 100644 index.html diff --git a/app.js b/app.js new file mode 100644 index 000000000..9c67ceb5c --- /dev/null +++ b/app.js @@ -0,0 +1,168 @@ +const ChannelItem = { + props: ['channel'], + template: ` + + + + + +

+ + + + + +

+ + + ` +} + +const CountryItem = { + components: { + ChannelItem + }, + props: ['item', 'normQuery', 'regQuery'], + data() { + return { + count: 0 + } + }, + computed: { + countryChannels() { + if (!this.normQuery) return this.item.channels + + return ( + this.item.channels.filter(c => { + const normResult = c.key.includes(this.normQuery) + const regResult = this.regQuery + ? this.regQuery.test(c.name) || this.regQuery.test(c.id) + : false + + return normResult || regResult + }) || [] + ) + } + }, + watch: { + countryChannels: function (value) { + this.count = value.length + } + }, + template: ` +
+
+ {{item.flag}} {{item.name}} + +
+
+
+ + + + + + + + + + + + +
NameTVG-IDEPG
+
+
+
+ ` +} + +const App = { + components: { + CountryItem + }, + data() { + return { + isLoading: true, + query: '', + normQuery: '', + regQuery: null, + items: [] + } + }, + methods: { + search() { + this.normQuery = this.query.replace(/\s/g, '').toLowerCase() + this.regQuery = new RegExp(this.query) + } + }, + async mounted() { + // NOTE: epg/guides.json temporary anavailable + // const guides = await fetch('https://iptv-org.github.io/epg/guides.json') + // .then(response => response.json()) + // .catch(console.log) + const guides = [] + + const channels = await fetch('https://iptv-org.github.io/api/channels.json') + .then(response => response.json()) + .then(arr => + arr.map(c => { + const found = guides.filter(g => g.channel === c.id) + c.key = `${c.id}_${c.name}`.replace(/\s/g, '').toLowerCase() + c.guides = found.map(f => f.url) || [] + return c + }) + ) + .then(arr => _.groupBy(arr, 'country')) + .catch(console.log) + + const countries = await fetch('https://iptv-org.github.io/api/countries.json') + .then(response => response.json()) + .catch(console.log) + + this.items = countries.map(i => { + i.expanded = false + i.channels = channels[i.code] || [] + return i + }) + + this.isLoading = false + } +} + +Vue.createApp(App).mount('#app') diff --git a/index.html b/index.html new file mode 100644 index 000000000..faf642a16 --- /dev/null +++ b/index.html @@ -0,0 +1,74 @@ + + + + + + iptv-org/epg + + + + + +
+ +
+
+
+
+
+
+
+ +
+
+ +
+
+
+ +
+
Loading...
+
+ + +
+
+
+
+
+ + + +