@@ -107,9 +107,9 @@ func (b Book) String() string {
107
107
}
108
108
109
109
func (tale * TaleBook ) Request (req * http.Request ) (* http.Response , error ) {
110
- return tale .retryReuquest (req , 0 )
110
+ return tale .tryRequest (req , 0 )
111
111
}
112
- func (tale * TaleBook ) retryReuquest (req * http.Request , count int ) (* http.Response , error ) {
112
+ func (tale * TaleBook ) tryRequest (req * http.Request , count int ) (* http.Response , error ) {
113
113
if tale .userAgent != "" {
114
114
req .Header .Set ("User-Agent" , tale .userAgent )
115
115
}
@@ -122,7 +122,7 @@ func (tale *TaleBook) retryReuquest(req *http.Request, count int) (*http.Respons
122
122
return nil , err
123
123
}
124
124
log .Printf ("timeout , retry %s://%s%s [%d/%d]" , req .URL .Scheme , req .Host , req .URL .Path , count + 1 , tale .retry )
125
- return tale .retryReuquest (req , count + 1 )
125
+ return tale .tryRequest (req , count + 1 )
126
126
}
127
127
return response , err
128
128
}
@@ -160,7 +160,16 @@ func (tale *TaleBook) Next() (*Book, error) {
160
160
161
161
func (tale * TaleBook ) Download (b * Book , dir string ) error {
162
162
for _ , file := range b .Book .Files {
163
- downloadURL := urlJoin (tale .api , file .Href )
163
+ var downloadURL string
164
+ if strings .HasPrefix (file .Href , "https://" ) || strings .HasPrefix (file .Href , "http://" ) {
165
+ downloadURL = file .Href
166
+ } else {
167
+ downloadURL = urlJoin (tale .api , file .Href )
168
+ }
169
+ if tale .verbose {
170
+ log .Printf ("download %s" , downloadURL )
171
+ }
172
+
164
173
req , err := http .NewRequest (http .MethodGet , downloadURL , nil )
165
174
if err != nil {
166
175
return err
0 commit comments