- Implemented FetchEpisode function to retrieve episode metadata from dアニメストア. - Added /api/v1/danime GET endpoint to fetch episode details by partId. - Updated Swagger documentation for the new endpoint and response structure. - Created DanimeEpisodeResponse type for API responses. - Added tests for the new functionality and handlers.
38 lines
610 B
Go
38 lines
610 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"watch-party-backend/internal/danime"
|
|
)
|
|
|
|
func main() {
|
|
flag.Usage = func() {
|
|
fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s <partId>\n", os.Args[0])
|
|
flag.PrintDefaults()
|
|
}
|
|
flag.Parse()
|
|
|
|
if flag.NArg() != 1 {
|
|
flag.Usage()
|
|
os.Exit(1)
|
|
}
|
|
partID := flag.Arg(0)
|
|
|
|
ep, err := danime.FetchEpisode(context.Background(), partID)
|
|
if err != nil {
|
|
log.Fatalf("fetch failed: %v", err)
|
|
}
|
|
|
|
buf, err := json.MarshalIndent(ep, "", " ")
|
|
if err != nil {
|
|
log.Fatalf("marshal failed: %v", err)
|
|
}
|
|
fmt.Println(string(buf))
|
|
}
|