Compare commits

..

No commits in common. "main" and "1.0.0" have entirely different histories.
main ... 1.0.0

3 changed files with 6 additions and 15 deletions

View File

@ -7,7 +7,7 @@ tmp_dir = "tmp"
bin = "./tmp/main" bin = "./tmp/main"
cmd = "go build -o ./tmp/main ." cmd = "go build -o ./tmp/main ."
delay = 1000 delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata", "ui"] exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = [] exclude_file = []
exclude_regex = ["_test.go"] exclude_regex = ["_test.go"]
exclude_unchanged = false exclude_unchanged = false

View File

@ -1,7 +1,6 @@
package lib package lib
import ( import (
"fmt"
"time" "time"
"rul.sh/go-ytmp3/utils" "rul.sh/go-ytmp3/utils"
@ -76,10 +75,6 @@ func InitTaskScheduler() *TaskScheduler {
Album: task.Album, Album: task.Album,
}) })
if err != nil {
fmt.Println(err)
}
task.IsPending = false task.IsPending = false
task.Error = err task.Error = err
task.Result = result task.Result = result

View File

@ -18,11 +18,8 @@ import (
"rul.sh/go-ytmp3/utils" "rul.sh/go-ytmp3/utils"
) )
func fetchAudio(video *goutubedl.Result, out string, ch chan error) { func fetchVideo(video *goutubedl.Result, out string, ch chan error) {
dl, err := video.DownloadWithOptions(context.Background(), goutubedl.DownloadOptions{ dl, err := video.Download(context.Background(), "best")
DownloadAudioOnly: true,
AudioFormats: "best",
})
if err != nil { if err != nil {
ch <- err ch <- err
return return
@ -116,7 +113,6 @@ func convertToMp3(data ConvertOptions, ch chan error) {
input := []*ffmpeg.Stream{ffmpeg.Input(data.Video).Audio()} input := []*ffmpeg.Stream{ffmpeg.Input(data.Video).Audio()}
args := ffmpeg.KwArgs{ args := ffmpeg.KwArgs{
"format": "mp3", "format": "mp3",
"ab": "320k",
"id3v2_version": "3", "id3v2_version": "3",
"write_id3v1": "1", "write_id3v1": "1",
"metadata": []string{ "metadata": []string{
@ -171,7 +167,7 @@ func Yt2Mp3(video *goutubedl.Result, options Yt2Mp3Options) (string, error) {
videoSlug = slug.Make(title) 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) thumbnail := fmt.Sprintf("%s/%s.jpg", tmpDir, videoSlug)
out := fmt.Sprintf("%s/%s.mp3", options.OutDir, 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) videoCh := make(chan error)
thumbCh := make(chan error) thumbCh := make(chan error)
go fetchAudio(video, audioSrc, videoCh) go fetchVideo(video, videoSrc, videoCh)
go fetchThumbnail(video, thumbnail, thumbCh) go fetchThumbnail(video, thumbnail, thumbCh)
err := <-videoCh err := <-videoCh
@ -200,7 +196,7 @@ func Yt2Mp3(video *goutubedl.Result, options Yt2Mp3Options) (string, error) {
convertCh := make(chan error) convertCh := make(chan error)
go convertToMp3(ConvertOptions{ go convertToMp3(ConvertOptions{
Video: audioSrc, Video: videoSrc,
Thumbnail: thumbnail, Thumbnail: thumbnail,
Title: title, Title: title,
Artist: artist, Artist: artist,