add .torrent link support
parent
262aba9633
commit
f884f743c9
|
|
@ -180,8 +180,16 @@ func handle(vpntor, outdir, content string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func findMagnets(s string) []string {
|
func findMagnets(s string) []string {
|
||||||
magnetRegexp := regexp.MustCompile(`magnet:.xt[^ $"]*`)
|
patterns := []string{
|
||||||
return magnetRegexp.FindAllString(s, -1)
|
`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) {
|
func submit(vpntor, outdir, magnet string) (*http.Response, error) {
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,10 @@ func TestFindMagnets(t *testing.T) {
|
||||||
s: `here is some magnet:-xt1 and magnet:-xt2 another one <a href="magnet:-xt3">link</a>`,
|
s: `here is some magnet:-xt1 and magnet:-xt2 another one <a href="magnet:-xt3">link</a>`,
|
||||||
l: 3,
|
l: 3,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
s: `here is a link https://my.domain/a.b/c.torrent, and another <a href="https://my.domain/a/b/c.torrent"></a>`,
|
||||||
|
l: 2,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, c := range cases {
|
for i, c := range cases {
|
||||||
|
|
|
||||||
|
|
@ -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)" "<a.*?href=.magnet:.*?</a>" "2h" LastWeekTonight
|
https://eztv.ag/ezrss.xml?g=g torrent","news "^([Ll]ast..eek..onight..ith..ohn..liver.*WEB)" "<a.*?href=.magnet:.*?</a>" "2h" LastWeekTonight
|
||||||
https://eztv.ag/ezrss.xml?h=h torrent "^([Rr]ick.[Aa]nd.[Mm]orty)" "<a.*?href=.magnet:.*?</a>" "2h" RickAndMorty
|
https://eztv.ag/ezrss.xml?h=h torrent "^([Rr]ick.[Aa]nd.[Mm]orty)" "<a.*?href=.magnet:.*?</a>" "2h" RickAndMorty
|
||||||
https://matrix.org/blog/feed news ".*" ".*" "1h"
|
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)" "<a.*?href=.magnet:.*?</a>" "2h"
|
#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)" "<a.*?href=.magnet:.*?</a>" "2h"
|
||||||
feedsB="$(printf "%s\n" "$feeds" | grep -v '^$' | tail -n 1)"
|
feedsB="$(printf "%s\n" "$feeds" | grep -v '^$' | tail -n 1)"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue