Skip to content

Commit

Permalink
Merge pull request #51 from itouakirai/main
Browse files Browse the repository at this point in the history
fix: 动态封面质量查找出错
  • Loading branch information
zhaarey authored Feb 12, 2025
2 parents 53044d8 + 1d52465 commit 1e9cc05
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
54 changes: 24 additions & 30 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,28 +869,6 @@ func rip(albumId string, token string, storefront string, mediaUserToken string,
if Config.SaveAnimatedArtwork && meta.Data[0].Attributes.EditorialVideo.MotionDetailSquare.Video != "" {
fmt.Println("Found Animation Artwork.")

// Download tall version
motionvideoUrlTall, err := extractVideo(meta.Data[0].Attributes.EditorialVideo.MotionDetailTall.Video)
if err != nil {
fmt.Println("no motion video tall.\n", err)
} else {
exists, err := fileExists(filepath.Join(sanAlbumFolder, "animated_artwork_tall.mp4"))
if err != nil {
fmt.Println("Failed to check if animated artwork tall exists.")
}
if exists {
fmt.Println("Animated artwork tall already exists locally.")
} else {
fmt.Println("Animation Artwork Tall Downloading...")
cmd := exec.Command("ffmpeg", "-loglevel", "quiet", "-y", "-i", motionvideoUrlTall, "-c", "copy", filepath.Join(sanAlbumFolder, "animated_artwork_tall.mp4"))
if err := cmd.Run(); err != nil {
fmt.Printf("animated artwork tall dl err: %v\n", err)
} else {
fmt.Println("Animation Artwork Tall Downloaded")
}
}
}

// Download square version
motionvideoUrlSquare, err := extractVideo(meta.Data[0].Attributes.EditorialVideo.MotionDetailSquare.Video)
if err != nil {
Expand All @@ -914,18 +892,34 @@ func rip(albumId string, token string, storefront string, mediaUserToken string,
}

if Config.EmbyAnimatedArtwork {
// Convert tall version to gif
cmd2 := exec.Command("ffmpeg", "-i", filepath.Join(sanAlbumFolder, "animated_artwork_tall.mp4"), "-vf", "scale=440:-1", "-r", "24", "-f", "gif", filepath.Join(sanAlbumFolder, "folder_tall.jpg"))
if err := cmd2.Run(); err != nil {
fmt.Printf("animated artwork tall to gif err: %v\n", err)
}

// Convert square version to gif
cmd3 := exec.Command("ffmpeg", "-i", filepath.Join(sanAlbumFolder, "animated_artwork_square.mp4"), "-vf", "scale=440:-1", "-r", "24", "-f", "gif", filepath.Join(sanAlbumFolder, "folder_square.jpg"))
cmd3 := exec.Command("ffmpeg", "-i", filepath.Join(sanAlbumFolder, "animated_artwork_square.mp4"), "-vf", "scale=440:-1", "-r", "24", "-f", "gif", filepath.Join(sanAlbumFolder, "folder.jpg"))
if err := cmd3.Run(); err != nil {
fmt.Printf("animated artwork square to gif err: %v\n", err)
}
}

// Download tall version
motionvideoUrlTall, err := extractVideo(meta.Data[0].Attributes.EditorialVideo.MotionDetailTall.Video)
if err != nil {
fmt.Println("no motion video tall.\n", err)
} else {
exists, err := fileExists(filepath.Join(sanAlbumFolder, "animated_artwork_tall.mp4"))
if err != nil {
fmt.Println("Failed to check if animated artwork tall exists.")
}
if exists {
fmt.Println("Animated artwork tall already exists locally.")
} else {
fmt.Println("Animation Artwork Tall Downloading...")
cmd := exec.Command("ffmpeg", "-loglevel", "quiet", "-y", "-i", motionvideoUrlTall, "-c", "copy", filepath.Join(sanAlbumFolder, "animated_artwork_tall.mp4"))
if err := cmd.Run(); err != nil {
fmt.Printf("animated artwork tall dl err: %v\n", err)
} else {
fmt.Println("Animation Artwork Tall Downloaded")
}
}
}
}
trackTotal := len(meta.Data[0].Relationships.Tracks.Data)
arr := make([]int, trackTotal)
Expand Down Expand Up @@ -1931,7 +1925,7 @@ func extractVideo(c string) (string, error) {

video := from.(*m3u8.MasterPlaylist)

re := regexp.MustCompile(`_(\d+)x(\d+)_`)
re := regexp.MustCompile(`_(\d+)x(\d+)`)

var streamUrl *url.URL
sort.Slice(video.Variants, func(i, j int) bool {
Expand Down
6 changes: 6 additions & 0 deletions utils/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ type AutoGenerated struct {
} `json:"playParams"`
IsCompilation bool `json:"isCompilation"`
EditorialVideo struct {
MotionTall struct {
Video string `json:"video"`
} `json:"motionTallVideo3x4"`
MotionSquare struct {
Video string `json:"video"`
} `json:"motionSquareVideo1x1"`
MotionDetailTall struct {
Video string `json:"video"`
} `json:"motionDetailTall"`
Expand Down

0 comments on commit 1e9cc05

Please sign in to comment.