play: native torrent via Lampa.Player.play with torrent_hash; download opens magnet directly
This commit is contained in:
1 parent
b5fbd9e027
commit
814589ca1b
1 file changed
+16
-8
@@ -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).
|
||||
$('<a href="' + url + '"></a>')[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.
|
||||
$('<a href="' + url + '"></a>')[0].click();
|
||||
}
|
||||
|
||||
// ---------- Menu item ----------
|
||||
|
||||
Reference in new issue
Block a user