diff --git a/handlers/torrent/main.go b/handlers/torrent/main.go index 24ab8e2..5bde835 100755 --- a/handlers/torrent/main.go +++ b/handlers/torrent/main.go @@ -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) { diff --git a/handlers/torrent/main_test.go b/handlers/torrent/main_test.go index 3e8464f..6cdb530 100755 --- a/handlers/torrent/main_test.go +++ b/handlers/torrent/main_test.go @@ -239,6 +239,10 @@ func TestFindMagnets(t *testing.T) { s: `here is some magnet:-xt1 and magnet:-xt2 another one link`, l: 3, }, + { + s: `here is a link https://my.domain/a.b/c.torrent, and another `, + l: 2, + }, } for i, c := range cases { diff --git a/testdata/add b/testdata/add index 418c1de..4cf260e 100755 --- a/testdata/add +++ b/testdata/add @@ -47,7 +47,7 @@ https://xkcd.com/atom.xml https://eztv.ag/ezrss.xml?g=g torrent","news "^([Ll]ast..eek..onight..ith..ohn..liver.*WEB)" "" "2h" LastWeekTonight https://eztv.ag/ezrss.xml?h=h torrent "^([Rr]ick.[Aa]nd.[Mm]orty)" "" "2h" RickAndMorty https://matrix.org/blog/feed news ".*" ".*" "1h" -https://nyaa.si/?page=rss&f=0&c=0_0&q=erai+shingeki+no+kyojin+final+season+720p anime","torrent ".*" ".*" "1h" Anime-ShingekiNoKyojin +https://nyaa.si/?page=rss&f=0&c=0_0&q=shingeki+no+kyojin+final+season+720p anime","torrent ".*" ".*" "1h" Anime-ShingekiNoKyojin ' #https://eztv.ag/ezrss.xml momma","torrent "^(Wheel.[oO]f.Fortune.[S2]|Jeopardy.20|Gold.Rush.*720.*WEB|Survivor.S.*720p|Gold.Rush.*S.*E.*720.*WEB|Archer|[Mm]aster[cC]hef.US.*720p.WEB|[Mm]aster[cC]hef.Aus.*|[tT]he.[pP]rice.[iI]s.[rR]ight|[lL]et.*[mM]ake.[aA].[dD]eal|The.Handmaids.Tale.*720.*WEB|[Ss]urvivor.*[AaSs][UuAa]|Australian.Ninja.Warrior.*HDTV)" "" "2h" feedsB="$(printf "%s\n" "$feeds" | grep -v '^$' | tail -n 1)"