sped-up download by spawning 1 less yt-dlp process
This commit is contained in:
@@ -36,6 +36,7 @@ type DownloadInfo struct {
|
|||||||
ACodec string `json:"acodec"`
|
ACodec string `json:"acodec"`
|
||||||
Extension string `json:"ext"`
|
Extension string `json:"ext"`
|
||||||
OriginalURL string `json:"original_url"`
|
OriginalURL string `json:"original_url"`
|
||||||
|
FileName string `json:"filename"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,9 +82,6 @@ func (p *Process) Start() {
|
|||||||
|
|
||||||
buildFilename(&p.Output)
|
buildFilename(&p.Output)
|
||||||
|
|
||||||
//TODO: it spawn another one yt-dlp process, too slow.
|
|
||||||
go p.GetFileName(&out)
|
|
||||||
|
|
||||||
baseParams := []string{
|
baseParams := []string{
|
||||||
strings.Split(p.Url, "?list")[0], //no playlist
|
strings.Split(p.Url, "?list")[0], //no playlist
|
||||||
"--newline",
|
"--newline",
|
||||||
@@ -275,6 +272,7 @@ func (p *Process) GetFormatsSync() (DownloadFormats, error) {
|
|||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove, potentially unused
|
||||||
func (p *Process) GetFileName(o *DownloadOutput) error {
|
func (p *Process) GetFileName(o *DownloadOutput) error {
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
config.Instance().DownloaderPath,
|
config.Instance().DownloaderPath,
|
||||||
@@ -304,7 +302,12 @@ func (p *Process) SetPending() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) SetMetadata() error {
|
func (p *Process) SetMetadata() error {
|
||||||
cmd := exec.Command(config.Instance().DownloaderPath, p.Url, "-J")
|
cmd := exec.Command(
|
||||||
|
config.Instance().DownloaderPath,
|
||||||
|
p.Url,
|
||||||
|
"-J",
|
||||||
|
"-o", fmt.Sprintf("%s/%s", p.Output.Path, p.Output.Filename),
|
||||||
|
)
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||||
|
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
@@ -351,13 +354,14 @@ func (p *Process) SetMetadata() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
p.Info = info
|
|
||||||
p.Progress.Status = StatusPending
|
|
||||||
|
|
||||||
if err := cmd.Wait(); err != nil {
|
if err := cmd.Wait(); err != nil {
|
||||||
return errors.New(bufferedStderr.String())
|
return errors.New(bufferedStderr.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.Info = info
|
||||||
|
p.Progress.Status = StatusPending
|
||||||
|
p.Output.SavedFilePath = info.FileName
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user