Skip to content

Commit

Permalink
update mirros to have default outputDir
Browse files Browse the repository at this point in the history
  • Loading branch information
laureanray committed Jul 13, 2023
1 parent b59e597 commit 4a638e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions internal/mirror/current_mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ func (m *CurrentMirror) searchSite(query string) (*goquery.Document, error) {
return document, e
}

func (m *CurrentMirror) DownloadSelection(selectedBook book.Book) {
func (m *CurrentMirror) DownloadSelection(selectedBook book.Book, outputDirectory string) {
fmt.Println(console.Info("Downloading book..."))

directLink := documentparser.GetDirectDownloadLinkFromCurrent(selectedBook.Mirrors[0])
downloader.NewDownloader(selectedBook, directLink).Download()
if outputDirectory == "" {
outputDirectory = "./"
}
downloader.NewDownloader(selectedBook, directLink, outputDirectory).Download()
}
9 changes: 7 additions & 2 deletions internal/mirror/legacy_mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,13 @@ func (m *LegacyMirror) searchSite(query string) (*goquery.Document, error) {
return document, e
}

func (m *LegacyMirror) DownloadSelection(selectedBook book.Book) {
func (m *LegacyMirror) DownloadSelection(selectedBook book.Book, outputDirectory string) {
fmt.Println(console.Info("Downloading book..."))
directLink := documentparser.GetDirectDownloadLinkFromLegacy(selectedBook.Mirrors[0])
downloader.NewDownloader(selectedBook, directLink).Download()

if outputDirectory == "" {
outputDirectory = "./"
}

downloader.NewDownloader(selectedBook, directLink, outputDirectory).Download()
}
2 changes: 1 addition & 1 deletion internal/mirror/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Mirror interface {
SearchByAuthor(author string) ([]book.Book, error)
// SearchByISBN(isbn string) []book.Book
// 1GetDownloadLink(book book.Book) string
DownloadSelection(book book.Book)
DownloadSelection(book book.Book, outputDirectory string)
}

// TODO: Make this persistent
Expand Down

0 comments on commit 4a638e8

Please sign in to comment.