3362899493662ae8295521bc8fa8eccec79c7550
- Author
- Ryan Neufeld <ryan@neufeldmail.com>
- Committer
- Ryan Neufeld <ryan@neufeldmail.com>
- Date
Message
Adding torrent tools plugin.
Only one tool exists right now, that is to convert a magnetlink into a
torrent file.
Diff
1diff --git a/plugins/torrent/torrent.plugin.zsh b/plugins/torrent/torrent.plugin.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..656e337de241d34a28b9575249fd530192dcd3a0
4--- /dev/null
5+++ b/plugins/torrent/torrent.plugin.zsh
6@@ -0,0 +1,17 @@
7+#
8+# Algorithm borrowed from http://wiki.rtorrent.org/MagnetUri and adapted to work with zsh.
9+#
10+
11+function magnet_to_torrent() {
12+ [[ "$1" =~ xt=urn:btih:([^\&/]+) ]] || return 1
13+
14+ hashh=${match[1]}
15+
16+ if [[ "$1" =~ dn=([^\&/]+) ]];then
17+ filename=${match[1]}
18+ else
19+ filename=$hashh
20+ fi
21+
22+ echo "d10:magnet-uri${#1}:${1}e" > "$filename.torrent"
23+}