-
Notifications
You must be signed in to change notification settings - Fork 6
/
bloom
executable file
·120 lines (96 loc) · 2.8 KB
/
bloom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/sh
# first choice is curl(1), should be OK for Linux
if command -v curl >/dev/null 2>&1; then
__download () {
curl -sL "$1"
}
# second is fetch(1), for FreeBSD
elif command -v fetch >/dev/null 2>&1; then
__download () {
fetch -q -o - "$1"
}
# last comes ftp(1), which does far more than its name implies (OpenBSD only)
elif [ "$(uname -s)" = OpenBSD ] && command -v ftp >/dev/null 2>&1; then
__download () {
ftp -o - "$1"
}
else
printf '%s\n' "Oh no! You don't seem to have curl(1) or fetch(1)" >&2
printf '%s\n' "I'm cowardly exiting" >&2
exit 4
fi
# We find magnet links
__magnet () {
__download "$1" | grep -Eo 'magnet:\?[^"<> ]+'
}
# We find absolute torrent links
__abs_torrent () {
__download "$1" | grep -Eo 'href="?[^"]+\.torrent' | grep -Eo '[^"=]+\.torrent'
}
__root_torrent () {
_domain="$(printf '%s\n' "$1" | grep -Eo 'https?://[^/]+')"
__download "$1" |
grep -Eo 'href="?[^"]+\.torrent' |
grep -Eo '[^"=]+\.torrent' |
while read -r _root_link; do
printf '%s/%s\n' "$_domain" "$_root_link"
done
}
# We find relative links to the torrents and generate an absolute link
__rel_torrent () {
_page="$1"
__download "$_page" | grep -Eo 'href="?[^"]+\.torrent' |
grep -Eo '[^"=]+\.torrent' |
while read -r _rel_link; do
printf '%s%s\n' "$_page" "$_rel_link"
done
unset _page _rel_link
}
# Archlinux
__magnet 'https://www.archlinux.org/download/'
# Debian
for _arch in amd64 i386 ; do
# Installation media
for _medium in 'cd' 'dvd'; do
__rel_torrent "https://cdimage.debian.org/debian-cd/current/$_arch/bt-$_medium/"
done
# Live CD
__rel_torrent "https://cdimage.debian.org/debian-cd/current-live/$_arch/bt-hybrid/"
done
# devuan
__magnet "https://www.devuan.org/get-devuan"
# Ubuntu
__abs_torrent 'https://ubuntu.com/download/alternative-downloads'
# openSUSE
# Doesn't provide torrents anymore!
# Linux Mint
# It's not trivial to get a page with the latest torrents
# Fedora
# Doesn't seem to provide torrents..?
# Elementary
__magnet 'https://elementary.io'
# CentOS
# It's not trivial to get a page with the latest torrents
# ReactOS
# Uses sourceforge to distribute its isos
# Kali
# https://www.kali.org/downloads/ forces gzip encoding. I'm not dealing with
# this crap. Learn how to configure your webserver.
# KDE Neon
# Doesn't seem to provide torrents..?
# Mageia
__magnet "http://www.mageia.org/en/downloads/alternative/"
# tails
__rel_torrent 'https://tails.boum.org/torrents/files/'
# FreeBSD
__magnet "https://wiki.freebsd.org/Torrents"
# Solus
__abs_torrent "https://getsol.us/download/"
# Parrot
for _version in security home; do
__abs_torrent "https://parrotsec.org/${_version}-edition/"
done
# lubuntu
__abs_torrent "https://lubuntu.me/downloads/"
# slackware
__root_torrent "http://www.slackware.com/getslack/torrents.php"