fix: pass magnet link directly to add-torrent API, avoid search_by_id lookup
This commit is contained in:
parent
b971294909
commit
fb2aa5a60a
2 changed files with 62 additions and 15 deletions
|
|
@ -215,7 +215,7 @@
|
|||
<div class="torrent-actions">
|
||||
<a href="{{ torrent.magnet }}" class="btn btn-primary">Magnet</a>
|
||||
<a href="{{ torrent.download_url }}" class="btn btn-success">Скачать .torrent</a>
|
||||
<button onclick="addToTorrentClient('{{ torrent.id }}')" class="btn btn-secondary">Добавить в клиент</button>
|
||||
<button onclick="addToTorrentClient('{{ torrent.id }}', '{{ torrent.magnet|e }}', '{{ torrent.title|e }}')" class="btn btn-secondary">Добавить в клиент</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
@ -228,16 +228,18 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
function addToTorrentClient(torrentId) {
|
||||
function addToTorrentClient(torrentId, magnet, title) {
|
||||
// Показываем индикатор загрузки
|
||||
const button = event.target;
|
||||
const originalText = button.textContent;
|
||||
button.textContent = '⏳ Получаем magnet...';
|
||||
button.textContent = '⏳ Добавляем...';
|
||||
button.disabled = true;
|
||||
|
||||
// Отправляем ID торрента для получения magnet-ссылки
|
||||
// Отправляем ID + magnet + название
|
||||
const formData = new FormData();
|
||||
formData.append('torrent_id', torrentId);
|
||||
formData.append('magnet', magnet || '');
|
||||
formData.append('torrent_title', title || '');
|
||||
|
||||
fetch('/api/add-torrent', {
|
||||
method: 'POST',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue