Skip to content

Commit

Permalink
v17.0.5b
Browse files Browse the repository at this point in the history
Minor improvements and bugfixes
  • Loading branch information
EdenwareApps committed Jul 14, 2023
1 parent 9c398b8 commit e063912
Show file tree
Hide file tree
Showing 48 changed files with 668 additions and 709 deletions.
21 changes: 10 additions & 11 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,22 @@
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="AndroidXEnabled" value="true" />
<resource-file src="resources/android/notification.png" target="/app/src/main/res/mipmap-ldpi/icon.png" />
<resource-file src="resources/android/notification.png" target="/app/src/main/res/mipmap-mdpi/icon.png" />
<resource-file src="resources/android/notification.png" target="/app/src/main/res/mipmap-hdpi/icon.png" />
<resource-file src="resources/android/notification.png" target="/app/src/main/res/mipmap-xhdpi/icon.png" />
<resource-file src="resources/android/notification.png" target="/app/src/main/res/mipmap-xxhdpi/icon.png" />
<resource-file src="resources/android/banner.png" target="/app/src/main/res/drawable/banner.png" />
<resource-file src="resources/values/colors.xml" target="/app/src/main/res/values/colors.xml" />
<resource-file src="resources/values/themes.xml" target="/app/src/main/res/values/themes.xml" />
<resource-file src="resources/values/colors.xml" target="/app/src/main/res/values/colors.xml" />
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/icon/drawable-xxxhdpi-icon.png" />
<preference name="AndroidWindowSplashScreenBackground" value="#362064" />
<icon src="resources/android/icon/drawable-ldpi-icon.png" />
<icon background="@color/background" density="ldpi" foreground="resources/android/icon/ldpi-foreground.png" qualifier="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon background="@color/background" density="mdpi" foreground="resources/android/icon/mdpi-foreground.png" qualifier="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon background="@color/background" density="hdpi" foreground="resources/android/icon/hdpi-foreground.png" qualifier="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
<icon background="@color/background" density="xhdpi" foreground="resources/android/icon/xhdpi-foreground.png" qualifier="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
<icon background="@color/background" density="xxhdpi" foreground="resources/android/icon/xxhdpi-foreground.png" qualifier="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
<icon background="@color/background" density="xxxhdpi" foreground="resources/android/icon/xxxhdpi-foreground.png" qualifier="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/icon/drawable-xxxhdpi-icon.png" />
<preference name="AndroidWindowSplashScreenBackground" value="#362064" />
<resource-file src="resources/values/colors.xml" target="/app/src/main/res/values/colors.xml" />
<resource-file src="resources/values/themes.xml" target="/app/src/main/res/values/themes.xml" />
<resource-file src="resources/android/notification.png" target="/app/src/main/res/mipmap-ldpi/icon.png" />
<resource-file src="resources/android/notification.png" target="/app/src/main/res/mipmap-mdpi/icon.png" />
<resource-file src="resources/android/notification.png" target="/app/src/main/res/mipmap-hdpi/icon.png" />
<resource-file src="resources/android/notification.png" target="/app/src/main/res/mipmap-xhdpi/icon.png" />
<resource-file src="resources/android/notification.png" target="/app/src/main/res/mipmap-xxhdpi/icon.png" />
<resource-file src="resources/android/banner.png" target="/app/src/main/res/drawable/banner.png" />
</platform>
</widget>
44 changes: 20 additions & 24 deletions www/nodejs-project/assets/js/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function langUpdated(){
function resolveNativePath(uri, callback) {
const originalURI = uri, errorcb = err => callback(err)
uri = decodeURIComponent(uri).replace('/raw%3A', '/raw:')
if (uri.startsWith('file://') === 0) {
if (uri.startsWith('file://')) {
uri = uri.replace('file://', '')
}
if (uri.indexOf('raw:') !== -1) {
Expand Down Expand Up @@ -180,10 +180,12 @@ function initApp(){
explorer.setLoading(e, false)
})
}
parent.winman && parent.winman.backgroundModeLock('open-file')
console.log('MIMETYPES: ' + mimetypes.replace(new RegExp(' *, *', 'g'), '|'))
parent.fileChooser.open(file => { // {"mime": mimetypes.replace(new RegExp(' *, *', 'g'), '|')},
console.log('FILE: '+ file)
osd.show(lang.PROCESSING, 'fa-mega spin-x-alt', 'theme-upload', 'normal')
parent.winman && parent.winman.backgroundModeUnlock('open-file')
explorer.get({name: optionTitle}).forEach(e => {
explorer.setLoading(e, true, lang.PROCESSING)
})
Expand Down Expand Up @@ -240,34 +242,28 @@ function initApp(){
app.on('background-mode-unlock', name => {
if(parent.player && parent.winman) parent.winman && parent.winman.backgroundModeUnlock(name)
})
let initP2PDetails
window.initP2P = () => {
console.warn({initP2PDetails})
if(initP2PDetails) {
const done = () => {
if(typeof(require) == 'function') {
console.warn({initP2PDetails})
loadJSOnIdle('./modules/download/download-p2p-client.js', () => {
console.warn({initP2PDetails})
const {addr, limit, stunServers} = initP2PDetails
window.p2p = new P2PManager(app, addr, limit, stunServers)
})
}
}
if(typeof(require) != 'function' && typeof(parent.parent.require) == 'function') {
window.require = parent.parent.require
}
let initP2PDetails, initP2P = () => {
if(!initP2PDetails || !config || !config['p2p']) return
const done = () => {
if(typeof(require) == 'function') {
done()
} else {
// browserify -r @geut/discovery-swarm-webrtc -r crypto -r safe-buffer -o assets/js/libs/webrtc-bundle.js
loadJSOnIdle('./modules/download/discovery-swarm-webrtc-bundle.js', done)
loadJSOnIdle('./modules/download/download-p2p-client.js', () => {
const {addr, limit, stunServers} = initP2PDetails
window.p2p = new P2PManager(app, addr, limit, stunServers)
})
}
}
if(typeof(require) != 'function' && typeof(parent.parent.require) == 'function') {
window.require = parent.parent.require
}
if(typeof(require) == 'function') {
done()
} else {
// browserify -r @geut/discovery-swarm-webrtc -r crypto -r safe-buffer -o assets/js/libs/webrtc-bundle.js
loadJSOnIdle('./modules/download/discovery-swarm-webrtc-bundle.js', done)
}
}
app.on('init-p2p', (addr, limit, stunServers) => {
initP2PDetails = {addr, limit, stunServers}
console.warn({initP2PDetails})
initP2P()
})
app.emit('download-p2p-init');
Expand Down Expand Up @@ -532,7 +528,7 @@ function initApp(){
hotkeys = new Hotkeys()
hotkeys.start(config.hotkeys)
app.on('config', (keys, c) => {
if(keys.includes('hotkeys')){
if(keys.includes('hotkeys')) {
hotkeys.start(c.hotkeys)
}
})
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 @@ -332,7 +332,7 @@ function fakeUpdateProgress() {
let stack = typeof errorObj == 'object' && errorObj !== null && errorObj.stack ? errorObj.stack : traceback();
if (maxAlerts) {
maxAlerts--;
if (file && file.startsWith('blob:http://') == -1) { // ignore hls.js errors
if (file && file.startsWith('blob:http://')) { // ignore hls.js errors
alert(message + ' ' + file + ':' + line + ' ' + stack);
log(message);
}
Expand Down
2 changes: 1 addition & 1 deletion www/nodejs-project/assets/js/index/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class WinMan extends EventEmitter {
}
}
exit(force){
console.log('exit()', traceback())
console.log('exit('+ force +')', traceback())
let w = this.getAppWindow()
if(w.streamer && w.streamer.active){
w.streamer.stop()
Expand Down
3 changes: 2 additions & 1 deletion www/nodejs-project/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ global.storage = require('./modules/storage')({main: true})

global.onexit(() => {
global.isExiting = true
console.log('APP_EXIT', traceback())
console.error('APP_EXIT='+ traceback())
if(typeof(global.streamer) != 'undefined' && global.streamer.active){
global.streamer.stop()
}
Expand Down Expand Up @@ -597,6 +597,7 @@ const init = (language, timezone) => {
global.energy.exit()
})
global.ui.once('exit', () => {
console.error('Immediate exit called from client.')
process.exit(0)
})
global.ui.on('suspend', () => { // cordova only
Expand Down
5 changes: 3 additions & 2 deletions www/nodejs-project/modules/bridge/bridge.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path'), http = require('http'), Events = require('events'), fs = require('fs'), url = require('url')
const path = require('path'), http = require('http'), Events = require('events')
const fs = require('fs'), url = require('url'), createReader = require('../reader')
const formidable = require('formidable'), closed = require('../on-closed')

class BaseCustomEmitter extends Events {
Expand Down Expand Up @@ -105,7 +106,7 @@ class BridgeServer extends Events {
response.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Cache-Control, Accept, Authorization')
response.setHeader('Cache-Control', 'max-age=0, no-cache, no-store')
response.setHeader('Connection', 'close')
let stream = fs.createReadStream(pathname)
let stream = createReader(pathname)
closed(req, response, () => {
console.log(`${req.method} ${req.url} CLOSED`)
if(stream){
Expand Down
25 changes: 1 addition & 24 deletions www/nodejs-project/modules/bridge/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,13 @@ class BridgeClient extends EventEmitter {
}
}
startNodeMainScript() {
const isDev = true
const argument = [
'--allow-insecure-localhost',
// '--max-old-space-size=4096', // 1/4 of total mem? should not exceed device memory
'--nojitless',
'--allow-natives-syntax'
]
if (isDev) {
argument.push(...[
'--trace-warnings',
'--async-stack-traces',
'--stack-trace-limit=20'
])
}
window.parent.nodejs.start('main.js', err => {
err && log(String(err))
this.channelGetLangCallback()
updateSplashProgress()
console.log('Node main script loaded.')
}, {
maxPayloadInBytes: 50 * 1024 * 1024,
forwardStderr: true,
enableInspector: isDev,
redirectOutputToLogcat: isDev,
argument,
/* maxPayloadInBytes: max message size for channel.post()
forwardStderr: Specifies whether Node.js standard errors should be forwarded to the Cordova application's standard error output. The default value is true.
enableInspector: specifies whether Node.js built-in debugger should be enabled. The default value is false.
redirectOutputToLogcat: Specifies whether Node.js output should be redirected to Android's logcat. The default value is false.
argument: specifies a list of additional arguments to pass to the Node.js process during startup. */
redirectOutputToLogcat: false
})
}
configureCordovaChannel() {
Expand Down
23 changes: 11 additions & 12 deletions www/nodejs-project/modules/channels/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ class ChannelsCategories extends ChannelsData {
let data = {}, weighted = true
const completed = () => this.mapSize(data) >= amount
const countries = await global.lang.getActiveCountries(0)
const limit = pLimit(3)
const tasks = () => countries.map(country => {
const limit = pLimit(2)
const tasks = () => countries.map((country, i) => {
return limit(async () => {
let err
const map = await global.cloud.get('channels/' + country).catch(e => err = e)
if(completed()) throw 'completed'
if (!err) {
data = await this.applyMapCategories(map, data, amount, weighted)
data = await this.applyMapCategories(map, data, amount, i ? weighted : false)
if(completed()) throw 'completed'
}
})
Expand Down Expand Up @@ -1111,13 +1111,12 @@ class Channels extends ChannelsKids {
if(typeof(terms) == 'string'){
terms = global.lists.terms(terms)
}
let epgEntries = [], already = []
let entries = []
let epgEntries = [], entries = [], already = {}
Object.keys(this.channelsIndex).sort().forEach(name => {
if(!already.includes(name)){
if(typeof(already[name]) == 'undefined'){
let score = this.cmatch(this.channelsIndex[name], terms, partial)
if(score){
already.push(name)
already[name] = null
entries.push({
name,
terms: {name: this.channelsIndex[name]}
Expand All @@ -1131,8 +1130,8 @@ class Channels extends ChannelsKids {
epgEntries = ees.map(e => {
let ch = this.isChannel(e.programme.ch)
if(ch){
if(!already.includes(ch.name)){
already.push(ch.name)
if(typeof(already[ch.name]) == 'undefined'){
already[ch.name] = null
if(e.details){
e.details = e.details.replace(e.programme.ch, ch.name)
}
Expand Down Expand Up @@ -1697,12 +1696,12 @@ class Channels extends ChannelsKids {
class: isSeries ? 'entry-cover' : undefined,
details: namedGroups[name].details,
renderer: async () => {
const entries = [], already = []
const entries = [], already = {}
await Promise.allSettled(namedGroups[name].map(g => g.renderer().then(es => {
es.forEach(e => {
if(already.includes(e.url)) return
if(typeof(already[e.url]) != 'undefined') return
entries.push(e)
already.push(e.url)
already[e.url] = null
})
})))
return await global.lists.tools.deepify(entries, { minPageCount: 8 })
Expand Down
2 changes: 1 addition & 1 deletion www/nodejs-project/modules/cloud/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CloudConfiguration {
if(this.debug){
console.log('cloud: fallback', key)
}
const p2p = key != 'configure' && !key.startsWith('channels') && global.config.get('p2p')
const p2p = key != 'configure' && global.config.get('p2p')
const url = this.url(key)
let err, err2, body = await global.Download.get({
url,
Expand Down
7 changes: 3 additions & 4 deletions www/nodejs-project/modules/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
'broadcast-start-timeout': 40,
'channels-list-smart-sorting': 0,
'communitary-mode-lists-amount': 0,
'connect-timeout': 5,
'countries': [],
'custom-background-image': '',
'custom-background-video': '',
Expand Down Expand Up @@ -64,15 +65,13 @@ module.exports = {
'stun:stun2.l.google.com:19302',
'stun:stun3.l.google.com:19302',
'stun:stun4.l.google.com:19302',
'stun:stun.stunprotocol.org',
'stun:stun.voipbuster.com',
'stun:global.stun.twilio.com:3478'
'stun:stun.stunprotocol.org'
],
'parental-control': 'remove',
'parental-control-terms': '.',
'play-while-loading': true,
'playback-rate-control': true,
'connect-timeout': 5,
'preferred-ip-version': -1,
'resume': false,
'stretch-logos': false,
'search-missing-logos': true,
Expand Down
10 changes: 9 additions & 1 deletion www/nodejs-project/modules/diagnostics/diagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ class Diagnostics extends Events {
const myLists = config.lists.map(a => a[1]);
const listsRequesting = global.lists.requesting
const tuning = global.tuning ? global.tuning.logText(false) : ''
const processedLists = global.lists.processedLists.keys();
const processing = global.lists.loader.processes.map(p => {
return {
url: p.url,
started: p.started(),
priority: p.priority
}
});
const updaterResults = global.lists.loader.results;
['lists', 'parental-control-terms', 'parental-control-pw', 'premium-license'].forEach(k => delete config[k])
Object.keys(lists).forEach(url => {
Expand All @@ -32,7 +40,7 @@ class Diagnostics extends Events {
diskSpace.free = global.kbfmt(diskSpace.free)
diskSpace.size = global.kbfmt(diskSpace.size)
}
return {diskSpace, freeMem, config, lists, listsRequesting, updaterResults, tuning}
return {diskSpace, freeMem, config, lists, listsRequesting, updaterResults, processedLists, processing, tuning}
}
async saveReport(){
const file = global.downloads.folder +'/report.txt'
Expand Down
16 changes: 12 additions & 4 deletions www/nodejs-project/modules/discovery/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ class PublicIPTVListsDiscovery extends Events {
this.restore().catch(console.error)
const iptv = new IPTVOrgProvider()
this.register(iptv.discovery.bind(iptv), 24 * 3600)
global.ui.on('download-p2p-discovery-lists', lists => this.add(lists))
global.ui.on('public-iptv-lists-discovery', lists => {
if(Array.isArray(lists)) { // received from a peer
this.add(lists)
} else { // requested by client, update him
global.ui.emit('public-iptv-lists-discovery', this.knownLists)
}
})
}
async restore(){
const data = await global.storage.promises.get(this.key).catch(console.error)
Expand Down Expand Up @@ -109,7 +115,6 @@ class PublicIPTVListsDiscovery extends Events {
if(!list || !list.url) return
const existingListIndex = this.knownLists.findIndex(l => l.url === list.url)
if (existingListIndex === -1) {

this.knownLists.push(Object.assign({
health: -1,
perceivedHealth: 0,
Expand Down Expand Up @@ -148,12 +153,16 @@ class PublicIPTVListsDiscovery extends Events {
health,
name: existingList.name || list.name, // trusting more on own info
image: existingList.image || list.image,
countries: existingList.countries.concat(list.countries.filter(c => !existingList.countries.includes(c))),
countries: this.mergeCountries(existingList, list),
perceivedHealth: existingList.perceivedHealth, // perceived health is personal, should not be merged
perceivedHealthTestCount: existingList.perceivedHealthTestCount,
lastModified: list.lastModified
}
}
mergeCountries(a, b) { // TODO: implement here some capping to avoid countries overflow
const c = a.countries || []
return c.concat((b.countries || []).filter(g => !c.includes(g)))
}
reportHealth(sourceListUrl, success) {
return this.knownLists.some((list, i) => {
if(list.url === sourceListUrl) {
Expand Down Expand Up @@ -263,7 +272,6 @@ class PublicIPTVListsDiscovery extends Events {
return a
})
this.knownLists.sort((a, b) => b.averageHealth - a.averageHealth)
return health
}
cleanupKnownLists() {
if (this.knownLists.length > this.opts.limit) {
Expand Down
Loading

0 comments on commit e063912

Please sign in to comment.