Skip to content

Commit

Permalink
v17.0.9
Browse files Browse the repository at this point in the history
- Options to edit channels/categories on "Live" section had disappeared in the last versions but now they are back
- Minor improvements and bugfixes
  • Loading branch information
EdenwareApps committed Jul 31, 2023
1 parent 10db2b2 commit 0571b10
Show file tree
Hide file tree
Showing 25 changed files with 119 additions and 67 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="367" id="tv.megacubo.app" version="17.0.8" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget android-versionCode="370" id="tv.megacubo.app" version="17.0.9" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Megacubo</name>
<description>
An intuitive, free and open source IPTV player.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tv.megacubo.app",
"displayName": "Megacubo",
"version": "17.0.8",
"version": "17.0.9",
"description": "A intuitive and multi-language IPTV player.",
"main": "index.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion www/nodejs-project/assets/js/app/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ function loadJS(url, cb, retries=3){
setTimeout(function (){
loadJS(url, cb, retries)
}, 1)

} else {
console.warn('ERROR', url);
setTimeout(cb, 1)
Expand Down
2 changes: 1 addition & 1 deletion www/nodejs-project/assets/js/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ function updateSplashProgress(increase) {
function fakeUpdateProgress() {
let timer = setInterval(function () {
fakeTasksCount--;
if (!fakeTasksCount) {
if (fakeTasksCount <= 0) {
clearInterval(timer);
}
updateSplashProgress();
Expand Down
6 changes: 3 additions & 3 deletions www/nodejs-project/modules/channels/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ class Channels extends ChannelsKids {
moreOptions.push(this.shareChannelEntry(e))
moreOptions.push(streamsEntry)
}
if(global.config.get('channel-grid') == '' && global.config.get('allow-edit-channel-list') && (e.path || global.explorer.path).indexOf(global.lang.SEARCH) == -1){ // avoid it on search results to prevent bugs
if(!global.config.get('channel-grid') && global.config.get('allow-edit-channel-list') && (e.path || global.explorer.path).indexOf(global.lang.SEARCH) == -1){ // avoid it on search results to prevent bugs
const editEntry = this.editChannelEntry(e, category, {name: category ? global.lang.EDIT_CHANNEL : global.lang.EDIT, details: undefined, class: 'no-icon', fa: 'fas fa-edit', users: undefined, usersPercentage: undefined, path: undefined, url: undefined})
moreOptions.push(editEntry)
}
Expand Down Expand Up @@ -1400,7 +1400,7 @@ class Channels extends ChannelsKids {
}
let list
const type = global.config.get('channel-grid')
const editable = type == '' && global.config.get('allow-edit-channel-list')
const editable = !type && global.config.get('allow-edit-channel-list')
if(type == 'lists') {
list = await this.groupsRenderer('live')
} else {
Expand Down Expand Up @@ -1562,7 +1562,7 @@ class Channels extends ChannelsKids {
options(){
return new Promise((resolve, reject) => {
let entries = []
if(global.config.get('channel-grid') == '' && global.config.get('allow-edit-channel-list')){
if(!global.config.get('channel-grid') && global.config.get('allow-edit-channel-list')){
entries.push(this.editCategoriesEntry())
}
entries.push(...[
Expand Down
4 changes: 2 additions & 2 deletions www/nodejs-project/modules/cloud/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CloudConfiguration {
'searching': 6 * 3600,
'channels': 6 * 3600,
'configure': 3600,
'promo': 300,
'promos': 300,
'country-sources': 6 * 3600,
'watching-country': 300
}
Expand All @@ -29,7 +29,7 @@ class CloudConfiguration {
throw 'Bad config server URL'
}
url(key){
if(['configure', 'promo', 'themes'].includes(key)){
if(['configure', 'promos', 'themes'].includes(key)){
return this.server + '/' + key + '.json'
} else if(key.indexOf('/') != -1 || key.indexOf('.') != -1) {
return this.server + '/stats/data/' + key + '.json'
Expand Down
2 changes: 1 addition & 1 deletion www/nodejs-project/modules/download/download-p2p-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class P2PPeer extends P2PEncDec {
let left = this.sockets.length
const done = () => {
left--
if (left == 0) {
if (left <= 0) {
this.writing = false
this.drain()
}
Expand Down
2 changes: 1 addition & 1 deletion www/nodejs-project/modules/explorer/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class Explorer extends Events {
if(typeof(level) != 'number'){
level = 1
}
while(p && level){
while(p && level >= 0){
p = this.dirname(p)
level--
}
Expand Down
2 changes: 1 addition & 1 deletion www/nodejs-project/modules/lists/epg-worker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const ListsCommon = require('../lists/common'), xmltv = require('xmltv')
const Events = require('events'), utils = require('../multi-worker/utils')
const Events = require('events'), utils = require('../multi-worker/utils')(__filename)

class EPGPaginateChannelsList extends Events {
constructor(){
Expand Down
4 changes: 2 additions & 2 deletions www/nodejs-project/modules/lists/list-index-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ListIndexUtils extends Events {
reject('list destroyed')
} else {
if(!line || line.charAt(0) != '{'){
console.error('Bad line readen', line, this.file, i)
console.error('Bad line readen', this.file, i)
}
if(!map || map.includes(i)){
lines[i] = line
Expand Down Expand Up @@ -158,7 +158,7 @@ class ListIndexUtils extends Events {
index = parsed // old style compat
}
} catch(e) {
console.error('Index parsing failure', line, e, this.file)
console.error('Index parsing failure', e, this.file)
}
}
if(index && typeof(index.length) != 'undefined'){
Expand Down
2 changes: 1 addition & 1 deletion www/nodejs-project/modules/lists/list-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ListIndex extends ListIndexUtils {
entries = global.parseJSON('['+ Object.values(lines).join(',') +']') // remove undefineds too
} catch(e) {}
if(!Array.isArray(entries)){
console.error('Failed to get lines', lines, map, entries, this.file)
console.error('Failed to get lines', this.file)
throw 'failed to get lines'
}
if(entries.length) {
Expand Down
35 changes: 25 additions & 10 deletions www/nodejs-project/modules/lists/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ class ListsLoader extends Events {
this.resetLowPriorityUpdates()
}
async resetLowPriorityUpdates(){ // load community lists
const maxListsToTry = 192
const minListsToTry = Math.max(64, 3 * this.communityListsAmount)
if(minListsToTry < this.master.processedLists.size) return

const taskId = Math.random()
this.currentTaskId = taskId
this.master.updaterFinished(false)
this.processes = this.processes.filter(p => {
/* Cancel pending processes to reorder it */
if(p.priority > 1 && !p.started() && !p.done()) {
Expand All @@ -69,6 +62,16 @@ class ListsLoader extends Events {
return true
})

if(!this.communityListsAmount) return

const maxListsToTry = 192
const minListsToTry = Math.max(64, 3 * this.communityListsAmount)
if(minListsToTry < this.master.processedLists.size) return

const taskId = Math.random()
this.currentTaskId = taskId
this.master.updaterFinished(false)

const lists = await global.discovery.get(maxListsToTry)
const communityLists = []
lists.some(({ url }) => {
Expand All @@ -94,7 +97,9 @@ class ListsLoader extends Events {
this.once('destroy', () => updater.terminate())
this.updaterClients = 1
updater.close = () => {
this.updaterClients--
if(this.updaterClients > 0){
this.updaterClients--
}
if(!this.updaterClients && !this.updater.terminating){
this.updater.terminating = setTimeout(() => {
console.error('Terminating updater worker')
Expand Down Expand Up @@ -187,10 +192,20 @@ class ListsLoader extends Events {
}
async reload(url){
let updateErr
const progressId = 'reloading-'+ parseInt(Math.random() * 1000000)
const progressListener = p => {
if(p.progressId == progressId) {
global.osd.show(global.lang.RECEIVING_LIST +' '+ p.progress +'%', 'fas fa-circle-notch fa-spin', 'progress-'+ progressId, 'persistent')
}
}
progressListener({progressId, progress: 0})
await this.prepareUpdater()
this.results[url] = 'reloading'
this.results[url] = await this.updater.updateList(url, true).catch(err => updateErr = err)
this.updater.on('progress', progressListener)
this.results[url] = 'reloading'
this.results[url] = await this.updater.updateList(url, true, progressId).catch(err => updateErr = err)
this.updater && this.updater.close()
this.updater.removeListener('progress', progressListener)
global.osd.hide('progress-'+ progressId)
if(updateErr) throw updateErr
await this.master.loadList(url).catch(err => updateErr = err)
if(updateErr) throw updateErr
Expand Down
33 changes: 27 additions & 6 deletions www/nodejs-project/modules/lists/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ class Manager extends ManagerEPG {
throw err
} else {
global.osd.show(global.lang.LIST_ADDED, 'fas fa-check-circle', 'add-list', 'normal')
const protect = !fromCommunity && value.match(new RegExp('(pwd?|pass|password)=', 'i')) // protect sensible lists
const protect = !fromCommunity && (value.match(new RegExp('(pwd?|pass|password)=', 'i')) || value.match(new RegExp('/[0-9]{5,}/[0-9]{5,}'))) // protect sensible lists
const currentEPG = global.config.get('epg-'+ global.lang.locale)
const community = global.config.get('communitary-mode-lists-amount') > 0
const chosen = (!protect && community && global.validateURL(value)) ? await global.explorer.dialog([
Expand All @@ -810,7 +810,7 @@ class Manager extends ManagerEPG {
this.setMeta(value, 'private', chosen != 'yes')
let info, i = 20
if(currentEPG != 'disabled'){
while(i && (!info || !info[value])){
while(i > 0 && (!info || !info[value])){
i--
await this.wait(500)
info = await this.master.info()
Expand Down Expand Up @@ -1285,7 +1285,19 @@ class Manager extends ManagerEPG {
type: 'group',
class: 'skip-testing',
renderer: async () => {
let es = []
let es = []
let contactUrl, contactFa
const meta = this.master.lists[url] ? this.master.lists[url].index.meta : {}
if(meta.site) {
contactUrl = meta.site
contactFa = 'fas fa-globe'
} else if(meta.email) {
contactUrl = 'mailto:'+ meta.email
contactFa = 'fas fa-envelope'
} else if(meta.phone) {
contactUrl = 'tel:+'+ meta.phone.replace(new RegExp('[^0-9]+'), '')
contactFa = 'fas fa-phone'
}
const options = [
{
name: global.lang.RENAME,
Expand Down Expand Up @@ -1329,7 +1341,17 @@ class Manager extends ManagerEPG {
class: 'skip-testing',
action: this.removeList.bind(this)
}
]
]
if(contactUrl) {
options.splice(2, 0, {
name: global.lang.CONTACT_PROVIDER,
type: 'action',
fa: contactFa,
action: () => {
global.ui.emit('open-external-url', contactUrl)
}
})
}
if(manageOnly) return options
es = await this.directListRenderer({url}, {
raw: true,
Expand All @@ -1343,7 +1365,7 @@ class Manager extends ManagerEPG {
}
es.unshift({
name: global.lang.OPTIONS,
fa: 'fas fa-edit',
fa: 'fas fa-bars',
type: 'select',
entries: options
})
Expand Down Expand Up @@ -1375,7 +1397,6 @@ class Manager extends ManagerEPG {
}
async refreshList(data){
let updateErr
global.osd.show(global.lang.UPDATING_LISTS, 'fa-mega spin-x-alt', 'refresh-list', 'persistent')
await this.master.loader.reload(data.url).catch(e => updateErr = e)
if(updateErr){
if(updateErr == 'empty list'){
Expand Down
5 changes: 3 additions & 2 deletions www/nodejs-project/modules/lists/update-list-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class UpdateListIndex extends ListIndexUtils {
console.error('ADDLISThttp='+path)
let resolved
const opts = {
debug: false,
url: path,
p2p: !!this.forceDownload,
retries: 3,
Expand Down Expand Up @@ -231,7 +232,7 @@ class UpdateListIndex extends ListIndexUtils {
this.indexateIterator++
})
this.parser.on('progress', readen => {
const cl = this.contentLength || 40 * (1024 * 1024) // estimate it if we don't know
const cl = this.contentLength > 0 ? this.contentLength : 62 * (1024 * 1024) // estimate it if we don't know
const pp = cl / 100
let progress = parseInt(readen / pp)
if(progress > 99) progress = 99
Expand All @@ -251,7 +252,7 @@ class UpdateListIndex extends ListIndexUtils {
}
}

if(progress > this.lastProgress) {
if(progress != this.lastProgress) {
this.lastProgress = progress
this.emit('progress', progress)
}
Expand Down
4 changes: 3 additions & 1 deletion www/nodejs-project/modules/lists/updater-worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

const Common = require('./common'), List = require('./list')
const UpdateListIndex = require('./update-list-index'), utils = require('../multi-worker/utils')
const UpdateListIndex = require('./update-list-index')
const utils = require('../multi-worker/utils')(__filename)

class ListsUpdater extends Common {
constructor(){
Expand Down Expand Up @@ -44,6 +45,7 @@ class ListsUpdater extends Common {
if(this.debug){
console.log('updater updateList', url)
}
progressId && utils.emit('progress', {progressId, progress: 0})
const should = force === true || (await this.updaterShouldUpdate(url))
const now = global.time()
if(this.debug){
Expand Down
Loading

0 comments on commit 0571b10

Please sign in to comment.