@@ -19,6 +19,8 @@ import (
1919 "golang.org/x/net/html"
2020)
2121
22+ const defaultAniTitle = "unknown"
23+
2224func init () {
2325 resolvers .Resolvers .Register ("hanime1.me" , New ())
2426}
@@ -42,6 +44,9 @@ func (re *resolver) Resolve(u string, opt *resolvers.Option) ([]*resolvers.HAnim
4244 return nil , fmt .Errorf ("get anime info from %q: %w" , u , err )
4345 }
4446
47+ if title == defaultAniTitle {
48+ log .Warn ("failed to get anime title" )
49+ }
4550 log .Infof ("Anime found: %s, Searching episodes, Please wait a moment..." , title )
4651
4752 res := make ([]* resolvers.HAnime , 0 )
@@ -106,10 +111,16 @@ func getAniInfo(u string) (string, []string, error) {
106111 }
107112
108113 series := util .FindTagByNameAttrs (doc , "div" , true , []html.Attribute {{Key : "id" , Val : "video-playlist-wrapper" }})
114+ if len (series ) == 0 {
115+ return "" , nil , fmt .Errorf ("get series info from %q error" , u )
116+ }
109117 seriesTag := series [0 ]
110118
119+ title := defaultAniTitle
111120 titleTag := util .FindTagByNameAttrs (seriesTag , "h4" , false , nil )
112- title := titleTag [0 ].FirstChild .Data
121+ if len (titleTag ) > 0 {
122+ title = titleTag [0 ].FirstChild .Data
123+ }
113124
114125 return title , getSeriesLinks (seriesTag ), nil
115126}
@@ -163,9 +174,14 @@ func getDLInfo(vid string) (map[string]*resolvers.Video, []string, error) {
163174 aTags := util .FindTagByNameAttrs (tables [0 ], "a" , false , nil )
164175 for _ , a := range aTags {
165176 link := util .GetAttrVal (a , "href" )
166- id := getID (link )
167- quality := strings .Split (id , "-" )[1 ]
168177 title := util .GetAttrVal (a , "download" )
178+
179+ id := getID (link )
180+ quality := ""
181+ if tmp := strings .Split (id , "-" ); len (tmp ) > 1 { // the video id may not contain quality
182+ quality = tmp [1 ]
183+ }
184+
169185 size , ext , err := getVideoInfo (link )
170186 if err != nil {
171187 return nil , nil , err
0 commit comments