Я использую торрент-клиент командной строки rTorrent под Xenial Xerus, и мне хотелось бы:
Я считаю, что скрипт необходимо вызывать из Firefox, но написание такого скрипта До сих пор победил меня ...
Проблемы обычно связаны с типом пантомимы и обработчиками по умолчанию.
Во-первых, имейте Вас измененный Firefox about:config
настройки? т.е.:
network.protocol-handler.expose.magnet -> false
и сброс другие опции согласно этому Firefox затопляет Вопросы и ответы.
Вы настроили rTorrent для наблюдения какого-либо конкретного каталога?
ФАЙЛ: ~/.rtorrent.rc
# Maximum and minimum number of peers to connect to per torrent.
min_peers = 50
max_peers = 80
# Maximum number of simultanious uploads per torrent.
max_uploads = 5
# Global upload and download rate in KiB. "0" for unlimited.
download_rate = 0
upload_rate = 50
# Default directory to save the downloaded torrents.
directory = $HOME/torrents/downloads
# Watch a directory for new torrents
# SET your watch directory here --v
schedule = watch_directory,5,5,$HOME/torrents/watch/*.torrent
port_range = 60125-64125
port_random = yes
dht = auto
# UDP port to use for DHT.
dht_port = 63425
# Enable peer exchange (for torrents not marked private)
peer_exchange = yes
# Check hash for finished torrents.
check_hash = yes
encryption = allow_incoming,try_outgoing ,enable_retry
Затем это - простой вопрос "сохранить Как" в $HOME/torrents/watch
.
Изменение $HOME/torrents/watch
к любой подпапке потоков Вы используете, или по крайней мере $HOME к/home/username
Создайте файл и добавьте следующий сценарий:
ФАЙЛ: maglink-rtorrent.sh
#!/bin/bash
cd $HOME/torrents/watch # set your watch directory here
[[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit;
echo "d10:magnet-uri${#1}:${1}e" > "meta-${BASH_REMATCH[1]}.torrent"
Не забывайте делать это исполняемым файлом
chmod +x maglink-rtorrent.sh
Это также предлагает способность загрузить с терминала:
cd $HOME/torrents/watch
./maglink-rtorrent.sh "MAGNET-LINK-HERE"
Далее потрясающие Сервисные Подсказки и rTorrent опции настройки здесь.
Кредиты Futher:
Не используя rTorrent, но kTorrent или qBittorent, затем это следующее является способом получить то выполнение:
# check defaults
xdg-mime query default x-scheme-handler/magnet
gvfs-mime --query x-scheme-handler/magnet
# set defaults
xdg-mime default qBittorent.desktop x-scheme-handler/magnet
gvfs-mime --set x-scheme-handler/magnet qBittorrent.desktop
Существует дальнейшая установка (из памяти) для того, требуете ли Вы командной строки.
Для rTorrent, хотя, этой ссылкой является Магнит обработчик FlexGet rTorrent URI
Надеюсь, это поможет.
Следующий сценарий является вращением на коде Max Gonzih, который работает и с регулярными .torrent файлами и с магнитными ссылками:
#!/bin/bash
torrent_file_or_magnet_link="$1"
# Edit rtorrent.rc to automatically start downloads when a .torrent file
# appears in this directory.
cd "$HOME/.rtorrent/watch/start/"
# XT stands for "exact topic".
# BTIH is the BitTorrent info hash:
# https://en.wikipedia.org/wiki/Magnet_URI_scheme#BitTorrent_info_hash_(BTIH)
# This is the hex-encoded SHA-1 hash of the torrent file info section
magnet_regex="xt=urn:btih:([^&/]+)"
if [[ "$torrent_file_or_magnet_link" =~ $magnet_regex ]]; then
torrent_hash=${BASH_REMATCH[1]};
magnet_link_length=${#torrent_file_or_magnet_link}
# To conform with the bencode encoding, the magnet link's number of characters
# must be part of the torrent file, otherwise rTorrent can't read it.
# Same for the "e" at the end.
# See https://en.wikipedia.org/wiki/Bencode
torrent_file_content="d10:magnet-uri${magnet_link_length}:${torrent_file_or_magnet_link}e"
# Note that rTorrent will read this torrent file, start downloading
# the file and then remove the torrent file
echo "$torrent_file_content" > "$torrent_hash.torrent"
else
cp "$torrent_file_or_magnet_link" .
fi
Можно использовать это в сценарии (давайте назовем его pass_to_rtorrent.sh
) и имейте передачу Firefox, которую файл потока или магнит связывают со сценарием:
Удостоверьтесь, что сценарий является исполняемым файлом: chmod +x pass_to_rtorrent.sh