diff --git a/plugin.js b/plugin.js index e88187d..e5ad8eb 100644 --- a/plugin.js +++ b/plugin.js @@ -382,25 +382,33 @@ } function play(m) { + // Native Lampa torrent playback: pass the magnet url + torrent_hash. + // On Android/TV (no Torserver) Lampa routes the magnet to the system torrent + // player; with Torserver it streams via the built-in player. var url = m.magnet ? m.magnet : resolve(m.torrent); - Lampa.Player.play({ + if (!url) return; + var data = { url: url, title: m.title, img: resolve(m.poster || m.cover), season: 0, episode: 0 - }); + }; + if (m.hash) data.torrent_hash = m.hash; + if (Lampa.Torserver && Lampa.Torserver.url && !Lampa.Torserver.url()) { + // No torrent server configured: fall back to opening the magnet link directly + // (Android opens it in the torrent client; web triggers a download/play). + $('')[0].click(); + return; + } + Lampa.Player.play(data); } function download(m) { var url = m.magnet ? m.magnet : resolve(m.torrent); if (!url) return; - // Open the torrent/magnet in the system (player or download manager) - if (Lampa.Player && Lampa.Player.play) { - Lampa.Player.play({ url: url, title: m.title, img: resolve(m.poster || m.cover), season: 0, episode: 0 }); - } else { - window.open(url, '_blank'); - } + // Open the torrent/magnet directly so the system (player or download manager) handles it. + $('')[0].click(); } // ---------- Menu item ----------