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