@@ -40,13 +40,13 @@ func GenVideoFetcher(video *model.Video) FetchFun {
4040
4141 resp , err := client .Do (request )
4242 if err != nil {
43- log .Fatalf ("Fail to download the video %d, err is %s" , video .ParCid .Cid , err )
43+ log .Fatalf ("下载 %d 时出错, 错误信息: %s" , video .ParCid .Cid , err )
4444 return nil , err
4545 }
4646
4747 if resp .StatusCode != http .StatusPartialContent {
48- log .Fatalf ("Fail to download the video %d, status code is %d" , video .ParCid .Cid , resp .StatusCode )
49- return nil , fmt .Errorf ("wrong status code: %d" , resp .StatusCode )
48+ log .Fatalf ("下载 %d 时出错, 错误码: %d" , video .ParCid .Cid , resp .StatusCode )
49+ return nil , fmt .Errorf ("错误码: %d" , resp .StatusCode )
5050 }
5151 defer resp .Body .Close ()
5252
@@ -59,18 +59,18 @@ func GenVideoFetcher(video *model.Video) FetchFun {
5959 }
6060 defer file .Close ()
6161
62- log .Println (video .ParCid .ParAid .Title + ": " + filename + " is downloading." )
62+ log .Println ("正在下载:" + video .ParCid .ParAid .Title + "\\ " + filename )
6363 _ , err = io .Copy (file , resp .Body )
6464 if err != nil {
65- log .Printf ("Failed to download video aid: %d, cid: %d, title: %s, part: %s" ,
66- video .ParCid .ParAid .Aid , video .ParCid .Cid , video .ParCid .ParAid .Title , video .ParCid .Part )
67- log .Println ("The error message is: " , err )
65+ log .Printf ("下载失败 aid: %d, cid: %d, title: %s, part: %s" ,
66+ video .ParCid .ParAid .Aid , video .ParCid .Cid , video .ParCid .ParAid .Title , video .ParCid .Part )
67+ log .Println ("错误信息: " , err )
6868
6969 // request again
70- go requestLater (file , resp , video )
70+ go requestLater (file , resp , video )
7171 return nil , err
7272 }
73- log .Println (video .ParCid .ParAid .Title + ": " + filename + " has finished." )
73+ log .Println ("下载完成:" + video .ParCid .ParAid .Title + "\\ " + filename )
7474
7575 return nil , nil
7676 }
@@ -83,17 +83,15 @@ func genCheckRedirectfun(referer string) func(req *http.Request, via []*http.Req
8383 }
8484}
8585
86- func requestLater (file * os.File , resp * http.Response , video * model.Video ) error {
86+ func requestLater (file * os.File , resp * http.Response , video * model.Video ) error {
8787
88- log .Println ("Unable to open the file due to the remote host, request in 30 seconds. " )
89- time .Sleep (time .Second * 30 )
88+ log .Println ("连接失败,30秒后重试 ( Unable to open the file due to the remote host, request in 30 seconds) " )
89+ time .Sleep (time .Second * 30 )
9090
91- _ , err := io .Copy (file , resp .Body )
92- if err != nil {
93- log .Printf ("Failed to download video aid: %d, cid: %d, title: %s, part: %s again" ,
94- video .ParCid .ParAid .Aid , video .ParCid .Cid , video .ParCid .ParAid .Title , video .ParCid .Part )
95- }
96- return err
91+ _ , err := io .Copy (file , resp .Body )
92+ if err != nil {
93+ log .Printf ("下载失败 aid: %d, cid: %d, title: %s, part: %s again" ,
94+ video .ParCid .ParAid .Aid , video .ParCid .Cid , video .ParCid .ParAid .Title , video .ParCid .Part )
95+ }
96+ return err
9797}
98-
99-
0 commit comments