Initial commit: MusicDownload con UI pywebview
- Frontend HTML/CSS/JS in webui/ (stile Spotify-like, hero gradient, modal blur) - API bridge JS<->Python in api/bridge.py - Core invariato: downloader yt-dlp, upgrader, spotify client, config - Build scripts macOS (WebKit) e Windows (EdgeChromium) - .gitignore esclude credenziali (config.json, cookies.txt) e artefatti build Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
commit
8c06a26ddb
25 files changed
+4316
No files matched your search
@@ -0,0 +1,778 @@
|
||||
/* ===============================
|
||||
MusicDownload — Spotify-like UI
|
||||
=============================== */
|
||||
|
||||
:root {
|
||||
--bg: #0A0A0A;
|
||||
--bg-elev: #121212;
|
||||
--bg-card: #181818;
|
||||
--bg-card-2: #1F1F1F;
|
||||
--bg-input: #2A2A2A;
|
||||
--bg-input-hover: #3A3A3A;
|
||||
|
||||
--border: #232323;
|
||||
--divider: #1F1F1F;
|
||||
|
||||
--green: #1DB954;
|
||||
--green-hover: #1ED760;
|
||||
--green-press: #169B46;
|
||||
--green-dim: #0F3B22;
|
||||
|
||||
--blue: #509BF5;
|
||||
--blue-hover: #6FB1F7;
|
||||
--blue-dim: #1A2F4A;
|
||||
|
||||
--purple: #A855F7;
|
||||
--purple-hover: #C084FC;
|
||||
--purple-dim: #2D1B4D;
|
||||
|
||||
--red: #E22134;
|
||||
--red-hover: #FF4055;
|
||||
|
||||
--text: #FFFFFF;
|
||||
--text-2: #B3B3B3;
|
||||
--text-3: #727272;
|
||||
|
||||
--r-sm: 8px;
|
||||
--r-md: 12px;
|
||||
--r-lg: 14px;
|
||||
--r-pill: 999px;
|
||||
|
||||
--shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
|
||||
--shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.7);
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
button, input, select, textarea { font-family: inherit; font-size: inherit; }
|
||||
|
||||
/* ===============================
|
||||
LAYOUT
|
||||
=============================== */
|
||||
.app {
|
||||
display: grid;
|
||||
grid-template-columns: 240px 1fr;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
SIDEBAR
|
||||
=============================== */
|
||||
.sidebar {
|
||||
background: var(--bg-elev);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 24px 12px;
|
||||
border-right: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 0 8px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.brand-logo {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, var(--green), var(--green-press));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 22px;
|
||||
font-weight: 900;
|
||||
color: #000;
|
||||
box-shadow: 0 4px 12px rgba(29, 185, 84, 0.35);
|
||||
}
|
||||
|
||||
.brand-name {
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.2px;
|
||||
}
|
||||
|
||||
.divider {
|
||||
height: 1px;
|
||||
background: var(--divider);
|
||||
margin: 0 8px 16px;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 12px 14px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text-2);
|
||||
cursor: pointer;
|
||||
border-radius: var(--r-sm);
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
text-align: left;
|
||||
transition: background-color 0.15s ease, color 0.15s ease;
|
||||
}
|
||||
|
||||
.nav-item:hover {
|
||||
background: #1A1A1A;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.nav-item.active {
|
||||
background: #1F1F1F;
|
||||
color: var(--green);
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
font-size: 16px;
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.footer {
|
||||
text-align: center;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--divider);
|
||||
}
|
||||
|
||||
.footer-by {
|
||||
color: var(--green);
|
||||
font-weight: 700;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
|
||||
.footer-version {
|
||||
color: var(--text-3);
|
||||
font-size: 11px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
MAIN
|
||||
=============================== */
|
||||
.main {
|
||||
overflow-y: auto;
|
||||
padding: 24px 32px 32px;
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
.view {
|
||||
display: none;
|
||||
animation: fadeIn 0.25s ease both;
|
||||
}
|
||||
|
||||
.view.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
HERO
|
||||
=============================== */
|
||||
.hero {
|
||||
position: relative;
|
||||
border-radius: var(--r-lg);
|
||||
padding: 28px 32px;
|
||||
margin-bottom: 24px;
|
||||
overflow: hidden;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.hero-green {
|
||||
background: linear-gradient(135deg, #16893E 0%, #0F3B22 60%, #062614 100%);
|
||||
}
|
||||
|
||||
.hero-blue {
|
||||
background: linear-gradient(135deg, #2D4D7A 0%, #1A2F4A 60%, #0D1A2B 100%);
|
||||
}
|
||||
|
||||
.hero-purple {
|
||||
background: linear-gradient(135deg, #5D2C9C 0%, #2D1B4D 60%, #1A0F2E 100%);
|
||||
}
|
||||
|
||||
.hero-content { position: relative; z-index: 2; max-width: 70%; }
|
||||
|
||||
.hero-eyebrow {
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 1.5px;
|
||||
color: var(--green);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.hero-eyebrow.blue { color: var(--blue); }
|
||||
.hero-eyebrow.purple { color: var(--purple); }
|
||||
|
||||
.hero-title {
|
||||
font-size: 36px;
|
||||
font-weight: 900;
|
||||
letter-spacing: -0.8px;
|
||||
line-height: 1.1;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
font-size: 14px;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.hero-deco {
|
||||
position: absolute;
|
||||
right: -10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
font-size: 180px;
|
||||
font-weight: 900;
|
||||
opacity: 0.08;
|
||||
line-height: 1;
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
SECTION LABELS
|
||||
=============================== */
|
||||
.section-label {
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 1.2px;
|
||||
color: var(--text-3);
|
||||
text-transform: uppercase;
|
||||
margin: 8px 4px 10px;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
CARDS
|
||||
=============================== */
|
||||
.card {
|
||||
background: var(--bg-card);
|
||||
border-radius: var(--r-md);
|
||||
padding: 18px 20px;
|
||||
margin-bottom: 18px;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.card-accent-purple {
|
||||
background: linear-gradient(180deg, #1F1532 0%, #181818 80%);
|
||||
border: 1px solid rgba(168, 85, 247, 0.2);
|
||||
}
|
||||
|
||||
.card.actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.log-card {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
FIELDS
|
||||
=============================== */
|
||||
.field { margin-bottom: 14px; }
|
||||
.field:last-child { margin-bottom: 0; }
|
||||
|
||||
.field.inline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
}
|
||||
.field.inline .field-label { margin-bottom: 0; }
|
||||
|
||||
.field-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--text-2);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.row.gap { gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
|
||||
.row.spread { justify-content: space-between; }
|
||||
|
||||
.badge {
|
||||
background: rgba(29, 185, 84, 0.15);
|
||||
color: var(--green);
|
||||
padding: 2px 8px;
|
||||
border-radius: 10px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
INPUTS
|
||||
=============================== */
|
||||
.input {
|
||||
width: 100%;
|
||||
background: var(--bg-input);
|
||||
color: var(--text);
|
||||
border: 1px solid transparent;
|
||||
padding: 10px 16px;
|
||||
border-radius: var(--r-sm);
|
||||
outline: none;
|
||||
transition: background-color 0.15s, border-color 0.15s;
|
||||
}
|
||||
|
||||
.input.pill { border-radius: var(--r-pill); }
|
||||
|
||||
.input::placeholder { color: var(--text-3); }
|
||||
|
||||
.input:focus {
|
||||
background: #333;
|
||||
border-color: rgba(29, 185, 84, 0.4);
|
||||
}
|
||||
|
||||
.input-sm { max-width: 200px; }
|
||||
|
||||
select.input {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%23B3B3B3' d='M2 4l4 4 4-4z'/></svg>");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 14px center;
|
||||
background-size: 12px;
|
||||
padding-right: 36px;
|
||||
}
|
||||
|
||||
input[type="number"] { -moz-appearance: textfield; }
|
||||
input[type="number"]::-webkit-outer-spin-button,
|
||||
input[type="number"]::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.path-display {
|
||||
flex: 1;
|
||||
background: var(--bg-input);
|
||||
color: var(--text);
|
||||
padding: 10px 16px;
|
||||
border-radius: var(--r-pill);
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.path-display:empty,
|
||||
.path-display.empty { color: var(--text-3); }
|
||||
|
||||
/* ===============================
|
||||
BUTTONS
|
||||
=============================== */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 10px 22px;
|
||||
font-weight: 700;
|
||||
border-radius: var(--r-sm);
|
||||
white-space: nowrap;
|
||||
transition: transform 0.06s ease, background-color 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.btn.pill { border-radius: var(--r-pill); }
|
||||
.btn.btn-sm { padding: 8px 16px; font-size: 12px; }
|
||||
.btn.btn-lg { padding: 14px 32px; font-size: 14px; }
|
||||
|
||||
.btn:active { transform: scale(0.96); }
|
||||
.btn:disabled { cursor: not-allowed; opacity: 0.4; }
|
||||
.btn:not(:disabled):hover { filter: brightness(1.06); }
|
||||
|
||||
.btn-primary {
|
||||
background: var(--green);
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.btn-primary:not(:disabled):hover {
|
||||
background: var(--green-hover);
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.btn-blue {
|
||||
background: var(--blue);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-purple {
|
||||
background: var(--purple);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: #00CEC9;
|
||||
color: #000;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: transparent;
|
||||
color: var(--red);
|
||||
border: 1px solid var(--red);
|
||||
}
|
||||
|
||||
.btn-danger:not(:disabled):hover {
|
||||
background: var(--red);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-ghost {
|
||||
background: var(--bg-input);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.btn-ghost:not(:disabled):hover {
|
||||
background: var(--bg-input-hover);
|
||||
}
|
||||
|
||||
.ico {
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
COUNTER / PROGRESS
|
||||
=============================== */
|
||||
.counter {
|
||||
color: var(--text-2);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.progress-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.micro-label {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.8px;
|
||||
color: var(--text-2);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.percent {
|
||||
font-size: 14px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.percent.green { color: var(--green); }
|
||||
.percent.blue { color: var(--blue); }
|
||||
|
||||
.progress {
|
||||
width: 100%;
|
||||
height: 6px;
|
||||
background: var(--bg-input);
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
width: 0%;
|
||||
height: 100%;
|
||||
border-radius: 3px;
|
||||
transition: width 0.2s ease-out;
|
||||
}
|
||||
|
||||
.progress-fill.green {
|
||||
background: linear-gradient(90deg, var(--green), var(--green-hover));
|
||||
}
|
||||
|
||||
.progress-fill.blue {
|
||||
background: linear-gradient(90deg, var(--blue), var(--blue-hover));
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
LOG BOX
|
||||
=============================== */
|
||||
.log {
|
||||
background: var(--bg-card-2);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 14px 16px;
|
||||
font-family: "SF Mono", Menlo, Consolas, monospace;
|
||||
font-size: 12px;
|
||||
color: var(--text-2);
|
||||
height: 220px;
|
||||
overflow-y: auto;
|
||||
white-space: pre-wrap;
|
||||
user-select: text;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.log .l-ok { color: var(--green); }
|
||||
.log .l-err { color: var(--red); }
|
||||
.log .l-info { color: var(--blue); }
|
||||
.log .l-warn { color: #FDCB6E; }
|
||||
.log .l-muted { color: var(--text-3); }
|
||||
|
||||
/* ===============================
|
||||
CHECKBOX
|
||||
=============================== */
|
||||
.checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
color: var(--text);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
margin: 6px 0 14px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.checkbox input { display: none; }
|
||||
|
||||
.check-box {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 4px;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--bg-input-hover);
|
||||
position: relative;
|
||||
transition: background-color 0.15s, border-color 0.15s;
|
||||
}
|
||||
|
||||
.checkbox input:checked + .check-box {
|
||||
background: var(--blue);
|
||||
border-color: var(--blue);
|
||||
}
|
||||
|
||||
.checkbox input:checked + .check-box::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 1px;
|
||||
width: 5px;
|
||||
height: 11px;
|
||||
border: solid #fff;
|
||||
border-width: 0 2px 2px 0;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
INFO ROW (Upgrade tab)
|
||||
=============================== */
|
||||
.info-row {
|
||||
color: var(--green);
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 14px;
|
||||
min-height: 18px;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
SETTINGS
|
||||
=============================== */
|
||||
.version-line {
|
||||
color: var(--text-2);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.strong { color: var(--text); font-weight: 700; }
|
||||
|
||||
.update-status {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
margin-top: 12px;
|
||||
min-height: 18px;
|
||||
}
|
||||
|
||||
.update-status.ok { color: var(--green); }
|
||||
.update-status.warn { color: #FDCB6E; }
|
||||
.update-status.err { color: var(--red); }
|
||||
|
||||
.update-notes {
|
||||
color: var(--text-3);
|
||||
font-size: 12px;
|
||||
margin-top: 8px;
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
.save-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
margin: 20px 0 32px;
|
||||
}
|
||||
|
||||
.save-status {
|
||||
color: var(--green);
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.25s;
|
||||
}
|
||||
|
||||
.save-status.show { opacity: 1; }
|
||||
|
||||
/* ===============================
|
||||
MODAL
|
||||
=============================== */
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.65);
|
||||
backdrop-filter: blur(4px);
|
||||
-webkit-backdrop-filter: blur(4px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 200;
|
||||
animation: fadeIn 0.18s ease both;
|
||||
}
|
||||
|
||||
.modal-backdrop[hidden] { display: none; }
|
||||
|
||||
.modal {
|
||||
background: var(--bg-card);
|
||||
border-radius: var(--r-lg);
|
||||
width: min(560px, calc(100% - 40px));
|
||||
max-height: 80vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: var(--shadow-lg);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.modal-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 18px 22px;
|
||||
border-bottom: 1px solid var(--divider);
|
||||
}
|
||||
|
||||
.modal-head h2 {
|
||||
font-size: 17px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--text-2);
|
||||
font-size: 26px;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
padding: 0 6px;
|
||||
}
|
||||
|
||||
.modal-close:hover { color: var(--text); }
|
||||
|
||||
.modal-body {
|
||||
padding: 18px 22px;
|
||||
font-family: "SF Mono", Menlo, Consolas, monospace;
|
||||
font-size: 13px;
|
||||
color: var(--text-2);
|
||||
white-space: pre-wrap;
|
||||
overflow-y: auto;
|
||||
line-height: 1.6;
|
||||
user-select: text;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.modal-foot {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
padding: 14px 22px;
|
||||
border-top: 1px solid var(--divider);
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
TOAST
|
||||
=============================== */
|
||||
.toast {
|
||||
position: fixed;
|
||||
bottom: 32px;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 100px);
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text);
|
||||
padding: 14px 22px;
|
||||
border-radius: var(--r-pill);
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
box-shadow: var(--shadow-lg);
|
||||
opacity: 0;
|
||||
transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.3, 1), opacity 0.3s;
|
||||
z-index: 300;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.toast.show {
|
||||
opacity: 1;
|
||||
transform: translate(-50%, 0);
|
||||
}
|
||||
|
||||
.toast.toast-error { border-color: var(--red); color: var(--red); }
|
||||
.toast.toast-success { border-color: var(--green); color: var(--green); }
|
||||
|
||||
/* ===============================
|
||||
SCROLLBARS (WebKit)
|
||||
=============================== */
|
||||
::-webkit-scrollbar { width: 10px; height: 10px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #404040;
|
||||
border-radius: 5px;
|
||||
border: 2px solid var(--bg);
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover { background: #606060; }
|
||||
|
||||
.log::-webkit-scrollbar-thumb { border-color: var(--bg-card-2); }
|
||||
.main::-webkit-scrollbar-thumb { border-color: var(--bg); }
|
||||
@@ -0,0 +1,291 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>MusicDownload</title>
|
||||
<link rel="stylesheet" href="css/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
|
||||
<!-- ============== SIDEBAR ============== -->
|
||||
<aside class="sidebar">
|
||||
<div class="brand">
|
||||
<div class="brand-logo">
|
||||
<span>♫</span>
|
||||
</div>
|
||||
<div class="brand-name">MusicDownload</div>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<nav class="nav">
|
||||
<button class="nav-item active" data-view="download">
|
||||
<span class="nav-icon">⬇</span>
|
||||
<span>Scarica</span>
|
||||
</button>
|
||||
<button class="nav-item" data-view="upgrade">
|
||||
<span class="nav-icon">⚡</span>
|
||||
<span>Upgrade</span>
|
||||
</button>
|
||||
<button class="nav-item" data-view="settings">
|
||||
<span class="nav-icon">⚙</span>
|
||||
<span>Impostazioni</span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div class="footer">
|
||||
<div class="footer-by">by LuZa</div>
|
||||
<div class="footer-version" id="footerVersion">v1.0</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- ============== MAIN ============== -->
|
||||
<main class="main">
|
||||
|
||||
<!-- ===== VIEW: DOWNLOAD ===== -->
|
||||
<section class="view active" id="view-download">
|
||||
<header class="hero hero-green">
|
||||
<div class="hero-content">
|
||||
<div class="hero-eyebrow">DOWNLOAD</div>
|
||||
<h1 class="hero-title">Scarica la tua musica</h1>
|
||||
<p class="hero-subtitle">Spotify · YouTube · SoundCloud · qualsiasi link supportato da yt-dlp</p>
|
||||
</div>
|
||||
<div class="hero-deco">♫</div>
|
||||
</header>
|
||||
|
||||
<h2 class="section-label">Sorgente</h2>
|
||||
<div class="card">
|
||||
<div class="field">
|
||||
<label class="field-label">
|
||||
URL
|
||||
<span class="badge" id="urlListBadge" hidden></span>
|
||||
</label>
|
||||
<div class="row">
|
||||
<input type="text" id="urlInput" class="input pill" placeholder="Incolla qui un link Spotify, YouTube o SoundCloud…" />
|
||||
<button class="btn btn-ghost pill" id="loadListBtn">
|
||||
<span>📂</span> Carica lista
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field-label">Cartella output</label>
|
||||
<div class="row">
|
||||
<div class="path-display" id="dlPathDisplay">Nessuna cartella selezionata</div>
|
||||
<button class="btn btn-ghost pill btn-sm" id="dlBrowseBtn">Sfoglia</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card actions">
|
||||
<button class="btn btn-primary pill btn-lg" id="downloadBtn">
|
||||
<span class="ico">▶</span> Avvia Download
|
||||
</button>
|
||||
<button class="btn btn-danger pill btn-lg" id="stopDownloadBtn" disabled>
|
||||
<span class="ico">◼</span> Stop
|
||||
</button>
|
||||
<div class="counter" id="dlCounter"></div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="progress-head">
|
||||
<span class="micro-label">Progresso</span>
|
||||
<span class="percent green" id="dlPercent">0%</span>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-fill green" id="dlProgressFill"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="section-label">Log</h2>
|
||||
<div class="card log-card">
|
||||
<div class="log" id="dlLog"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ===== VIEW: UPGRADE ===== -->
|
||||
<section class="view" id="view-upgrade">
|
||||
<header class="hero hero-blue">
|
||||
<div class="hero-content">
|
||||
<div class="hero-eyebrow blue">UPGRADE QUALITÀ</div>
|
||||
<h1 class="hero-title">Migliora i tuoi audio</h1>
|
||||
<p class="hero-subtitle">Riscarica i file a bitrate più alto. Imposta la soglia minima accettabile.</p>
|
||||
</div>
|
||||
<div class="hero-deco">⚡</div>
|
||||
</header>
|
||||
|
||||
<h2 class="section-label">Cartella audio</h2>
|
||||
<div class="card">
|
||||
<div class="field">
|
||||
<div class="row">
|
||||
<div class="path-display" id="upPathDisplay">Nessuna cartella selezionata</div>
|
||||
<button class="btn btn-ghost pill btn-sm" id="upBrowseBtn">📂 Sfoglia</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="upRecursive" />
|
||||
<span class="check-box"></span>
|
||||
<span>Includi sottocartelle</span>
|
||||
</label>
|
||||
|
||||
<div class="info-row" id="upInfo"></div>
|
||||
|
||||
<div class="field inline">
|
||||
<label class="field-label">Soglia HQ (kbps)</label>
|
||||
<input type="number" id="upThreshold" class="input pill input-sm" value="310" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card actions">
|
||||
<button class="btn btn-blue pill btn-lg" id="upgradeBtn">
|
||||
<span class="ico">▶</span> Avvia Upgrade
|
||||
</button>
|
||||
<button class="btn btn-danger pill btn-lg" id="stopUpgradeBtn" disabled>
|
||||
<span class="ico">◼</span> Stop
|
||||
</button>
|
||||
<div class="counter" id="upCounter"></div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="progress-head">
|
||||
<span class="micro-label">Progresso</span>
|
||||
<span class="percent blue" id="upPercent">0%</span>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-fill blue" id="upProgressFill"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="section-label">Log</h2>
|
||||
<div class="card log-card">
|
||||
<div class="log" id="upLog"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ===== VIEW: SETTINGS ===== -->
|
||||
<section class="view" id="view-settings">
|
||||
<header class="hero hero-purple">
|
||||
<div class="hero-content">
|
||||
<div class="hero-eyebrow purple">IMPOSTAZIONI</div>
|
||||
<h1 class="hero-title">Configurazione</h1>
|
||||
<p class="hero-subtitle">Credenziali Spotify, qualità audio, percorsi e aggiornamenti.</p>
|
||||
</div>
|
||||
<div class="hero-deco">⚙</div>
|
||||
</header>
|
||||
|
||||
<h2 class="section-label">Spotify API</h2>
|
||||
<div class="card card-accent-purple">
|
||||
<div class="row gap">
|
||||
<button class="btn btn-purple pill" id="showGuideBtn">Come ottenere le credenziali?</button>
|
||||
<button class="btn btn-ghost pill" id="openDashboardBtn">Apri Spotify Dashboard</button>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field-label">Client ID</label>
|
||||
<input type="text" id="clientIdInput" class="input pill" placeholder="Inserisci Client ID" />
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field-label">Client Secret</label>
|
||||
<div class="row">
|
||||
<input type="password" id="clientSecretInput" class="input pill" placeholder="Inserisci Client Secret" />
|
||||
<button class="btn btn-ghost pill btn-sm" id="toggleSecretBtn">Mostra</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="section-label">Download</h2>
|
||||
<div class="card">
|
||||
<div class="field">
|
||||
<label class="field-label">Bitrate</label>
|
||||
<select id="bitrateSelect" class="input pill input-sm">
|
||||
<option value="128K">128 kbps</option>
|
||||
<option value="192K">192 kbps</option>
|
||||
<option value="256K">256 kbps</option>
|
||||
<option value="320K" selected>320 kbps</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field-label">Soglia HQ (kbps)</label>
|
||||
<input type="number" id="hqThresholdInput" class="input pill input-sm" placeholder="310" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="section-label">Percorsi</h2>
|
||||
<div class="card">
|
||||
<div class="field">
|
||||
<label class="field-label">Percorso cookies.txt</label>
|
||||
<div class="row">
|
||||
<input type="text" id="cookiesInput" class="input pill" placeholder="cookies.txt" />
|
||||
<button class="btn btn-ghost pill btn-sm" id="browseCookiesBtn">Sfoglia</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field-label">Cartella output predefinita</label>
|
||||
<div class="row">
|
||||
<input type="text" id="outputInput" class="input pill" placeholder="MUSICA/" />
|
||||
<button class="btn btn-ghost pill btn-sm" id="browseOutputBtn">Sfoglia</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="section-label">Aspetto</h2>
|
||||
<div class="card">
|
||||
<div class="field">
|
||||
<label class="field-label">Tema</label>
|
||||
<select id="themeSelect" class="input pill input-sm">
|
||||
<option value="dark">Dark</option>
|
||||
<option value="light">Light</option>
|
||||
<option value="system">System</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="section-label">Aggiornamenti</h2>
|
||||
<div class="card">
|
||||
<div class="row spread">
|
||||
<div class="version-line">
|
||||
Versione corrente: <span class="strong" id="currentVersionLabel">v1.0</span>
|
||||
</div>
|
||||
<button class="btn btn-purple pill" id="checkUpdateBtn">Controlla aggiornamenti</button>
|
||||
</div>
|
||||
<div class="update-status" id="updateStatus"></div>
|
||||
<button class="btn btn-success pill" id="downloadUpdateBtn" hidden>Scarica aggiornamento</button>
|
||||
<div class="update-notes" id="updateNotes"></div>
|
||||
</div>
|
||||
|
||||
<div class="save-row">
|
||||
<button class="btn btn-primary pill btn-lg" id="saveBtn">Salva Impostazioni</button>
|
||||
<div class="save-status" id="saveStatus"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- ============== MODAL: Spotify Guide ============== -->
|
||||
<div class="modal-backdrop" id="guideModal" hidden>
|
||||
<div class="modal">
|
||||
<div class="modal-head">
|
||||
<h2>Come ottenere le credenziali Spotify</h2>
|
||||
<button class="modal-close" id="guideCloseBtn">×</button>
|
||||
</div>
|
||||
<pre class="modal-body" id="guideBody"></pre>
|
||||
<div class="modal-foot">
|
||||
<button class="btn btn-purple pill" id="guideOpenDashBtn">Apri Spotify Dashboard</button>
|
||||
<button class="btn btn-ghost pill" id="guideCloseBtn2">Chiudi</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ============== TOAST ============== -->
|
||||
<div class="toast" id="toast"></div>
|
||||
|
||||
<script src="js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+405
@@ -0,0 +1,405 @@
|
||||
/* ======================================================
|
||||
MusicDownload — Frontend (vanilla JS)
|
||||
====================================================== */
|
||||
|
||||
const $ = (sel) => document.querySelector(sel);
|
||||
const $$ = (sel) => Array.from(document.querySelectorAll(sel));
|
||||
|
||||
const state = {
|
||||
config: {},
|
||||
urlList: [],
|
||||
dlOutputDir: "",
|
||||
upDir: "",
|
||||
showSecret: false,
|
||||
downloading: false,
|
||||
upgrading: false,
|
||||
};
|
||||
|
||||
// Wait for pywebview ready
|
||||
function waitApi() {
|
||||
return new Promise((resolve) => {
|
||||
if (window.pywebview && window.pywebview.api) return resolve();
|
||||
window.addEventListener("pywebviewready", resolve, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Bridge — eventi spinti dal backend
|
||||
// ============================================================
|
||||
window.bridge = {
|
||||
emit(channel, payload) {
|
||||
const handler = bridgeHandlers[channel];
|
||||
if (handler) handler(payload);
|
||||
},
|
||||
};
|
||||
|
||||
const bridgeHandlers = {
|
||||
"log": ({ view, msg }) => appendLog(view, msg),
|
||||
|
||||
"download:progress": (p) => {
|
||||
if (typeof p.overall === "number") {
|
||||
const pct = Math.round(p.overall * 100);
|
||||
$("#dlProgressFill").style.width = pct + "%";
|
||||
$("#dlPercent").textContent = pct + "%";
|
||||
}
|
||||
if (p.status === "searching" && typeof p.idx === "number") {
|
||||
const prefix = p.url_total > 1 ? `[${(p.url_idx ?? 0) + 1}/${p.url_total}] ` : "";
|
||||
$("#dlCounter").textContent = `${prefix}Brano ${p.idx + 1} di ${p.total}`;
|
||||
}
|
||||
if (p.status === "completed" && p.url_total > 1) {
|
||||
$("#dlCounter").textContent = `Completato: ${p.url_total} URL`;
|
||||
}
|
||||
},
|
||||
|
||||
"download:done": () => {
|
||||
state.downloading = false;
|
||||
state.urlList = [];
|
||||
$("#urlListBadge").hidden = true;
|
||||
$("#urlListBadge").textContent = "";
|
||||
$("#downloadBtn").disabled = false;
|
||||
$("#loadListBtn").disabled = false;
|
||||
$("#stopDownloadBtn").disabled = true;
|
||||
},
|
||||
|
||||
"upgrade:progress": (p) => {
|
||||
if (typeof p.overall === "number") {
|
||||
const pct = Math.round(p.overall * 100);
|
||||
$("#upProgressFill").style.width = pct + "%";
|
||||
$("#upPercent").textContent = pct + "%";
|
||||
}
|
||||
if (typeof p.idx === "number" && typeof p.total === "number" && p.total > 0) {
|
||||
$("#upCounter").textContent = `File ${p.idx} di ${p.total}`;
|
||||
}
|
||||
if (p.status === "completed") {
|
||||
$("#upCounter").textContent = `Completato: ${p.total} file`;
|
||||
}
|
||||
},
|
||||
|
||||
"upgrade:done": () => {
|
||||
state.upgrading = false;
|
||||
$("#upgradeBtn").disabled = false;
|
||||
$("#stopUpgradeBtn").disabled = true;
|
||||
},
|
||||
};
|
||||
|
||||
// ============================================================
|
||||
// Logging
|
||||
// ============================================================
|
||||
const logEls = { download: () => $("#dlLog"), upgrade: () => $("#upLog") };
|
||||
|
||||
function classifyLog(msg) {
|
||||
if (msg.startsWith("[ERRORE]")) return "l-err";
|
||||
if (msg.startsWith("[OK]") || msg.startsWith("[UPGRADE]")) return "l-ok";
|
||||
if (msg.startsWith("[INFO]")) return "l-info";
|
||||
if (msg.startsWith("[SKIP]") || msg.startsWith("[CERCA]") || msg.startsWith("[DOWNLOAD]") || msg.startsWith("[CONV]")) return "l-muted";
|
||||
if (msg.startsWith("[NON TROVATO]")) return "l-warn";
|
||||
if (msg.startsWith("[LISTA]")) return "l-info";
|
||||
return "";
|
||||
}
|
||||
|
||||
function appendLog(view, msg) {
|
||||
const el = logEls[view] && logEls[view]();
|
||||
if (!el) return;
|
||||
const cls = classifyLog(msg);
|
||||
const line = document.createElement("div");
|
||||
if (cls) line.className = cls;
|
||||
line.textContent = msg;
|
||||
el.appendChild(line);
|
||||
el.scrollTop = el.scrollHeight;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Toast
|
||||
// ============================================================
|
||||
let toastTimer = null;
|
||||
function toast(msg, kind = "") {
|
||||
const el = $("#toast");
|
||||
el.textContent = msg;
|
||||
el.className = "toast show " + (kind ? `toast-${kind}` : "");
|
||||
clearTimeout(toastTimer);
|
||||
toastTimer = setTimeout(() => { el.className = "toast"; }, 3000);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Routing (sidebar)
|
||||
// ============================================================
|
||||
function showView(name) {
|
||||
$$(".view").forEach((v) => v.classList.toggle("active", v.id === `view-${name}`));
|
||||
$$(".nav-item").forEach((b) => b.classList.toggle("active", b.dataset.view === name));
|
||||
}
|
||||
|
||||
$$(".nav-item").forEach((btn) => {
|
||||
btn.addEventListener("click", () => showView(btn.dataset.view));
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// Init
|
||||
// ============================================================
|
||||
async function init() {
|
||||
await waitApi();
|
||||
const data = await window.pywebview.api.get_init_data();
|
||||
state.config = data.config || {};
|
||||
$("#footerVersion").textContent = data.version;
|
||||
$("#currentVersionLabel").textContent = data.version;
|
||||
$("#guideBody").textContent = data.spotify_guide;
|
||||
|
||||
// Populate Settings fields
|
||||
$("#clientIdInput").value = state.config.client_id || "";
|
||||
$("#clientSecretInput").value = state.config.client_secret || "";
|
||||
$("#bitrateSelect").value = state.config.bitrate || "320K";
|
||||
$("#hqThresholdInput").value = state.config.hq_threshold || 310;
|
||||
$("#cookiesInput").value = state.config.cookies_path || "";
|
||||
$("#outputInput").value = state.config.output_dir || "";
|
||||
$("#themeSelect").value = state.config.theme || "dark";
|
||||
|
||||
// Download tab — usa output_dir come default
|
||||
state.dlOutputDir = state.config.output_dir || "";
|
||||
if (state.dlOutputDir) {
|
||||
$("#dlPathDisplay").textContent = state.dlOutputDir;
|
||||
$("#dlPathDisplay").classList.remove("empty");
|
||||
}
|
||||
|
||||
// Upgrade tab — default threshold
|
||||
$("#upThreshold").value = state.config.hq_threshold || 310;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// DOWNLOAD tab
|
||||
// ============================================================
|
||||
$("#dlBrowseBtn").addEventListener("click", async () => {
|
||||
const path = await window.pywebview.api.browse_directory();
|
||||
if (path) {
|
||||
state.dlOutputDir = path;
|
||||
$("#dlPathDisplay").textContent = path;
|
||||
$("#dlPathDisplay").classList.remove("empty");
|
||||
}
|
||||
});
|
||||
|
||||
$("#loadListBtn").addEventListener("click", async () => {
|
||||
const path = await window.pywebview.api.browse_file([
|
||||
"Text files (*.txt)",
|
||||
"All files (*.*)",
|
||||
]);
|
||||
if (!path) return;
|
||||
const res = await window.pywebview.api.load_url_list(path);
|
||||
if (!res.ok) {
|
||||
toast("Impossibile leggere il file: " + (res.error || ""), "error");
|
||||
return;
|
||||
}
|
||||
if (!res.count) {
|
||||
toast("Il file non contiene URL validi", "error");
|
||||
return;
|
||||
}
|
||||
state.urlList = res.urls;
|
||||
$("#urlInput").value = path;
|
||||
const badge = $("#urlListBadge");
|
||||
badge.textContent = `· ${res.count} URL caricati`;
|
||||
badge.hidden = false;
|
||||
appendLog("download", `[INFO] Caricati ${res.count} URL dal file`);
|
||||
});
|
||||
|
||||
$("#downloadBtn").addEventListener("click", async () => {
|
||||
let urls = state.urlList;
|
||||
if (!urls.length) {
|
||||
const single = $("#urlInput").value.trim();
|
||||
if (!single) {
|
||||
toast("Inserisci un URL o carica una lista", "error");
|
||||
return;
|
||||
}
|
||||
urls = [single];
|
||||
}
|
||||
if (!state.dlOutputDir) {
|
||||
toast("Seleziona una cartella di destinazione", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
state.downloading = true;
|
||||
$("#downloadBtn").disabled = true;
|
||||
$("#loadListBtn").disabled = true;
|
||||
$("#stopDownloadBtn").disabled = false;
|
||||
$("#dlProgressFill").style.width = "0%";
|
||||
$("#dlPercent").textContent = "0%";
|
||||
|
||||
const res = await window.pywebview.api.start_download({
|
||||
urls,
|
||||
output_dir: state.dlOutputDir,
|
||||
});
|
||||
if (!res.ok) {
|
||||
toast(res.error || "Errore", "error");
|
||||
bridgeHandlers["download:done"]();
|
||||
}
|
||||
});
|
||||
|
||||
$("#stopDownloadBtn").addEventListener("click", async () => {
|
||||
await window.pywebview.api.stop_download();
|
||||
$("#stopDownloadBtn").disabled = true;
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// UPGRADE tab
|
||||
// ============================================================
|
||||
$("#upBrowseBtn").addEventListener("click", async () => {
|
||||
const path = await window.pywebview.api.browse_directory();
|
||||
if (path) {
|
||||
state.upDir = path;
|
||||
$("#upPathDisplay").textContent = path;
|
||||
$("#upPathDisplay").classList.remove("empty");
|
||||
await refreshUpgradeScan();
|
||||
}
|
||||
});
|
||||
|
||||
$("#upRecursive").addEventListener("change", refreshUpgradeScan);
|
||||
|
||||
async function refreshUpgradeScan() {
|
||||
if (!state.upDir) return;
|
||||
const res = await window.pywebview.api.scan_audio_folder(state.upDir, $("#upRecursive").checked);
|
||||
const info = $("#upInfo");
|
||||
if (!res.ok) {
|
||||
info.textContent = "Errore scansione: " + (res.error || "");
|
||||
return;
|
||||
}
|
||||
if (!res.total) {
|
||||
info.textContent = "Nessun file audio trovato";
|
||||
return;
|
||||
}
|
||||
if (res.done > 0) {
|
||||
info.textContent = `● ${res.total} file audio · ${res.done} già convertiti · ${res.remaining} da fare`;
|
||||
} else {
|
||||
info.textContent = `● ${res.total} file audio trovati`;
|
||||
}
|
||||
}
|
||||
|
||||
$("#upgradeBtn").addEventListener("click", async () => {
|
||||
if (!state.upDir) {
|
||||
toast("Seleziona una cartella", "error");
|
||||
return;
|
||||
}
|
||||
state.upgrading = true;
|
||||
$("#upgradeBtn").disabled = true;
|
||||
$("#stopUpgradeBtn").disabled = false;
|
||||
$("#upProgressFill").style.width = "0%";
|
||||
$("#upPercent").textContent = "0%";
|
||||
|
||||
const res = await window.pywebview.api.start_upgrade({
|
||||
directory: state.upDir,
|
||||
recursive: $("#upRecursive").checked,
|
||||
threshold: parseInt($("#upThreshold").value, 10) || 310,
|
||||
});
|
||||
if (!res.ok) {
|
||||
toast(res.error || "Errore", "error");
|
||||
bridgeHandlers["upgrade:done"]();
|
||||
}
|
||||
});
|
||||
|
||||
$("#stopUpgradeBtn").addEventListener("click", async () => {
|
||||
await window.pywebview.api.stop_upgrade();
|
||||
$("#stopUpgradeBtn").disabled = true;
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// SETTINGS tab
|
||||
// ============================================================
|
||||
$("#toggleSecretBtn").addEventListener("click", () => {
|
||||
state.showSecret = !state.showSecret;
|
||||
$("#clientSecretInput").type = state.showSecret ? "text" : "password";
|
||||
$("#toggleSecretBtn").textContent = state.showSecret ? "Nascondi" : "Mostra";
|
||||
});
|
||||
|
||||
$("#browseCookiesBtn").addEventListener("click", async () => {
|
||||
const path = await window.pywebview.api.browse_file([
|
||||
"Text files (*.txt)",
|
||||
"All files (*.*)",
|
||||
]);
|
||||
if (path) $("#cookiesInput").value = path;
|
||||
});
|
||||
|
||||
$("#browseOutputBtn").addEventListener("click", async () => {
|
||||
const path = await window.pywebview.api.browse_directory();
|
||||
if (path) $("#outputInput").value = path;
|
||||
});
|
||||
|
||||
$("#saveBtn").addEventListener("click", async () => {
|
||||
const payload = {
|
||||
client_id: $("#clientIdInput").value,
|
||||
client_secret: $("#clientSecretInput").value,
|
||||
bitrate: $("#bitrateSelect").value,
|
||||
hq_threshold: parseInt($("#hqThresholdInput").value, 10) || 310,
|
||||
cookies_path: $("#cookiesInput").value,
|
||||
output_dir: $("#outputInput").value,
|
||||
theme: $("#themeSelect").value,
|
||||
};
|
||||
const res = await window.pywebview.api.save_settings(payload);
|
||||
if (res.ok) {
|
||||
state.config = payload;
|
||||
// sync Download tab default path
|
||||
if (!state.dlOutputDir && payload.output_dir) {
|
||||
state.dlOutputDir = payload.output_dir;
|
||||
$("#dlPathDisplay").textContent = payload.output_dir;
|
||||
$("#dlPathDisplay").classList.remove("empty");
|
||||
}
|
||||
const status = $("#saveStatus");
|
||||
status.textContent = "✓ Impostazioni salvate";
|
||||
status.classList.add("show");
|
||||
setTimeout(() => status.classList.remove("show"), 2500);
|
||||
} else {
|
||||
toast("Errore nel salvataggio", "error");
|
||||
}
|
||||
});
|
||||
|
||||
$("#openDashboardBtn").addEventListener("click", () => {
|
||||
window.pywebview.api.open_external_url("https://developer.spotify.com/dashboard");
|
||||
});
|
||||
|
||||
$("#showGuideBtn").addEventListener("click", () => {
|
||||
$("#guideModal").hidden = false;
|
||||
});
|
||||
|
||||
$("#guideCloseBtn").addEventListener("click", () => { $("#guideModal").hidden = true; });
|
||||
$("#guideCloseBtn2").addEventListener("click", () => { $("#guideModal").hidden = true; });
|
||||
$("#guideOpenDashBtn").addEventListener("click", () => {
|
||||
window.pywebview.api.open_external_url("https://developer.spotify.com/dashboard");
|
||||
});
|
||||
|
||||
$("#checkUpdateBtn").addEventListener("click", async () => {
|
||||
const btn = $("#checkUpdateBtn");
|
||||
const status = $("#updateStatus");
|
||||
const notes = $("#updateNotes");
|
||||
const dlBtn = $("#downloadUpdateBtn");
|
||||
|
||||
btn.disabled = true;
|
||||
btn.textContent = "Controllo...";
|
||||
status.className = "update-status";
|
||||
status.textContent = "";
|
||||
notes.textContent = "";
|
||||
dlBtn.hidden = true;
|
||||
|
||||
const res = await window.pywebview.api.check_update();
|
||||
btn.disabled = false;
|
||||
btn.textContent = "Controlla aggiornamenti";
|
||||
|
||||
if (!res.ok) {
|
||||
status.className = "update-status err";
|
||||
status.textContent = "Errore: " + (res.error || "");
|
||||
return;
|
||||
}
|
||||
if (res.is_new) {
|
||||
status.className = "update-status warn";
|
||||
status.textContent = `Nuova versione disponibile: ${res.remote}`;
|
||||
if (res.download_url) {
|
||||
dlBtn.hidden = false;
|
||||
dlBtn.onclick = () => window.pywebview.api.open_external_url(res.download_url);
|
||||
}
|
||||
if (res.notes) notes.textContent = res.notes;
|
||||
} else {
|
||||
status.className = "update-status ok";
|
||||
status.textContent = "✓ Sei aggiornato!";
|
||||
}
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// Boot
|
||||
// ============================================================
|
||||
init().catch((e) => {
|
||||
console.error(e);
|
||||
toast("Errore di inizializzazione: " + e.message, "error");
|
||||
});
|
||||
Reference in new issue
Block a user