diff options
| author | Nathan Perry <avaglir@gmail.com> | 2017-07-28 22:13:56 -0400 |
|---|---|---|
| committer | Nathan Perry <avaglir@gmail.com> | 2017-07-28 22:13:56 -0400 |
| commit | 85d19683f6619150ff949822e1bb118472241d13 (patch) | |
| tree | 806ca6b689c1ca4e39430685c37939d9ea5a20ad /downloader/downloader.go | |
| parent | f48248693839d803490ef92fc5ba89e25024ab96 (diff) | |
downloadmanager working
Diffstat (limited to 'downloader/downloader.go')
| -rw-r--r-- | downloader/downloader.go | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/downloader/downloader.go b/downloader/downloader.go index 793cd22..95c022f 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -75,18 +75,11 @@ func info(inUrl string) (*videoInfo, error) { return &v, err } -func Download(inUrl string, startTime time.Duration, duration time.Duration) (<-chan []byte, error) { - vInfo, err := info(inUrl) - if err != nil { - return nil, err - } - +func (d *DownloadManager) download(startTime, duration time.Duration) (<-chan []byte, error) { startSecond := int(startTime.Seconds()) - dur := int(duration.Seconds()) - args := []string{ "-ss", strconv.Itoa(startSecond), - "-i", vInfo.Url.String(), + "-i", d.info.Url.String(), "-c:a", "pcm_s16le", "-f", "wav", "-ar", "48000", @@ -94,7 +87,8 @@ func Download(inUrl string, startTime time.Duration, duration time.Duration) (<- "-vn", "-y", } - if dur > 0 { + dur := int(duration.Seconds()) + if dur > 0 && startTime+duration < d.info.Duration { args = append(args, "-t", strconv.Itoa(dur)) } |
