Smule API for Go.
Clean example request for the media downloader endpoint. Replace YOUR API and the media URL, then run the code.
Checking
Clean example request for the media downloader endpoint. Replace YOUR API and the media URL, then run the code.
package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/url"
)
const (
apiKey = "YOUR API"
videoURL = "URL SMULE"
endpoint = "https://senpai-bot.store/smuledl"
)
type DuetInfo struct {
Picture string `json:"picture"`
Username string `json:"username"`
Verified bool `json:"verified"`
VIP bool `json:"vip"`
}
type Result struct {
Artist string `json:"artist"`
Caption *string `json:"caption"`
Comments int `json:"comments"`
Created string `json:"created"` // ISO-8601 format, pakai string
Duet DuetInfo `json:"duet"`
Duration *int `json:"duration"` // nullable
Gifts int `json:"gifts"`
Listens int `json:"listens"`
Loves int `json:"loves"`
Mp3URL string `json:"mp3Url"`
Mp4URL string `json:"mp4Url"`
Picture string `json:"picture"`
Thumbnail string `json:"thumbnail"`
Title string `json:"title"`
Type string `json:"type"`
Username string `json:"username"`
Verified bool `json:"verified"`
VIP bool `json:"vip"`
}
type ApiResponse struct {
Code int `json:"code"`
Result Result `json:"result"`
}
func main() {
encodedVideoURL := url.QueryEscape(videoURL)
getData := fmt.Sprintf("%s?apikey=%s&url=%s", endpoint, apiKey, encodedVideoURL)
resp, err := http.Get(getData)
if err != nil {
log.Fatalf("Error making request: %v", err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Error reading response: %v", err)
}
var response ApiResponse
if err := json.Unmarshal(body, &response); err != nil {
log.Fatalf("Error parsing JSON: %v", err)
}
r := response.Result
fmt.Println("Username:", r.Username)
fmt.Println("Verified:", r.Verified)
fmt.Println("VIP:", r.VIP)
fmt.Println("Title:", r.Title)
fmt.Println("Artist:", r.Artist)
if r.Caption != nil {
fmt.Println("Caption:", *r.Caption)
} else {
fmt.Println("Caption: (null)")
}
fmt.Println("Comments:", r.Comments)
fmt.Println("Created:", r.Created)
if r.Duration != nil {
fmt.Println("Duration:", *r.Duration)
} else {
fmt.Println("Duration: (null)")
}
fmt.Println("Gifts:", r.Gifts)
fmt.Println("Listens:", r.Listens)
fmt.Println("Loves:", r.Loves)
fmt.Println("MP3 URL:", r.Mp3URL)
fmt.Println("MP4 URL:", r.Mp4URL)
fmt.Println("Picture:", r.Picture)
fmt.Println("Thumbnail:", r.Thumbnail)
fmt.Println("Type:", r.Type)
fmt.Println("\nDuet Info:")
fmt.Println("- Username:", r.Duet.Username)
fmt.Println("- Picture:", r.Duet.Picture)
fmt.Println("- Verified:", r.Duet.Verified)
fmt.Println("- VIP:", r.Duet.VIP)
}