fix codeql suggestions
This commit is contained in:
parent
62fe4fca8e
commit
03a7dcda52
4 changed files with 73 additions and 24 deletions
|
|
@ -22,7 +22,9 @@ def recv_packet(s):
|
||||||
op, length = struct.unpack('<II', header)
|
op, length = struct.unpack('<II', header)
|
||||||
payload = s.recv(length)
|
payload = s.recv(length)
|
||||||
return json.loads(payload.decode('utf-8'))
|
return json.loads(payload.decode('utf-8'))
|
||||||
except: return None
|
except Exception:
|
||||||
|
# Ignore errors and return None
|
||||||
|
return None
|
||||||
|
|
||||||
def set_activity(ds, pid, details, state, img=None, start=None, end=None, large_text=None, small_img=None, small_txt=None):
|
def set_activity(ds, pid, details, state, img=None, start=None, end=None, large_text=None, small_img=None, small_txt=None):
|
||||||
global LAST_STATUS
|
global LAST_STATUS
|
||||||
|
|
@ -61,7 +63,9 @@ def main():
|
||||||
line = sys.stdin.readline()
|
line = sys.stdin.readline()
|
||||||
if not line: return
|
if not line: return
|
||||||
config = json.loads(line)
|
config = json.loads(line)
|
||||||
except: return
|
except Exception:
|
||||||
|
# Ignore errors and exit
|
||||||
|
return
|
||||||
|
|
||||||
ppid = os.getppid()
|
ppid = os.getppid()
|
||||||
|
|
||||||
|
|
@ -71,7 +75,9 @@ def main():
|
||||||
try:
|
try:
|
||||||
ds = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
ds = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
ds.connect(ipc_path)
|
ds.connect(ipc_path)
|
||||||
except: return
|
except Exception:
|
||||||
|
# Ignore connection errors and exit
|
||||||
|
return
|
||||||
|
|
||||||
# 3. Handshake
|
# 3. Handshake
|
||||||
send_packet(ds, 0, {"v": 1, "client_id": CLIENT_ID})
|
send_packet(ds, 0, {"v": 1, "client_id": CLIENT_ID})
|
||||||
|
|
@ -85,7 +91,9 @@ def main():
|
||||||
ws.settimeout(1.0)
|
ws.settimeout(1.0)
|
||||||
try:
|
try:
|
||||||
ws.connect(('127.0.0.1', int(config['nlPort'])))
|
ws.connect(('127.0.0.1', int(config['nlPort'])))
|
||||||
except: return
|
except Exception:
|
||||||
|
# Ignore connection errors and exit
|
||||||
|
return
|
||||||
|
|
||||||
key = base64.b64encode(os.urandom(16)).decode()
|
key = base64.b64encode(os.urandom(16)).decode()
|
||||||
handshake = (
|
handshake = (
|
||||||
|
|
@ -133,8 +141,12 @@ def main():
|
||||||
set_activity(ds, ppid, "Idling", "Monochrome")
|
set_activity(ds, ppid, "Idling", "Monochrome")
|
||||||
elif msg['event'] == 'windowClose':
|
elif msg['event'] == 'windowClose':
|
||||||
break
|
break
|
||||||
except socket.timeout: continue
|
except socket.timeout:
|
||||||
except: continue
|
# Timeout is expected, continue polling
|
||||||
|
continue
|
||||||
|
except Exception:
|
||||||
|
# Ignore other errors and continue
|
||||||
|
continue
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
try:
|
try:
|
||||||
|
|
@ -145,7 +157,9 @@ def main():
|
||||||
})
|
})
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
ds.close()
|
ds.close()
|
||||||
except: pass
|
except Exception:
|
||||||
|
# Ignore cleanup errors
|
||||||
|
pass
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
|
|
@ -438,7 +438,7 @@ export class LosslessAPI {
|
||||||
if (!album) throw new Error('Album not found');
|
if (!album) throw new Error('Album not found');
|
||||||
|
|
||||||
// If album exists but has no artist, try to extract from tracks
|
// If album exists but has no artist, try to extract from tracks
|
||||||
if (album && !album.artist && tracksSection?.items && tracksSection.items.length > 0) {
|
if (!album.artist && tracksSection?.items && tracksSection.items.length > 0) {
|
||||||
const firstTrack = tracksSection.items[0];
|
const firstTrack = tracksSection.items[0];
|
||||||
const track = firstTrack.item || firstTrack;
|
const track = firstTrack.item || firstTrack;
|
||||||
if (track && track.artist) {
|
if (track && track.artist) {
|
||||||
|
|
@ -447,7 +447,7 @@ export class LosslessAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If album exists but has no releaseDate, try to extract from tracks
|
// If album exists but has no releaseDate, try to extract from tracks
|
||||||
if (album && !album.releaseDate && tracksSection?.items && tracksSection.items.length > 0) {
|
if (!album.releaseDate && tracksSection?.items && tracksSection.items.length > 0) {
|
||||||
const firstTrack = tracksSection.items[0];
|
const firstTrack = tracksSection.items[0];
|
||||||
const track = firstTrack.item || firstTrack;
|
const track = firstTrack.item || firstTrack;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import { sanitizeForFilename } from './utils.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to get track artists string
|
* Helper function to get track artists string
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export const apiSettings = {
|
||||||
if (isSimpleArray) {
|
if (isSimpleArray) {
|
||||||
groupedInstances.api = [...data.api];
|
groupedInstances.api = [...data.api];
|
||||||
} else {
|
} else {
|
||||||
for (const [, config] of Object.entries(data.api)) {
|
for (const [_key, config] of Object.entries(data.api)) {
|
||||||
if (config.cors === false && Array.isArray(config.urls)) {
|
if (config.cors === false && Array.isArray(config.urls)) {
|
||||||
groupedInstances.api.push(...config.urls);
|
groupedInstances.api.push(...config.urls);
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +233,7 @@ export const themeManager = {
|
||||||
purple: {},
|
purple: {},
|
||||||
forest: {},
|
forest: {},
|
||||||
mocha: {},
|
mocha: {},
|
||||||
machiatto: {},
|
macchiato: {},
|
||||||
frappe: {},
|
frappe: {},
|
||||||
latte: {},
|
latte: {},
|
||||||
},
|
},
|
||||||
|
|
@ -947,7 +947,7 @@ export const equalizerSettings = {
|
||||||
const stored = localStorage.getItem(this.FREQ_MIN_KEY);
|
const stored = localStorage.getItem(this.FREQ_MIN_KEY);
|
||||||
if (stored) {
|
if (stored) {
|
||||||
const val = parseInt(stored, 10);
|
const val = parseInt(stored, 10);
|
||||||
if (!isNaN(val) && val >= this.ABSOLUTE_FREQ_MIN && val < this.DEFAULT_FREQ_MAX) {
|
if (!isNaN(val) && val >= this.ABSOLUTE_FREQ_MIN && val < this.ABSOLUTE_FREQ_MAX) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -959,7 +959,20 @@ export const equalizerSettings = {
|
||||||
|
|
||||||
setFreqMin(value) {
|
setFreqMin(value) {
|
||||||
const val = parseInt(value, 10);
|
const val = parseInt(value, 10);
|
||||||
if (!isNaN(val) && val >= this.ABSOLUTE_FREQ_MIN && val < this.getFreqMax()) {
|
// Get effective max from storage without recursive call
|
||||||
|
let effectiveMax = this.DEFAULT_FREQ_MAX;
|
||||||
|
try {
|
||||||
|
const storedMax = localStorage.getItem(this.FREQ_MAX_KEY);
|
||||||
|
if (storedMax) {
|
||||||
|
const parsedMax = parseInt(storedMax, 10);
|
||||||
|
if (!isNaN(parsedMax) && parsedMax > this.ABSOLUTE_FREQ_MIN && parsedMax <= this.ABSOLUTE_FREQ_MAX) {
|
||||||
|
effectiveMax = parsedMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* ignore and use default max */
|
||||||
|
}
|
||||||
|
if (!isNaN(val) && val >= this.ABSOLUTE_FREQ_MIN && val < effectiveMax) {
|
||||||
localStorage.setItem(this.FREQ_MIN_KEY, val.toString());
|
localStorage.setItem(this.FREQ_MIN_KEY, val.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -968,11 +981,23 @@ export const equalizerSettings = {
|
||||||
|
|
||||||
getFreqMax() {
|
getFreqMax() {
|
||||||
try {
|
try {
|
||||||
const stored = localStorage.getItem(this.FREQ_MAX_KEY);
|
const storedMax = localStorage.getItem(this.FREQ_MAX_KEY);
|
||||||
if (stored) {
|
if (storedMax) {
|
||||||
const val = parseInt(stored, 10);
|
const maxVal = parseInt(storedMax, 10);
|
||||||
if (!isNaN(val) && val > this.getFreqMin() && val <= this.ABSOLUTE_FREQ_MAX) {
|
if (!isNaN(maxVal) && maxVal > this.ABSOLUTE_FREQ_MIN && maxVal <= this.ABSOLUTE_FREQ_MAX) {
|
||||||
return val;
|
// Get stored min without recursive call
|
||||||
|
try {
|
||||||
|
const storedMin = localStorage.getItem(this.FREQ_MIN_KEY);
|
||||||
|
if (storedMin) {
|
||||||
|
const minVal = parseInt(storedMin, 10);
|
||||||
|
if (!isNaN(minVal) && maxVal <= minVal) {
|
||||||
|
return this.DEFAULT_FREQ_MAX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
return maxVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -982,9 +1007,21 @@ export const equalizerSettings = {
|
||||||
},
|
},
|
||||||
|
|
||||||
setFreqMax(value) {
|
setFreqMax(value) {
|
||||||
const val = parseInt(value, 10);
|
const maxVal = parseInt(value, 10);
|
||||||
if (!isNaN(val) && val > this.getFreqMin() && val <= this.ABSOLUTE_FREQ_MAX) {
|
if (!isNaN(maxVal) && maxVal > this.ABSOLUTE_FREQ_MIN && maxVal <= this.ABSOLUTE_FREQ_MAX) {
|
||||||
localStorage.setItem(this.FREQ_MAX_KEY, val.toString());
|
// Check against stored min without recursive call
|
||||||
|
try {
|
||||||
|
const storedMin = localStorage.getItem(this.FREQ_MIN_KEY);
|
||||||
|
if (storedMin) {
|
||||||
|
const minVal = parseInt(storedMin, 10);
|
||||||
|
if (!isNaN(minVal) && maxVal <= minVal) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
localStorage.setItem(this.FREQ_MAX_KEY, maxVal.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1181,7 +1218,7 @@ export const equalizerSettings = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(gains) && gains.length === 16) {
|
if (Array.isArray(gains) && gains.length === this.DEFAULT_BAND_COUNT) {
|
||||||
presets[presetId].gains = gains.map((g) => Math.round(g * 10) / 10);
|
presets[presetId].gains = gains.map((g) => Math.round(g * 10) / 10);
|
||||||
presets[presetId].updatedAt = Date.now();
|
presets[presetId].updatedAt = Date.now();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue