Merge pull request #5716 from iptv-org/minor-fixes

Minor fixes
This commit is contained in:
Aleksandr Statciuk 2021-12-15 00:42:38 +03:00 committed by GitHub
commit 896b2b1a90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 4235 additions and 62 deletions

View File

@ -5,6 +5,7 @@
"require-header": true,
"attribute-quotes": true,
"require-info": true,
"require-title": true,
"no-trailing-spaces": false,
"no-whitespace-before-title": true,
"no-multi-spaces": true,

4220
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
"iptv-playlist-parser": "^0.10.2",
"jest": "^27.4.3",
"lodash": "^4.17.21",
"m3u-linter": "^0.2.2",
"m3u-linter": "^0.3.0",
"markdown-include": "^0.4.3",
"mz": "^2.7.0",
"nedb-promises": "^5.0.2",

View File

@ -86,11 +86,20 @@ async function updateStreams() {
if (result) {
const { error, streams, requests } = result
const status = parseStatus(error, item.status)
const resolution = parseResolution(streams)
const origin = findOrigin(requests)
let status = parseStatus(error)
if (status) {
const prevStatus = item.status
if (prevStatus.code === 'not_247') // not_247 -> * = not_247
status = item.status
else if (prevStatus.code === 'geo_blocked') // geo_blocked -> * = geo_blocked
status = item.status
else if(prevStatus.code === 'offline' && status.code === 'online') // offline -> online = not_247
status = statuses['not_247']
stream.set('status', { status })
stream.set('is_broken', { status: stream.get('status') })
}
@ -200,24 +209,9 @@ function parseResolution(streams) {
return null
}
// Mapping Scheme:
// ===============
// not_247 -> * = not_247
// geo_blocked -> * = geo_blocked
// offline -> online = not_247
// * -> online = online
// * -> timeout = timeout
// * -> geo_blocked = geo_blocked
// * -> offline = offline
function parseStatus(error, prevStatus) {
if (['not_247', 'geo_blocked'].includes(prevStatus.code)) return null
if(!error && prevStatus.code === 'offline') return statuses['not_247']
if(!error) return statuses['online']
function parseStatus(error) {
if (error) {
if (['not_247', 'geo_blocked'].includes(prevStatus.code)) {
return prevStatus
} else if (error.includes('timed out')) {
if (error.includes('timed out')) {
return statuses['timeout']
} else if (error.includes('403')) {
return statuses['geo_blocked']
@ -225,7 +219,7 @@ function parseStatus(error, prevStatus) {
return statuses['offline']
}
return null
return statuses['online']
}
function findLogo(id) {

View File

@ -41,7 +41,7 @@ async function generateCategoryTable() {
const table = markdown.createTable(rows, [
{ name: 'Category', align: 'left' },
{ name: 'Channels', align: 'right' },
{ name: 'Playlist', align: 'left' }
{ name: 'Playlist', align: 'left', nowrap: true }
])
await file.create('./.readme/_categories.md', table)
@ -65,7 +65,7 @@ async function generateCountryTable() {
const table = markdown.createTable(rows, [
{ name: 'Country', align: 'left' },
{ name: 'Channels', align: 'right' },
{ name: 'Playlist', align: 'left' }
{ name: 'Playlist', align: 'left', nowrap: true }
])
await file.create('./.readme/_countries.md', table)
@ -86,7 +86,7 @@ async function generateRegionTable() {
const table = markdown.createTable(rows, [
{ name: 'Region', align: 'left' },
{ name: 'Channels', align: 'right' },
{ name: 'Playlist', align: 'left' }
{ name: 'Playlist', align: 'left', nowrap: true }
])
await file.create('./.readme/_regions.md', table)
@ -107,7 +107,7 @@ async function generateLanguageTable() {
const table = markdown.createTable(rows, [
{ name: 'Language', align: 'left' },
{ name: 'Channels', align: 'right' },
{ name: 'Playlist', align: 'left' }
{ name: 'Playlist', align: 'left', nowrap: true }
])
await file.create('./.readme/_languages.md', table)

View File

@ -34,9 +34,9 @@ Or select one of the playlists from the list below.
<tr><th align="left">Category</th><th align="right">Channels</th><th align="left">Playlist</th></tr>
</thead>
<tbody>
<tr><td align="left">General</td><td align="right">1</td><td align="left"><code>https://iptv-org.github.io/iptv/categories/general.m3u</code></td></tr>
<tr><td align="left">News</td><td align="right">1</td><td align="left"><code>https://iptv-org.github.io/iptv/categories/news.m3u</code></td></tr>
<tr><td align="left">Other</td><td align="right">0</td><td align="left"><code>https://iptv-org.github.io/iptv/categories/other.m3u</code></td></tr>
<tr><td align="left">General</td><td align="right">1</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/categories/general.m3u</code></td></tr>
<tr><td align="left">News</td><td align="right">1</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/categories/news.m3u</code></td></tr>
<tr><td align="left">Other</td><td align="right">0</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/categories/other.m3u</code></td></tr>
</tbody>
</table>
@ -54,10 +54,10 @@ Or select one of the playlists from the list below.
<tr><th align="left">Language</th><th align="right">Channels</th><th align="left">Playlist</th></tr>
</thead>
<tbody>
<tr><td align="left">Catalan</td><td align="right">0</td><td align="left"><code>https://iptv-org.github.io/iptv/languages/cat.m3u</code></td></tr>
<tr><td align="left">English</td><td align="right">1</td><td align="left"><code>https://iptv-org.github.io/iptv/languages/eng.m3u</code></td></tr>
<tr><td align="left">Russian</td><td align="right">1</td><td align="left"><code>https://iptv-org.github.io/iptv/languages/rus.m3u</code></td></tr>
<tr><td align="left">Undefined</td><td align="right">0</td><td align="left"><code>https://iptv-org.github.io/iptv/languages/undefined.m3u</code></td></tr>
<tr><td align="left">Catalan</td><td align="right">0</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/languages/cat.m3u</code></td></tr>
<tr><td align="left">English</td><td align="right">1</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/languages/eng.m3u</code></td></tr>
<tr><td align="left">Russian</td><td align="right">1</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/languages/rus.m3u</code></td></tr>
<tr><td align="left">Undefined</td><td align="right">0</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/languages/undefined.m3u</code></td></tr>
</tbody>
</table>
@ -75,11 +75,11 @@ Or select one of the playlists from the list below.
<tr><th align="left">Region</th><th align="right">Channels</th><th align="left">Playlist</th></tr>
</thead>
<tbody>
<tr><td align="left">Asia</td><td align="right">1</td><td align="left"><code>https://iptv-org.github.io/iptv/regions/asia.m3u</code></td></tr>
<tr><td align="left">Commonwealth of Independent States</td><td align="right">1</td><td align="left"><code>https://iptv-org.github.io/iptv/regions/cis.m3u</code></td></tr>
<tr><td align="left">Europe</td><td align="right">2</td><td align="left"><code>https://iptv-org.github.io/iptv/regions/eur.m3u</code></td></tr>
<tr><td align="left">Europe, the Middle East and Africa</td><td align="right">2</td><td align="left"><code>https://iptv-org.github.io/iptv/regions/emea.m3u</code></td></tr>
<tr><td align="left">Undefined</td><td align="right">0</td><td align="left"><code>https://iptv-org.github.io/iptv/regions/undefined.m3u</code></td></tr>
<tr><td align="left">Asia</td><td align="right">1</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/regions/asia.m3u</code></td></tr>
<tr><td align="left">Commonwealth of Independent States</td><td align="right">1</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/regions/cis.m3u</code></td></tr>
<tr><td align="left">Europe</td><td align="right">2</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/regions/eur.m3u</code></td></tr>
<tr><td align="left">Europe, the Middle East and Africa</td><td align="right">2</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/regions/emea.m3u</code></td></tr>
<tr><td align="left">Undefined</td><td align="right">0</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/regions/undefined.m3u</code></td></tr>
</tbody>
</table>
@ -97,11 +97,11 @@ Or select one of the playlists from the list below.
<tr><th align="left">Country</th><th align="right">Channels</th><th align="left">Playlist</th></tr>
</thead>
<tbody>
<tr><td align="left">🇦🇩 Andorra</td><td align="right">0</td><td align="left"><code>https://iptv-org.github.io/iptv/countries/ad.m3u</code></td></tr>
<tr><td align="left">🇷🇺 Russia</td><td align="right">1</td><td align="left"><code>https://iptv-org.github.io/iptv/countries/ru.m3u</code></td></tr>
<tr><td align="left">🇬🇧 United Kingdom</td><td align="right">1</td><td align="left"><code>https://iptv-org.github.io/iptv/countries/uk.m3u</code></td></tr>
<tr><td align="left">🌍 International</td><td align="right">0</td><td align="left"><code>https://iptv-org.github.io/iptv/countries/int.m3u</code></td></tr>
<tr><td align="left">Undefined</td><td align="right">0</td><td align="left"><code>https://iptv-org.github.io/iptv/countries/undefined.m3u</code></td></tr>
<tr><td align="left">🇦🇩 Andorra</td><td align="right">0</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/countries/ad.m3u</code></td></tr>
<tr><td align="left">🇷🇺 Russia</td><td align="right">1</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/countries/ru.m3u</code></td></tr>
<tr><td align="left">🇬🇧 United Kingdom</td><td align="right">1</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/countries/uk.m3u</code></td></tr>
<tr><td align="left">🌍 International</td><td align="right">0</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/countries/int.m3u</code></td></tr>
<tr><td align="left">Undefined</td><td align="right">0</td><td align="left" nowrap><code>https://iptv-org.github.io/iptv/countries/undefined.m3u</code></td></tr>
</tbody>
</table>