diff --git a/internal/downloader/downloader.go b/internal/downloader/downloader.go index dab4bcd..8ebc994 100644 --- a/internal/downloader/downloader.go +++ b/internal/downloader/downloader.go @@ -16,12 +16,14 @@ import ( type Downloader struct { selectedBook book.Book directLink string + outputFileDir string } -func NewDownloader(selectedBook book.Book, directLink string) *Downloader { +func NewDownloader(selectedBook book.Book, directLink string, outputFileDir string) *Downloader { return &Downloader{ selectedBook: selectedBook, directLink: directLink, + outputFileDir: outputFileDir, } } @@ -37,7 +39,7 @@ func (d *Downloader) Download() error { } defer resp.Body.Close() - filename := sanitize.Path(strings.Trim(d.selectedBook.Title, " ") + "." + d.selectedBook.Extension) + filename := sanitize.Path(d.outputFileDir + strings.Trim(d.selectedBook.Title, " ") + "." + d.selectedBook.Extension) f, _ := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY, 0666) defer f.Close()