add .torrent link support

This commit is contained in:
bel
2020-12-14 22:06:11 -07:00
parent 262aba9633
commit f884f743c9
3 changed files with 15 additions and 3 deletions

View File

@@ -180,8 +180,16 @@ func handle(vpntor, outdir, content string) error {
}
func findMagnets(s string) []string {
magnetRegexp := regexp.MustCompile(`magnet:.xt[^ $"]*`)
return magnetRegexp.FindAllString(s, -1)
patterns := []string{
`magnet:.xt[^ $"]*`,
`https:..[^"]*\.torrent`,
}
matches := []string{}
for _, pattern := range patterns {
magnetRegexp := regexp.MustCompile(pattern)
matches = append(matches, magnetRegexp.FindAllString(s, -1)...)
}
return matches
}
func submit(vpntor, outdir, magnet string) (*http.Response, error) {