Skip to content

Commit

Permalink
feat: add download method for sanqiu books.
Browse files Browse the repository at this point in the history
  • Loading branch information
syhily committed Nov 15, 2022
1 parent 6d4407c commit 2eacb6e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/driver/aliyun.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ func (a *aliyunDriver) Resolve(shareLink string, passcode string) ([]Share, erro
panic("TODO implement me")
}

func (a *aliyunDriver) Download(share Share) (io.ReadCloser, error) {
func (a *aliyunDriver) Download(share Share) (io.ReadCloser, int64, error) {
panic("TODO implement me")
}
2 changes: 1 addition & 1 deletion internal/driver/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type (
Resolve(shareLink string, passcode string) ([]Share, error)

// Download the given link.
Download(share Share) (io.ReadCloser, error)
Download(share Share) (io.ReadCloser, int64, error)
}
)

Expand Down
2 changes: 1 addition & 1 deletion internal/driver/lanzou.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ func (l *lanzouDriver) Resolve(shareLink string, passcode string) ([]Share, erro
panic("TODO implement me")
}

func (l *lanzouDriver) Download(share Share) (io.ReadCloser, error) {
func (l *lanzouDriver) Download(share Share) (io.ReadCloser, int64, error) {
panic("TODO implement me")
}
2 changes: 1 addition & 1 deletion internal/driver/telecom.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ func (t *telecomDriver) Resolve(shareLink string, passcode string) ([]Share, err
panic("TODO implement me")
}

func (t *telecomDriver) Download(share Share) (io.ReadCloser, error) {
func (t *telecomDriver) Download(share Share) (io.ReadCloser, int64, error) {
panic("TODO implement me")
}
10 changes: 9 additions & 1 deletion internal/fetcher/sanqiu.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,13 @@ func (s *sanqiuService) formats(id int64) (map[Format]driver.Share, error) {
}

func (s *sanqiuService) fetch(id int64, format Format, share driver.Share) (*fetch, error) {
panic("TODO implement me")
content, size, err := s.driver.Download(share)
if err != nil {
return nil, err
}

return &fetch{
content: content,
size: size,
}, nil
}

0 comments on commit 2eacb6e

Please sign in to comment.