look for magenets in link too
parent
3de97bf7e8
commit
84170b443d
|
|
@ -119,7 +119,7 @@ func pull(db storage.DB, vpntor, outdir, url string) error {
|
||||||
if item.Author == nil {
|
if item.Author == nil {
|
||||||
item.Author = &gofeed.Person{Name: "."}
|
item.Author = &gofeed.Person{Name: "."}
|
||||||
}
|
}
|
||||||
if err := handle(vpntor, path.Join(outdir, item.Author.Name), s); err != nil {
|
if err := handle(vpntor, path.Join(outdir, item.Author.Name), item.Link, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := db.Set(item.Link, []byte{}); err != nil {
|
if err := db.Set(item.Link, []byte{}); err != nil {
|
||||||
|
|
@ -166,9 +166,9 @@ func isDone(db storage.DB, url string) (bool, error) {
|
||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func handle(vpntor, outdir, content string) error {
|
func handle(vpntor, outdir, link, content string) error {
|
||||||
log.Printf("magnets: %v", findMagnets(content))
|
log.Printf("magnets: %v", append(findMagnets(content), findMagnets(link)...))
|
||||||
for _, magnet := range findMagnets(content) {
|
for _, magnet := range append(findMagnets(content), findMagnets(link)...) {
|
||||||
resp, err := submit(vpntor, outdir, magnet)
|
resp, err := submit(vpntor, outdir, magnet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,10 @@ func TestFindMagnets(t *testing.T) {
|
||||||
s: `here is a link https://my.domain/a.b/c.torrent, and another <a href="https://my.domain/a/b/c.torrent"></a>`,
|
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,
|
l: 2,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
s: `https://my.domain/a.b/c.torrent`,
|
||||||
|
l: 1,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, c := range cases {
|
for i, c := range cases {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue