model.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package model
  2. // Playurl is http://git.bilibili.co/video/playurl_doc/blob/master/PlayurlV2%E6%8E%A5%E5%8F%A3%E6%96%87%E6%A1%A3.md
  3. type Playurl struct {
  4. From string `json:"from"`
  5. Result string `json:"result"`
  6. Quality int64 `json:"quality"`
  7. Format string `json:"format"`
  8. Timelength int64 `json:"timelength"`
  9. AcceptFormat string `json:"accept_format"`
  10. AcceptDescription []string `json:"accept_description,omitempty"`
  11. AcceptQuality []int64 `json:"accept_quality"`
  12. VideoCodecid int `json:"video_codecid"`
  13. Fnver int `json:"fnver"`
  14. Fnval int `json:"fnval"`
  15. VideoProject bool `json:"video_project"`
  16. SeekParam string `json:"seek_param"`
  17. SeekType string `json:"seek_type"`
  18. Abtid int `json:"abtid,omitempty"`
  19. Durl []*Durl `json:"durl,omitempty"`
  20. Dash *Dash `json:"dash,omitempty"`
  21. }
  22. // FormatDash dash 驼峰 -> 下划线
  23. func (p *Playurl) FormatDash() {
  24. if p.Dash != nil {
  25. var as, vs []*DashItem
  26. for _, a := range p.Dash.Audio {
  27. as = append(as, &DashItem{
  28. ID: a.ID,
  29. BaseURL: a.BaseURLRes,
  30. BackupURL: a.BackupURLRes,
  31. Bandwidth: a.Bandwidth,
  32. Codecid: a.Codecid,
  33. })
  34. }
  35. for _, v := range p.Dash.Video {
  36. vs = append(vs, &DashItem{
  37. ID: v.ID,
  38. BaseURL: v.BaseURLRes,
  39. BackupURL: v.BackupURLRes,
  40. Bandwidth: v.Bandwidth,
  41. Codecid: v.Codecid,
  42. })
  43. }
  44. p.Dash.Audio = as
  45. p.Dash.Video = vs
  46. }
  47. }
  48. // Durl is
  49. type Durl struct {
  50. Order int `json:"order"`
  51. Length int64 `json:"length"`
  52. Size int64 `json:"size"`
  53. AHead string `json:"ahead,omitempty"`
  54. VHead string `json:"vhead,omitempty"`
  55. URL string `json:"url"`
  56. BackupURL []string `json:"backup_url,omitempty"`
  57. }
  58. //Param is
  59. type Param struct {
  60. AID int64 `form:"aid"`
  61. CID int64 `form:"cid"`
  62. Qn int64 `form:"qn"`
  63. Npcybs int `form:"npcybs"`
  64. Otype string `form:"otype"`
  65. MobiApp string `form:"mobi_app"`
  66. Fnver int `form:"fnver"`
  67. Fnval int `form:"fnval"`
  68. Session string `form:"session"`
  69. Build int `form:"build"`
  70. Device string `form:"device"`
  71. ForceHost int `form:"force_host"`
  72. }
  73. // Dash is
  74. type Dash struct {
  75. Video []*DashItem `json:"video"`
  76. Audio []*DashItem `json:"audio"`
  77. }
  78. // DashItem is
  79. type DashItem struct {
  80. ID int64 `json:"id"`
  81. BaseURL string `json:"base_url"`
  82. BackupURL []string `json:"backup_url,omitempty"`
  83. BaseURLRes string `json:"baseUrl,omitempty"`
  84. BackupURLRes []string `json:"backupUrl,omitempty"`
  85. Bandwidth int64 `json:"bandwidth"`
  86. Codecid int64 `json:"codecid"`
  87. }