synchro du labo (0bf0da65) : app.blade.php, README.md

This commit is contained in:
cloudion 2026-11-03 22:40:54 +00:00
parent 750b681eb8
commit b192405db0
2 changed files with 174 additions and 2 deletions

View File

@ -1,3 +1,21 @@
# ploxion-youtube-dl
# ⬇ YouTube DL
PLOXION · Le serveur télécharge une vidéo pour toi — 📹 mp4 ou 🎵 mp3, direct dans tes Fichiers (/ytdl). Outil personnel : respecte les droits des contenus. · fournit: video, download, mp3, files
Le serveur télécharge une vidéo pour toi — 📹 mp4 ou 🎵 mp3, direct dans tes Fichiers (/ytdl). Outil personnel : respecte les droits des contenus.
| | |
| --- | --- |
| id | `youtube-dl` |
| fournit | `video` `download` `mp3` `files` |
| bions qu'il nomme | `jOSApps` `jOSMobile` |
| fichiers | `app.blade.php` |
| dans le labo | `resources/views/ploxions/youtube-dl/` (dépôt `my_website2`) |
## Contribuer
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=youtube-dl — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
- **Dans VS Code** : `xb prendre youtube-dl` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
© 2026 chill-tekk · ne pas nuire

154
app.blade.php Normal file
View File

