Update app.js

This commit is contained in:
Aleksandr Statciuk 2022-02-03 22:13:03 +03:00
parent 5919c388fe
commit d314b31071

17
app.js
View file

@ -17,6 +17,9 @@ const ChannelItem = {
<td class="is-vcentered" nowrap> <td class="is-vcentered" nowrap>
<code v-text="channel.id"></code> <code v-text="channel.id"></code>
</td> </td>
<td class="is-vcentered">
<p v-for="guide in channel.guides"><code style="white-space: nowrap" v-text="guide.url"></code></p>
</td>
</tr> </tr>
` `
} }
@ -96,6 +99,7 @@ const CountryItem = {
<th></th> <th></th>
<th>Name</th> <th>Name</th>
<th>TVG-ID</th> <th>TVG-ID</th>
<th>EPG</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -128,19 +132,18 @@ const App = {
} }
}, },
async mounted() { async mounted() {
// NOTE: epg/guides.json temporary anavailable let guides = await fetch('https://iptv-org.github.io/api/guides.json')
// const guides = await fetch('https://iptv-org.github.io/epg/guides.json') .then(response => response.json())
// .then(response => response.json()) .catch(console.log)
// .catch(console.log) guides = guides.length ? guides : []
const guides = [] guides = _.groupBy(guides, 'channel')
const channels = await fetch('https://iptv-org.github.io/api/channels.json') const channels = await fetch('https://iptv-org.github.io/api/channels.json')
.then(response => response.json()) .then(response => response.json())
.then(arr => .then(arr =>
arr.map(c => { arr.map(c => {
const found = guides.filter(g => g.channel === c.id)
c.key = `${c.id}_${c.name}`.replace(/\s/g, '').toLowerCase() c.key = `${c.id}_${c.name}`.replace(/\s/g, '').toLowerCase()
c.guides = found.map(f => f.url) || [] c.guides = guides[c.id] || []
return c return c
}) })
) )