Fixing badge
parent
f6c1f2d150
commit
35ad033061
15
badge.go
15
badge.go
|
@ -28,21 +28,16 @@ func badgeHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
mp3Path := filepath.Join(audioBasePath, episode+".mp3")
|
mp3Path := filepath.Join(audioBasePath, episode+".mp3")
|
||||||
imgPath := filepath.Join(imageBasePath, episode+".jpg")
|
imgPath := filepath.Join(imageBasePath, episode+".jpg")
|
||||||
|
|
||||||
// Verifica se il file MP3 esiste
|
|
||||||
if _, err := os.Stat(mp3Path); os.IsNotExist(err) {
|
|
||||||
http.Error(w, "Episode not found: "+mp3Path, http.StatusNotFound)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Costruisci gli URL completi
|
|
||||||
audioURL := siteURL + mp3Path
|
|
||||||
imageURL := siteURL + imgPath
|
|
||||||
|
|
||||||
// Verifica se l'immagine esiste, altrimenti usa quella di default
|
// Verifica se l'immagine esiste, altrimenti usa quella di default
|
||||||
|
var imageURL string
|
||||||
if _, err := os.Stat("." + imgPath); os.IsNotExist(err) {
|
if _, err := os.Stat("." + imgPath); os.IsNotExist(err) {
|
||||||
imageURL = defaultImage
|
imageURL = defaultImage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Costruisci gli URL completi
|
||||||
|
audioURL := siteURL + strings.TrimPrefix(mp3Path, "/app")
|
||||||
|
imageURL = siteURL + strings.TrimPrefix(imgPath, "/app")
|
||||||
|
|
||||||
// Genera l'HTML completo del player
|
// Genera l'HTML completo del player
|
||||||
playerHTML := fmt.Sprintf(`
|
playerHTML := fmt.Sprintf(`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
Loading…
Reference in New Issue