下载bbc音频并发邮件 完善
This commit is contained in:
parent
21b4e3cebf
commit
f04c9d1679
|
@ -3,6 +3,7 @@ package bbclearn
|
|||
import (
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/fthvgb1/wp-go/rss2"
|
||||
"github.com/fthvgb1/wp-go/safety"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -77,10 +78,15 @@ func fetch(u string) (r rss2.Item) {
|
|||
r.PubDate = date.Format(time.RFC1123Z)
|
||||
r.Guid = u
|
||||
r.Description = content
|
||||
go downAndSendMail(dom, r.Title)
|
||||
if _, ok := hadSend.Load(r.Title); !ok {
|
||||
go downAndSendMail(dom, r.Title)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
var hadSend = safety.NewMap[string, struct{}]()
|
||||
|
||||
func downAndSendMail(doc *goquery.Document, title string) {
|
||||
type m struct {
|
||||
tit string
|
||||
|
@ -117,6 +123,7 @@ func downAndSendMail(doc *goquery.Document, title string) {
|
|||
return
|
||||
}
|
||||
mail.SendMail(mm.tit, mm.content, mm.f...)
|
||||
hadSend.Store(mm.tit, struct{}{})
|
||||
for _, s := range mm.f {
|
||||
err := os.Remove(s)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user