wild.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. package search
  2. import (
  3. "bytes"
  4. "fmt"
  5. "regexp"
  6. "strconv"
  7. "strings"
  8. v1 "go-common/app/service/main/archive/api"
  9. xtime "go-common/library/time"
  10. )
  11. // default .
  12. const (
  13. GotoBangumi = "bangumi"
  14. GotoAv = "av"
  15. GotoWeb = "web"
  16. GotoMovie = "movie"
  17. GotoBangumiWeb = "bangumi_web"
  18. GotoSp = "sp"
  19. GotoLive = "live"
  20. GotoGame = "game"
  21. GotoAuthor = "author"
  22. GotoClip = "clip"
  23. GotoAlbum = "album"
  24. GotoArticle = "article"
  25. GotoAudio = "audio"
  26. GotoSpecial = "special"
  27. GotoBanner = "banner"
  28. GotoSpecialS = "special_s"
  29. GotoConverge = "converge"
  30. GotoPGC = "pgc"
  31. GotoChannel = "channel"
  32. GotoEP = "ep"
  33. GotoTwitter = "twitter"
  34. CoverIng = "即将上映"
  35. CoverPay = "付费观看"
  36. CoverFree = "免费观看"
  37. CoverVipFree = "付费观看"
  38. CoverVipOnly = "专享"
  39. CoverVipFirst = "抢先"
  40. )
  41. // UserSearch user search request .
  42. type UserSearch struct {
  43. SearchType string `form:"search_type" validate:"required"`
  44. Order string `form:"order"`
  45. Category int `form:"category"`
  46. Platform string `form:"platform"`
  47. Build string `form:"build"`
  48. MobiAPP string `form:"mobi_app"`
  49. Device string `form:"device"`
  50. Keyword string `form:"keyword" validate:"required"`
  51. Page int `form:"page" validate:"required,min=1"`
  52. Pagesize int `form:"pagesize"`
  53. UserType int `form:"user_type"`
  54. Highlight int `form:"highlight"`
  55. OrderSort int `form:"order_sort"`
  56. FromSource string `form:"from_source"`
  57. Buvid string `form:"buvid"`
  58. Duration int `form:"duration"` // 视频时长
  59. // 传递参数,给到dao用
  60. SeasonNum int `form:"season_num"`
  61. MovieNum int `form:"movie_num"`
  62. RID int `form:"rid"`
  63. MID int64 `form:"mid"`
  64. }
  65. // User struct res .
  66. type User struct {
  67. Type string `json:"type"`
  68. Mid int64 `json:"mid,omitempty"`
  69. Name string `json:"uname,omitempty"`
  70. Usign string `json:"usign,omitempty"`
  71. Fans int `json:"fans,omitempty"`
  72. Videos int `json:"videos,omitempty"`
  73. Pic string `json:"upic,omitempty"`
  74. VerifyInfo string `json:"verify_info"`
  75. Level int `json:"level,omitempty"`
  76. Gender int `json:"gender"`
  77. IsUpuser int `json:"is_upuser,omitempty"`
  78. IsLive int `json:"is_live,omitempty"`
  79. RoomID int64 `json:"room_id,omitempty"`
  80. Res []*struct {
  81. Aid int64 `json:"aid,omitempty"`
  82. Title string `json:"title,omitempty"`
  83. Pubdate int64 `json:"pubdate,omitempty"`
  84. ArcURL string `json:"arcurl,omitempty"`
  85. Pic string `json:"pic,omitempty"`
  86. Play interface{} `json:"play,omitempty"`
  87. Danmaku int `json:"dm,omitempty"`
  88. Coin int `json:"coin"`
  89. Fav int `json:"fav"`
  90. Desc string `json:"desc"`
  91. Duration string `json:"duration,omitempty"`
  92. } `json:"res,omitempty"`
  93. OfficialVerify *OfficialVerify `json:"official_verify,omitempty"`
  94. *ResultResponse
  95. }
  96. // OfficialVerify struct .
  97. type OfficialVerify struct {
  98. Type int `json:"type"`
  99. Desc string `json:"desc,omitempty"`
  100. }
  101. // Search all .
  102. type Search struct {
  103. Code int `json:"code,omitempty"`
  104. Trackid string `json:"seid,omitempty"`
  105. Page int `json:"page,omitempty"`
  106. PageSize int `json:"pagesize,omitempty"`
  107. Total int `json:"total,omitempty"`
  108. NumResults int `json:"numResults,omitempty"`
  109. NumPages int `json:"numPages,omitempty"`
  110. SuggestKeyword string `json:"suggest_keyword,omitempty"`
  111. Attribute int32 `json:"exp_bits,omitempty"`
  112. PageInfo struct {
  113. Bangumi *Page `json:"bangumi,omitempty"`
  114. UpUser *Page `json:"upuser,omitempty"`
  115. BiliUser *Page `json:"bili_user,omitempty"`
  116. User *Page `json:"user,omitempty"`
  117. Movie *Page `json:"movie,omitempty"`
  118. Film *Page `json:"pgc,omitempty"`
  119. MediaBangumi *Page `json:"media_bangumi,omitempty"`
  120. MediaFt *Page `json:"media_ft,omitempty"`
  121. } `json:"pageinfo,omitempty"`
  122. Result struct {
  123. Bangumi []*Bangumi `json:"bangumi,omitempty"`
  124. UpUser []*User `json:"upuser,omitempty"`
  125. BiliUser []*User `json:"bili_user,omitempty"`
  126. User []*User `json:"user,omitempty"`
  127. Movie []*Movie `json:"movie,omitempty"`
  128. Video []*Video `json:"video,omitempty"`
  129. MediaBangumi []*Media `json:"media_bangumi,omitempty"`
  130. MediaFt []*Media `json:"media_ft,omitempty"`
  131. } `json:"result,omitempty"`
  132. }
  133. // Media struct .
  134. type Media struct {
  135. MediaID int64 `json:"media_id,omitempty"`
  136. SeasonID int64 `json:"season_id,omitempty"`
  137. Title string `json:"title,omitempty"`
  138. OrgTitle string `json:"org_title,omitempty"`
  139. Styles string `json:"styles,omitempty"`
  140. Cover string `json:"cover,omitempty"`
  141. PlayState int `json:"play_state,omitempty"`
  142. MediaScore *struct {
  143. Score float64 `json:"score,omitempty"`
  144. UserCount int `json:"user_count,omitempty"`
  145. } `json:"media_score,omitempty"`
  146. MediaType int `json:"media_type,omitempty"`
  147. CV string `json:"cv,omitempty"`
  148. Staff string `json:"staff,omitempty"`
  149. Areas string `json:"areas,omitempty"`
  150. GotoURL string `json:"goto_url,omitempty"`
  151. Pubtime xtime.Time `json:"pubtime,omitempty"`
  152. HitColumns []string `json:"hit_columns,omitempty"`
  153. }
  154. // Movie struct .
  155. type Movie struct {
  156. Title string `json:"title"`
  157. SpID string `json:"spid"`
  158. Type string `json:"type"`
  159. Aid int64 `json:"aid"`
  160. Desc string `json:"description"`
  161. Actors string `json:"actors"`
  162. Staff string `json:"staff"`
  163. Cover string `json:"cover"`
  164. Pic string `json:"pic"`
  165. ScreenDate string `json:"screenDate"`
  166. Area string `json:"area"`
  167. Status int `json:"status"`
  168. Length int `json:"length"`
  169. Pages int `json:"numPages"`
  170. }
  171. // Video struct .
  172. type Video struct {
  173. ID int64 `json:"id"`
  174. Author string `json:"author"`
  175. Title string `json:"title"`
  176. Pic string `json:"pic"`
  177. Desc string `json:"description"`
  178. Play interface{} `json:"play"`
  179. Danmaku int `json:"video_review"`
  180. Duration string `json:"duration"`
  181. Pages int `json:"numPages"`
  182. ViewType string `json:"view_type"`
  183. RecTags []string `json:"rec_tags"`
  184. }
  185. // ResultAll struct .
  186. type ResultAll struct {
  187. Trackid string `json:"trackid,omitempty"`
  188. Page int `json:"page,omitempty"`
  189. NavInfo []*NavInfo `json:"nav,omitempty"`
  190. Items ResultItems `json:"items,omitempty"`
  191. Item []*Item `json:"item,omitempty"` // 混排的数据(未用到)
  192. Attribute int32 `json:"attribute"` // 实验中开关
  193. }
  194. // ResultItems struct .
  195. type ResultItems struct {
  196. Season2 []*Item `json:"season2,omitempty"`
  197. Season []*Item `json:"season,omitempty"` // 老数据字段(未用到)
  198. Upper []*Item `json:"upper,omitempty"`
  199. Movie2 []*Item `json:"movie2,omitempty"`
  200. Movie []*Item `json:"movie,omitempty"` // 老数据字段(未用到)
  201. Archive []*Item `json:"archive,omitempty"`
  202. }
  203. // NavInfo struct .
  204. type NavInfo struct {
  205. Name string `json:"name"`
  206. Total int `json:"total"`
  207. Pages int `json:"pages"`
  208. Type int `json:"type"`
  209. Show int `json:"show_more,omitempty"`
  210. }
  211. // Item struct .
  212. type Item struct {
  213. TrackID string `json:"trackid,omitempty"`
  214. LinkType string `json:"linktype,omitempty"`
  215. Position int `json:"position,omitempty"`
  216. SuggestKeyword string `json:"suggest_keyword,omitempty"`
  217. Title string `json:"title,omitempty"`
  218. Name string `json:"name,omitempty"`
  219. Cover string `json:"cover,omitempty"`
  220. URI string `json:"uri,omitempty"`
  221. Param string `json:"param,omitempty"`
  222. Goto string `json:"goto,omitempty"`
  223. // av
  224. Play int `json:"play,omitempty"`
  225. Danmaku int `json:"danmaku,omitempty"`
  226. Author string `json:"author,omitempty"`
  227. ViewType string `json:"view_type,omitempty"`
  228. PTime xtime.Time `json:"ptime,omitempty"`
  229. RecTags []string `json:"rec_tags,omitempty"`
  230. // media bangumi and mdeia ft
  231. Prompt string `json:"prompt,omitempty"`
  232. Episodes []*Item `json:"episodes,omitempty"`
  233. Label string `json:"label,omitempty"`
  234. // bangumi season
  235. Finish int8 `json:"finish,omitempty"`
  236. Started int8 `json:"started,omitempty"`
  237. Index string `json:"index,omitempty"`
  238. NewestCat string `json:"newest_cat,omitempty"`
  239. NewestSeason string `json:"newest_season,omitempty"`
  240. CatDesc string `json:"cat_desc,omitempty"`
  241. TotalCount int `json:"total_count,omitempty"`
  242. MediaType int `json:"media_type,omitempty"`
  243. PlayState int `json:"play_state,omitempty"`
  244. Style string `json:"style,omitempty"`
  245. CV string `json:"cv,omitempty"`
  246. Rating float64 `json:"rating,omitempty"`
  247. Vote int `json:"vote,omitempty"`
  248. RatingCount int `json:"rating_count,omitempty"`
  249. BadgeType int `json:"badge_type,omitempty"`
  250. // upper
  251. Sign string `json:"sign,omitempty"`
  252. Fans int `json:"fans,omitempty"`
  253. Level int `json:"level,omitempty"`
  254. Desc string `json:"desc,omitempty"`
  255. OfficialVerify *OfficialVerify `json:"official_verify,omitempty"`
  256. AvItems []*Item `json:"av_items,omitempty"`
  257. Item []*Item `json:"item,omitempty"`
  258. CTime int64 `json:"ctime,omitempty"`
  259. IsUp bool `json:"is_up,omitempty"`
  260. LiveURI string `json:"live_uri,omitempty"`
  261. // movie
  262. ScreenDate string `json:"screen_date,omitempty"`
  263. Area string `json:"area,omitempty"`
  264. CoverMark string `json:"cover_mark,omitempty"`
  265. // user
  266. Face string `json:"face,omitempty"`
  267. // arc and sp
  268. Arcs int `json:"archives,omitempty"`
  269. // arc and movie
  270. Duration string `json:"duration,omitempty"`
  271. DurationInt int64 `json:"duration_int,omitempty"`
  272. Actors string `json:"actors,omitempty"`
  273. Staff string `json:"staff,omitempty"`
  274. Length int `json:"length,omitempty"`
  275. Status int `json:"status,omitempty"`
  276. }
  277. // Bangumi struct .
  278. type Bangumi struct {
  279. Name string `json:"name,omitempty"`
  280. SeasonID int `json:"season_id,omitempty"`
  281. Title string `json:"title,omitempty"`
  282. Cover string `json:"cover,omitempty"`
  283. Evaluate string `json:"evaluate,omitempty"`
  284. NewestEpID int `json:"newest_ep_id,omitempty"`
  285. NewestEpIndex string `json:"newest_ep_index,omitempty"`
  286. IsFinish int `json:"is_finish,omitempty"`
  287. IsStarted int `json:"is_started,omitempty"`
  288. NewestCat string `json:"newest_cat,omitempty"`
  289. NewestSeason string `json:"newest_season,omitempty"`
  290. TotalCount int `json:"total_count,omitempty"`
  291. Pages int `json:"numPages,omitempty"`
  292. CatList *struct {
  293. TV int `json:"tv"`
  294. Movie int `json:"movie"`
  295. Ova int `json:"ova"`
  296. } `json:"catlist,omitempty"`
  297. }
  298. // TypeSearch struct .
  299. type TypeSearch struct {
  300. TrackID string `json:"trackid"`
  301. Pages int `json:"pages"`
  302. Total int `json:"total"`
  303. Items []*Item `json:"items,omitempty"`
  304. }
  305. // Card for bangumi .
  306. type Card struct {
  307. SeasonID int64 `json:"season_id"`
  308. IsFollow int `json:"is_follow"`
  309. IsSelection int `json:"is_selection"`
  310. Badge string `json:"badge"`
  311. BadgeType int `json:"badge_type"`
  312. Episodes []*Episode `json:"episodes"`
  313. }
  314. // Episode for bangumi card .
  315. type Episode struct {
  316. ID int64 `json:"id"`
  317. Badge string `json:"badge"`
  318. BadgeType int `json:"badge_type"`
  319. Status int `json:"status"`
  320. Cover string `json:"cover"`
  321. Index string `json:"index"`
  322. IndexTitle string `json:"index_title"`
  323. }
  324. // StatusMark cover status mark .
  325. func StatusMark(status int) string {
  326. if status == 0 {
  327. return CoverIng
  328. } else if status == 1 {
  329. return CoverPay
  330. } else if status == 2 {
  331. return CoverFree
  332. } else if status == 3 {
  333. return CoverVipFree
  334. } else if status == 4 {
  335. return CoverVipOnly
  336. } else if status == 5 {
  337. return CoverVipFirst
  338. }
  339. return ""
  340. }
  341. // FillURI deal app schema .
  342. func FillURI(gt, param string, f func(uri string) string) (uri string) {
  343. switch gt {
  344. case GotoAv, "":
  345. uri = "bilibili://video/" + param
  346. case GotoLive:
  347. uri = "bilibili://live/" + param
  348. case GotoBangumi:
  349. uri = "bilibili://bangumi/season/" + param
  350. case GotoBangumiWeb:
  351. uri = "http://bangumi.bilibili.com/anime/" + param
  352. case GotoGame:
  353. uri = "bilibili://game_center/detail?id=" + param + "&sourceType=adPut"
  354. case GotoSp:
  355. uri = "bilibili://splist/" + param
  356. case GotoAuthor:
  357. uri = "bilibili://author/" + param
  358. case GotoClip:
  359. uri = "bilibili://clip/" + param
  360. case GotoAlbum:
  361. uri = "bilibili://album/" + param
  362. case GotoArticle:
  363. uri = "bilibili://article/" + param
  364. case GotoWeb:
  365. uri = param
  366. case GotoPGC:
  367. uri = "https://www.bilibili.com/bangumi/play/ss" + param
  368. case GotoChannel:
  369. uri = "bilibili://pegasus/channel/" + param + "/"
  370. case GotoEP:
  371. uri = "https://www.bilibili.com/bangumi/play/ep" + param
  372. case GotoTwitter:
  373. uri = "bilibili://pictureshow/detail/" + param
  374. }
  375. if f != nil {
  376. uri = f(uri)
  377. }
  378. return
  379. }
  380. // search const
  381. var getHightLight = regexp.MustCompile(`<em.*?em>`)
  382. var (
  383. // AvHandler .
  384. AvHandler = func(a *v1.Arc) func(uri string) string {
  385. return func(uri string) string {
  386. if a == nil {
  387. return uri
  388. }
  389. if a.Dimension.Height != 0 || a.Dimension.Width != 0 {
  390. return fmt.Sprintf("%s?player_width=%d&player_height=%d&player_rotate=%d", uri, a.Dimension.Width, a.Dimension.Height, a.Dimension.Rotate)
  391. }
  392. return uri
  393. }
  394. }
  395. )
  396. // FromSeason .
  397. func (i *Item) FromSeason(b *Bangumi, bangumi string) {
  398. i.Title = b.Title
  399. i.Cover = b.Cover
  400. i.Goto = GotoBangumi
  401. i.Param = strconv.Itoa(int(b.SeasonID))
  402. i.URI = FillURI(bangumi, i.Param, nil)
  403. i.Finish = int8(b.IsFinish)
  404. i.Started = int8(b.IsStarted)
  405. i.Index = b.NewestEpIndex
  406. i.NewestCat = b.NewestCat
  407. i.NewestSeason = b.NewestSeason
  408. i.TotalCount = b.TotalCount
  409. var buf bytes.Buffer
  410. if b.CatList.TV != 0 {
  411. buf.WriteString(`TV(`)
  412. buf.WriteString(strconv.Itoa(b.CatList.TV))
  413. buf.WriteString(`) `)
  414. }
  415. if b.CatList.Movie != 0 {
  416. buf.WriteString(`剧场版(`)
  417. buf.WriteString(strconv.Itoa(b.CatList.Movie))
  418. buf.WriteString(`) `)
  419. }
  420. if b.CatList.Ova != 0 {
  421. buf.WriteString(`OVA/OAD/SP(`)
  422. buf.WriteString(strconv.Itoa(b.CatList.Ova))
  423. buf.WriteString(`)`)
  424. }
  425. i.CatDesc = buf.String()
  426. }
  427. // FromUpUser form func .
  428. func (i *Item) FromUpUser(u *User, as map[int64]*v1.Arc) {
  429. i.Title = u.Name
  430. i.Cover = u.Pic
  431. i.Goto = GotoAuthor
  432. i.OfficialVerify = u.OfficialVerify
  433. i.Param = strconv.Itoa(int(u.Mid))
  434. i.URI = FillURI(i.Goto, i.Param, nil)
  435. i.Sign = u.Usign
  436. i.Fans = u.Fans
  437. i.Level = u.Level
  438. i.Arcs = u.Videos
  439. i.AvItems = make([]*Item, 0, len(u.Res))
  440. for _, v := range u.Res {
  441. vi := &Item{}
  442. vi.Title = v.Title
  443. vi.Cover = v.Pic
  444. vi.Goto = GotoAv
  445. vi.Param = strconv.Itoa(int(v.Aid))
  446. a, ok := as[v.Aid]
  447. if ok {
  448. vi.Play = int(a.Stat.View)
  449. vi.Danmaku = int(a.Stat.Danmaku)
  450. } else {
  451. switch play := v.Play.(type) {
  452. case float64:
  453. vi.Play = int(play)
  454. case string:
  455. vi.Play, _ = strconv.Atoi(play)
  456. }
  457. vi.Danmaku = v.Danmaku
  458. }
  459. vi.CTime = v.Pubdate
  460. vi.Duration = v.Duration
  461. i.AvItems = append(i.AvItems, vi)
  462. }
  463. }
  464. // FromUser form func .
  465. func (i *Item) FromUser(u *User, as map[int64]*v1.Arc) {
  466. i.Title = u.Name
  467. i.Cover = u.Pic
  468. i.Goto = GotoAuthor
  469. i.OfficialVerify = u.OfficialVerify
  470. i.Param = strconv.Itoa(int(u.Mid))
  471. i.URI = FillURI(i.Goto, i.Param, nil)
  472. i.Sign = u.Usign
  473. i.Fans = u.Fans
  474. i.Level = u.Level
  475. i.Arcs = u.Videos
  476. i.AvItems = make([]*Item, 0, len(u.Res))
  477. if u.IsUpuser == 1 {
  478. for _, v := range u.Res {
  479. vi := &Item{}
  480. vi.Title = v.Title
  481. vi.Cover = v.Pic
  482. vi.Goto = GotoAv
  483. vi.Param = strconv.Itoa(int(v.Aid))
  484. a, ok := as[v.Aid]
  485. if ok {
  486. vi.Play = int(a.Stat.View)
  487. vi.Danmaku = int(a.Stat.Danmaku)
  488. } else {
  489. switch play := v.Play.(type) {
  490. case float64:
  491. vi.Play = int(play)
  492. case string:
  493. vi.Play, _ = strconv.Atoi(play)
  494. }
  495. vi.Danmaku = v.Danmaku
  496. }
  497. vi.CTime = v.Pubdate
  498. vi.Duration = v.Duration
  499. i.AvItems = append(i.AvItems, vi)
  500. }
  501. i.IsUp = true
  502. }
  503. }
  504. // FromMovie form func .
  505. func (i *Item) FromMovie(m *Movie, as map[int64]*v1.Arc) {
  506. i.Title = m.Title
  507. i.Desc = m.Desc
  508. if m.Type == "movie" {
  509. i.Cover = m.Cover
  510. i.Param = strconv.Itoa(int(m.Aid))
  511. i.Goto = GotoAv
  512. i.URI = FillURI(i.Goto, i.Param, AvHandler(as[m.Aid]))
  513. i.CoverMark = StatusMark(m.Status)
  514. } else if m.Type == "special" {
  515. i.Param = m.SpID
  516. i.Goto = GotoSp
  517. i.URI = FillURI(i.Goto, i.Param, nil)
  518. i.Cover = m.Pic
  519. }
  520. i.Staff = m.Staff
  521. i.Actors = m.Actors
  522. i.Area = m.Area
  523. i.Length = m.Length
  524. i.Status = m.Status
  525. i.ScreenDate = m.ScreenDate
  526. }
  527. // FromVideo form func .
  528. func (i *Item) FromVideo(v *Video, a *v1.Arc) {
  529. i.Title = v.Title
  530. i.Cover = v.Pic
  531. i.Author = v.Author
  532. i.Param = strconv.Itoa(int(v.ID))
  533. i.Goto = GotoAv
  534. if a != nil {
  535. i.Face = a.Author.Face
  536. i.URI = FillURI(i.Goto, i.Param, AvHandler(a))
  537. i.Play = int(a.Stat.View)
  538. i.Danmaku = int(a.Stat.Danmaku)
  539. } else {
  540. i.URI = FillURI(i.Goto, i.Param, nil)
  541. switch play := v.Play.(type) {
  542. case float64:
  543. i.Play = int(play)
  544. case string:
  545. i.Play, _ = strconv.Atoi(play)
  546. }
  547. i.Danmaku = v.Danmaku
  548. }
  549. i.Desc = v.Desc
  550. i.Duration = v.Duration
  551. i.ViewType = v.ViewType
  552. i.RecTags = v.RecTags
  553. }
  554. // FromMedia form func .
  555. func (i *Item) FromMedia(m *Media, prompt string, gt string, bangumis map[string]*Card) {
  556. i.Title = m.Title
  557. if i.Title == "" {
  558. i.Title = m.OrgTitle
  559. }
  560. i.Cover = m.Cover
  561. i.Goto = gt
  562. i.Param = strconv.Itoa(int(m.SeasonID))
  563. i.URI = m.GotoURL
  564. i.MediaType = m.MediaType
  565. i.PlayState = m.PlayState
  566. i.Style = m.Styles
  567. i.CV = m.CV
  568. i.Staff = m.Staff
  569. if m.MediaScore != nil {
  570. i.Rating = m.MediaScore.Score
  571. i.Vote = m.MediaScore.UserCount
  572. }
  573. i.PTime = m.Pubtime
  574. areas := strings.Split(m.Areas, "、")
  575. if len(areas) != 0 {
  576. i.Area = areas[0]
  577. }
  578. i.Prompt = prompt
  579. var hit string
  580. for _, v := range m.HitColumns {
  581. if v == "cv" {
  582. hit = v
  583. break
  584. } else if v == "staff" {
  585. hit = v
  586. }
  587. }
  588. if hit == "cv" {
  589. for _, v := range getHightLight.FindAllStringSubmatch(m.CV, -1) {
  590. if gt == GotoBangumi {
  591. i.Label = fmt.Sprintf("声优: %v...", v[0])
  592. break
  593. } else if gt == GotoMovie {
  594. i.Label = fmt.Sprintf("演员: %v...", v[0])
  595. break
  596. }
  597. }
  598. } else if hit == "staff" {
  599. for _, v := range getHightLight.FindAllStringSubmatch(m.Staff, -1) {
  600. i.Label = fmt.Sprintf("制作人员: %v...", v[0])
  601. break
  602. }
  603. }
  604. // get from PGC API .
  605. ssID := strconv.Itoa(int(m.SeasonID))
  606. if bgm, ok := bangumis[ssID]; ok {
  607. for _, v := range bgm.Episodes {
  608. tmp := &Item{
  609. Param: strconv.Itoa(int(v.ID)),
  610. Index: v.Index,
  611. BadgeType: v.BadgeType,
  612. }
  613. tmp.URI = FillURI(GotoEP, tmp.Param, nil)
  614. i.Episodes = append(i.Episodes, tmp)
  615. }
  616. }
  617. }