Compare commits
No commits in common. "main" and "1.0.0" have entirely different histories.
@ -7,7 +7,7 @@ tmp_dir = "tmp"
|
||||
bin = "./tmp/main"
|
||||
cmd = "go build -o ./tmp/main ."
|
||||
delay = 1000
|
||||
exclude_dir = ["assets", "tmp", "vendor", "testdata", "ui"]
|
||||
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
|
||||
exclude_file = []
|
||||
exclude_regex = ["_test.go"]
|
||||
exclude_unchanged = false
|
||||
|
@ -1,7 +1,6 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"rul.sh/go-ytmp3/utils"
|
||||
@ -76,10 +75,6 @@ func InitTaskScheduler() *TaskScheduler {
|
||||
Album: task.Album,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
task.IsPending = false
|
||||
task.Error = err
|
||||
task.Result = result
|
||||
|
@ -18,11 +18,8 @@ import (
|
||||
"rul.sh/go-ytmp3/utils"
|
||||
)
|
||||
|
||||
func fetchAudio(video *goutubedl.Result, out string, ch chan error) {
|
||||
dl, err := video.DownloadWithOptions(context.Background(), goutubedl.DownloadOptions{
|
||||
DownloadAudioOnly: true,
|
||||
AudioFormats: "best",
|
||||
})
|
||||
func fetchVideo(video *goutubedl.Result, out string, ch chan error) {
|
||||
dl, err := video.Download(context.Background(), "best")
|
||||
if err != nil {
|
||||
ch <- err
|
||||
return
|
||||
@ -116,7 +113,6 @@ func convertToMp3(data ConvertOptions, ch chan error) {
|
||||
input := []*ffmpeg.Stream{ffmpeg.Input(data.Video).Audio()}
|
||||
args := ffmpeg.KwArgs{
|
||||
"format": "mp3",
|
||||
"ab": "320k",
|
||||
"id3v2_version": "3",
|
||||
"write_id3v1": "1",
|
||||
"metadata": []string{
|
||||
@ -171,7 +167,7 @@ func Yt2Mp3(video *goutubedl.Result, options Yt2Mp3Options) (string, error) {
|
||||
videoSlug = slug.Make(title)
|
||||
}
|
||||
|
||||
audioSrc := fmt.Sprintf("%s/%s-src.mp3", tmpDir, videoSlug)
|
||||
videoSrc := fmt.Sprintf("%s/%s.mp4", tmpDir, videoSlug)
|
||||
thumbnail := fmt.Sprintf("%s/%s.jpg", tmpDir, videoSlug)
|
||||
out := fmt.Sprintf("%s/%s.mp3", options.OutDir, videoSlug)
|
||||
|
||||
@ -182,7 +178,7 @@ func Yt2Mp3(video *goutubedl.Result, options Yt2Mp3Options) (string, error) {
|
||||
videoCh := make(chan error)
|
||||
thumbCh := make(chan error)
|
||||
|
||||
go fetchAudio(video, audioSrc, videoCh)
|
||||
go fetchVideo(video, videoSrc, videoCh)
|
||||
go fetchThumbnail(video, thumbnail, thumbCh)
|
||||
|
||||
err := <-videoCh
|
||||
@ -200,7 +196,7 @@ func Yt2Mp3(video *goutubedl.Result, options Yt2Mp3Options) (string, error) {
|
||||
convertCh := make(chan error)
|
||||
|
||||
go convertToMp3(ConvertOptions{
|
||||
Video: audioSrc,
|
||||
Video: videoSrc,
|
||||
Thumbnail: thumbnail,
|
||||
Title: title,
|
||||
Artist: artist,
|
||||
|
Loading…
x
Reference in New Issue
Block a user