@ -0,0 +1,154 @@
{{-- PL0XI0N youtube-dl — le serveur télécharge POUR TOI (directive RS-7 : outil
personnel yt→mp4/mp3, gated auth, sur son propre serveur). Colle une URL,
choisis 📹 mp4 ou 🎵 mp3, go : le backend (POST /px/ytdl) lance yt-dlp en
arrière-plan et on POLL la progression (GET /px/ytdl/<jobId>, 2 s). À la fin
le fichier est dans TES Fichiers (storage fs → dossier /ytdl), ouvrable via
le ploxion filesystem ou téléchargeable direct via /fs/read.
Honnêteté : bandeau « respecte les droits des contenus ». Si l'image docker
n'a pas encore yt-dlp (503 engine-missing) → message clair, pas d'échec muet.
window.jOSApps['youtube-dl']. mount(c, ctx) -> { unmount }. --}}
<style>
.ytd { display:flex; flex-direction:column; height:100%; background:#06090d;
color:rgba(220,232,240,.92); font-family:ui-sans-serif,system-ui,sans-serif; font-size:.84rem; }
.ytd__bar { flex:0 0 auto; display:flex; align-items:center; gap:8px; padding:8px 11px; border-bottom:1px solid rgba(120,160,230,.18); }
.ytd__t { font-weight:700; letter-spacing:.04em; color:rgba(255,120,120,.95); white-space:nowrap; }
.ytd__note { flex:0 0 auto; padding:6px 12px; font-size:.7rem; color:rgba(190,212,228,.55);
border-bottom:1px solid rgba(120,160,230,.1); background:rgba(18,26,42,.35); }
.ytd__body { flex:1; min-height:0; overflow-y:auto; display:flex; flex-direction:column; gap:12px; padding:16px 14px; max-width:640px; width:100%; margin:0 auto; }
.ytd__f { width:100%; border-radius:8px; padding:9px 12px; border:1px solid rgba(120,160,230,.25);
background:rgba(18,26,42,.55); color:#fff; font-family:inherit; font-size:.84rem; outline:none; }
.ytd__f:focus { border-color:rgba(255,120,120,.5); }
.ytd__row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.ytd__fmt { cursor:pointer; padding:7px 14px; border-radius:8px; border:1px solid rgba(120,160,230,.25);
background:rgba(18,26,42,.5); color:rgba(190,215,240,.85); font-size:.8rem; }
.ytd__fmt--on { border-color:rgba(255,120,120,.6); background:rgba(120,40,40,.35); color:#fff; }
.ytd__go { cursor:pointer; margin-left:auto; padding:7px 18px; border-radius:8px; border:1px solid rgba(255,120,120,.45);
background:rgba(120,40,40,.35); color:#fff; font-size:.8rem; }
.ytd__go:hover { background:rgba(170,50,50,.45); }
.ytd__go:disabled { opacity:.45; cursor:default; }
.ytd__prog { display:none; flex-direction:column; gap:6px; }
.ytd__track { height:10px; border-radius:6px; background:rgba(120,160,230,.12); overflow:hidden; }
.ytd__fill { height:100%; width:0%; border-radius:6px; background:linear-gradient(90deg, rgba(255,120,120,.75), rgba(255,170,110,.85)); transition:width .5s; }
.ytd__pstat { font-size:.74rem; color:rgba(190,212,228,.7); }
.ytd__done { display:none; flex-direction:column; gap:9px; padding:12px; border-radius:10px;
border:1px solid rgba(90,200,140,.35); background:rgba(20,60,40,.25); }
.ytd__file { font-size:.8rem; color:rgba(190,240,205,.92); word-break:break-all; }
.ytd__act { cursor:pointer; display:inline-block; text-decoration:none; padding:6px 13px; border-radius:8px;
border:1px solid rgba(90,200,140,.4); background:rgba(20,80,50,.35); color:#fff; font-size:.78rem; }
.ytd__act:hover { background:rgba(25,110,65,.45); }
.ytd__err { display:none; padding:10px 12px; border-radius:10px; font-size:.78rem;
border:1px solid rgba(255,120,120,.4); background:rgba(120,40,40,.22); color:rgba(255,190,190,.92); }
</style>
<script>
(function () {
'use strict';
function esc(s) { return window.jOSb.esc(s); }
function csrf(){ try{ var m=document.querySelector('meta[name=csrf-token]'); return m?m.content:''; }catch(e){ return ''; } }
var LIVE = null; // posé au mount : {active:function()}
function describe() {
var on = LIVE ? LIVE.active() : false;
return { v: 1, id: 'youtube-dl', title: 'YouTube DL', icon: '⬇', items: [
{ p: 1, kind: 'stat', label: 'téléchargement', value: on ? 'en cours' : 'aucun' }
] };
}
function mount(container, ctx) {
var fmt = 'mp4', jobId = null, timer = null, alive = true;
LIVE = { active: function () { return !!jobId; } };
container.innerHTML =
'<div class="ytd">'
+ ' <div class="ytd__bar"><span class="ytd__t">⬇ YouTube → fichier</span></div>'
+ ' <div class="ytd__note">🔒 outil personnel — ton serveur télécharge pour toi ; respecte les droits des contenus.</div>'
+ ' <div class="ytd__body">'
+ ' <input class="ytd__f" placeholder="colle une URL de vidéo (youtube.com, youtu.be…)">'
+ ' <div class="ytd__row">'
+ ' <button class="ytd__fmt ytd__fmt--on" data-fmt="mp4">📹 mp4</button>'
+ ' <button class="ytd__fmt" data-fmt="mp3">🎵 mp3</button>'
+ ' <button class="ytd__go" data-go>télécharger</button>'
+ ' </div>'
+ ' <div class="ytd__prog"><div class="ytd__track"><div class="ytd__fill"></div></div><div class="ytd__pstat">démarrage…</div></div>'
+ ' <div class="ytd__done"></div>'
+ ' <div class="ytd__err"></div>'
+ ' </div>'
+ '</div>';
var elF = container.querySelector('.ytd__f'), elGo = container.querySelector('[data-go]'),
elProg = container.querySelector('.ytd__prog'), elFill = container.querySelector('.ytd__fill'),
elPstat = container.querySelector('.ytd__pstat'), elDone = container.querySelector('.ytd__done'),
elErr = container.querySelector('.ytd__err');
function stopPoll() { if (timer) { clearInterval(timer); timer = null; } }
function showErr(msg) { stopPoll(); elProg.style.display = 'none'; elGo.disabled = false;
elErr.style.display = 'block'; elErr.innerHTML = '⚠ ' + esc(msg); }
function reset() { elErr.style.display = 'none'; elDone.style.display = 'none'; elProg.style.display = 'none'; }
function showProgress(pct) {
elProg.style.display = 'flex';
var p = Math.max(0, Math.min(100, Number(pct) || 0));
elFill.style.width = p + '%';
elPstat.textContent = p > 0 ? (p.toFixed(1) + ' % — ton serveur télécharge…') : 'démarrage…';
}
function openFiles() {
if (window.jOSMobile && window.jOSMobile.open) window.jOSMobile.open('filesystem', 'Fichiers');
else if (window.jOS && window.jOS.openPloxion) window.jOS.openPloxion('filesystem');
}
function showDone(d) {
stopPoll(); elProg.style.display = 'none'; elGo.disabled = false;
var dl = '/fs/read?path=' + encodeURIComponent('ytdl/' + d.file);
var mb = d.size ? ' (' + (d.size / 1048576).toFixed(1) + ' Mo)' : '';
elDone.style.display = 'flex';
elDone.innerHTML =
'<div class="ytd__file">✓ ' + esc(d.file) + esc(mb) + '</div>'
+ '<div class="ytd__row"><button class="ytd__act" data-files>📁 dans tes Fichiers</button>'
+ '<a class="ytd__act" href="' + esc(dl) + '" download="' + esc(d.file) + '">⬇ télécharger</a></div>';
var bf = elDone.querySelector('[data-files]'); if (bf) bf.addEventListener('click', openFiles);
}
function poll() {
if (!jobId || !alive) return;
fetch('/px/ytdl/' + jobId, { credentials: 'same-origin' })
.then(function (r) { return r.ok ? r.json() : Promise.reject(new Error('statut injoignable (' + r.status + ')')); })
.then(function (d) {
if (!alive || !d) return;
if (d.status === 'done') showDone(d);
else if (d.status === 'error') showErr(d.err || 'échec du téléchargement');
else showProgress(d.pct);
})
.catch(function () { /* transitoire : on retentera au tick suivant */ });
}
function follow(id) { jobId = id; stopPoll(); showProgress(0); timer = setInterval(poll, 2000); poll(); }
function start() {
var url = elF.value.trim();
if (!url) { showErr('colle d’abord une URL de vidéo'); return; }
reset(); elGo.disabled = true; showProgress(0);
fetch('/px/ytdl', { method: 'POST', credentials: 'same-origin',
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-CSRF-TOKEN': csrf() },
body: JSON.stringify({ url: url, format: fmt }) })
.then(function (r) { return r.json().then(function (d) { return { s: r.status, d: d || {} }; }); })
.then(function (x) {
if (!alive) return;
if (x.s === 503 && x.d.error === 'engine-missing') { showErr('le moteur (yt-dlp) n’est pas encore dans l’image — il sera dispo au prochain déploiement.'); return; }
if (x.s === 429 && x.d.jobId) { elErr.style.display = 'none'; elPstat.textContent = 'un téléchargement déjà en cours — je le suis'; follow(x.d.jobId); return; }
if (x.s === 429) { showErr(x.d.error || x.d.message || 'trop de demandes — réessaie dans un moment (10/h max)'); return; }
if (x.s >= 400 || !x.d.jobId) { showErr(x.d.error || x.d.message || 'demande refusée'); return; }
follow(x.d.jobId);
})
.catch(function () { if (alive) showErr('serveur injoignable — réessaie'); });
}
container.querySelectorAll('[data-fmt]').forEach(function (b) {
b.addEventListener('click', function () {
fmt = b.getAttribute('data-fmt');
container.querySelectorAll('[data-fmt]').forEach(function (o) { o.classList.toggle('ytd__fmt--on', o === b); });
});
});
elGo.addEventListener('click', start);
elF.addEventListener('keydown', function (e) { if (e.key === 'Enter') start(); });
if (ctx && ctx.config && ctx.config.url) { elF.value = String(ctx.config.url); }
setTimeout(function () { try { elF.focus(); } catch (e) {} }, 30);
return { unmount: function () { alive = false; LIVE = null; stopPoll(); container.innerHTML = ''; } };
}
window.jOSApps = window.jOSApps || {};
window.jOSApps['youtube-dl'] = { manifest: { id: 'youtube-dl', name: 'YouTube DL', icon: '⬇' }, mount: mount, describe: describe };
})();
</script>