скрытый текст
Если в будущем кто захочет обновить - скачайте mp3 из подкаст фида, если будет недоступен - запустите этот Go код (go run main.go - скачает в текущую папку, пропустив файлы которые уже есть):
Код:
package mainimport (
"errors"
"fmt"
"io"
"net/http"
"os"
"regexp"
"strings"
)func main() { r, err := regexp.Compile(`sound="(\S+\/(\S+)\.mp3)" peid="\S+" sname="(.+?)"`)
if err != nil {
fmt.Println("ERRPR regexp.Compile()")
return
} // File from
https://www.playpodcast.net/podcast/the-english-we-speak
// Scroll that JS will fetch the full list and save from the browser devtools
// Do you know another source? Looks like an official page with all episodes (from 2010) is not exists
b, err := os.ReadFile("../html.html")
if err != nil {
fmt.Println("ERRPR reading HTML file")
return
} submatches := r.FindAllStringSubmatch(string(b), -1) client := http.Client{} for _, submatch := range submatches {
url, filename, title := submatch[1], submatch[2], submatch[3]
title = strings.ReplaceAll(title, "/", "slash") + ".mp3"
filename = filename + "_" + title f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0666)
if errors.Is(err, os.ErrExist) {
fmt.Println("------------ Already exists", filename)
continue
}
if err != nil {
fmt.Println("ERROR creating the file", filename)
return
} resp, err := client.Get(url)
if err != nil {
fmt.Println("ERRPR downloading the file", url)
return
} _, err = io.Copy(f, resp.Body)
if err != nil {
fmt.Println("ERROR saving the file", filename)
return
} fmt.Println("Downloaded", filename) resp.Body.Close()
}
}