From 1d524651cebb950ce13d6ff7d954819bd0ee674c Mon Sep 17 00:00:00 2001 From: itouakirai Date: Wed, 12 Feb 2025 19:43:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8A=A8=E6=80=81=E5=B0=81=E9=9D=A2?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E6=9F=A5=E6=89=BE=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 54 ++++++++++++++++++---------------------- utils/structs/structs.go | 6 +++++ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/main.go b/main.go index 157081f..3bb36cc 100644 --- a/main.go +++ b/main.go @@ -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 { @@ -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) @@ -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 { diff --git a/utils/structs/structs.go b/utils/structs/structs.go index 33a16df..10ebfcf 100644 --- a/utils/structs/structs.go +++ b/utils/structs/structs.go @@ -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"`