Skip to content

Commit

Permalink
update with tv
Browse files Browse the repository at this point in the history
  • Loading branch information
sec-an committed Dec 31, 2023
1 parent 55f56b9 commit 7401999
Show file tree
Hide file tree
Showing 21 changed files with 230 additions and 157 deletions.
7 changes: 7 additions & 0 deletions internal/common/cate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package common

type Cate struct {
Land *int `json:"land,omitempty"`
Circle *int `json:"circle,omitempty"`
Ratio *float32 `json:"ratio,omitempty"`
}
18 changes: 12 additions & 6 deletions internal/common/channel.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package common

type Channel struct {
Urls []string `json:"urls,omitempty"`
Number string `json:"number,omitempty"`
Logo string `json:"logo,omitempty"`
Epg string `json:"epg,omitempty"`
Name string `json:"name,omitempty"`
Ua string `json:"ua,omitempty"`
Urls []string `json:"urls,omitempty"`
Number string `json:"number,omitempty"`
Logo string `json:"logo,omitempty"`
Epg string `json:"epg,omitempty"`
Name string `json:"name,omitempty"`
Ua string `json:"ua,omitempty"`
Click string `json:"click,omitempty"`
Referer string `json:"referer,omitempty"`
Header interface{} `json:"header,omitempty"`
PlayerType *int `json:"playerType,omitempty"`
Parse *int `json:"parse,omitempty"`
Drm *Drm `json:"drm,omitempty"`
}
9 changes: 7 additions & 2 deletions internal/common/class.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package common

type Class struct {
TypeId string `json:"type_id,omitempty"`
TypeName string `json:"type_name,omitempty"`
TypeId string `json:"type_id,omitempty"`
TypeName string `json:"type_name,omitempty"`
TypeFlag string `json:"type_flag,omitempty"`
Filters []Filter `json:"filters,omitempty"`
Land *int `json:"land,omitempty"`
Circle *int `json:"circle,omitempty"`
Ratio *float32 `json:"ratio,omitempty"`
}
17 changes: 9 additions & 8 deletions internal/common/config.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package common

type Config struct {
Ads []string `json:"ads,omitempty"`
Flags []string `json:"flags,omitempty"`
Parses []Parse `json:"parses,omitempty"`
Sites []Site `json:"sites,omitempty"`
Ijk interface{} `json:"ijk,omitempty"`
Lives []Live `json:"lives,omitempty"`
Spider string `json:"spider,omitempty"`
Wallpaper string `json:"wallpaper,omitempty"`
Doh []Doh `json:"doh,omitempty"`
Rules []Rule `json:"rules,omitempty"`
Sites []Site `json:"sites,omitempty"`
Parses []Parse `json:"parses,omitempty"`
Flags []string `json:"flags,omitempty"`
Ads []string `json:"ads,omitempty"`
Lives []Live `json:"lives,omitempty"`
Spider string `json:"spider,omitempty"`
Wallpaper string `json:"wallpaper,omitempty"`
}
4 changes: 4 additions & 0 deletions internal/common/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ type Core struct {
Name string `json:"name,omitempty"`
Pass string `json:"pass,omitempty"`
Broker string `json:"broker,omitempty"`
Resp string `json:"resp,omitempty"`
Sign string `json:"sign,omitempty"`
Pkg string `json:"pkg,omitempty"`
So string `json:"so,omitempty"`
}
7 changes: 7 additions & 0 deletions internal/common/doh.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package common

type Doh struct {
Name string `json:"name,omitempty"`
Url string `json:"url,omitempty"`
Ips []string `json:"ips,omitempty"`
}
6 changes: 6 additions & 0 deletions internal/common/drm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package common

type Drm struct {
Key string `json:"key,omitempty"`
Type string `json:"type,omitempty"`
}
1 change: 1 addition & 0 deletions internal/common/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package common
type Filter struct {
Key string `json:"key,omitempty"`
Name string `json:"name,omitempty"`
Init string `json:"init,omitempty"`
Value []Value `json:"value,omitempty"`
}

Expand Down
1 change: 0 additions & 1 deletion internal/common/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package common

type Group struct {
Channel []Channel `json:"channel,omitempty"`
Logo string `json:"logo,omitempty"`
Name string `json:"name,omitempty"`
Pass string `json:"pass,omitempty"`
}
103 changes: 49 additions & 54 deletions internal/common/live.go
Original file line number Diff line number Diff line change
@@ -1,59 +1,54 @@
package common

import (
"TVHelper/global"
"encoding/json"
"strconv"

"go.uber.org/zap"

"github.com/spf13/cast"
)

type Live struct {
Type int `json:"type"`
Boot bool `json:"boot,omitempty"`
Name string `json:"name,omitempty"`
Group string `json:"group,omitempty"`
Url string `json:"url,omitempty"`
Logo string `json:"logo,omitempty"`
Epg string `json:"epg,omitempty"`
Ua string `json:"ua,omitempty"`
PlayerType int `json:"playerType,omitempty"`
Channels []Channel `json:"channels,omitempty"`
Groups []Group `json:"groups,omitempty"`
Core Core `json:"core,omitempty"`
Name string `json:"name,omitempty"`
Type *int `json:"type"`
Boot *bool `json:"boot,omitempty"`
Pass *bool `json:"pass,omitempty"`
Group string `json:"group,omitempty"`
Url string `json:"url,omitempty"`
Logo string `json:"logo,omitempty"`
Epg string `json:"epg,omitempty"`
Ua string `json:"ua,omitempty"`
Click string `json:"click,omitempty"`
Referer string `json:"referer,omitempty"`
Timeout *int `json:"timeout,omitempty"`
Header interface{} `json:"header,omitempty"`
PlayerType *int `json:"playerType,omitempty"`
Channels []Channel `json:"channels,omitempty"`
Groups []Group `json:"groups,omitempty"`
Core *Core `json:"core,omitempty"`
}

func (l *Live) UnmarshalJSON(data []byte) error {
type TempLive Live
lr := struct {
*TempLive
Type interface{} `json:"type"`
PlayerType interface{} `json:"playerType,omitempty"`
Boot interface{} `json:"boot,omitempty"`
}{
TempLive: (*TempLive)(l),
}
if err := json.Unmarshal(data, &lr); err != nil {
global.Logger.Error(string(data), zap.Error(err))
}
l.Type = cast.ToInt(lr.Type)
l.PlayerType = cast.ToInt(lr.PlayerType)
switch lr.Boot.(type) {
case bool:
l.Boot = lr.Boot.(bool)
case string:
boolValue, err := strconv.ParseBool(lr.Boot.(string))
if err != nil {
global.Logger.Error(lr.Boot.(string), zap.Error(err))
}
l.Boot = boolValue
default:
l.Boot = false
if cast.ToInt(lr.Boot) > 0 {
l.Boot = true
}
}
return nil
}
//func (l *Live) UnmarshalJSON(data []byte) error {
// type TempLive Live
// lr := struct {
// *TempLive
// Type interface{} `json:"type"`
// PlayerType interface{} `json:"playerType,omitempty"`
// Boot interface{} `json:"boot,omitempty"`
// }{
// TempLive: (*TempLive)(l),
// }
// if err := json.Unmarshal(data, &lr); err != nil {
// global.Logger.Error(string(data), zap.Error(err))
// }
// l.Type = cast.ToInt(lr.Type)
// l.PlayerType = cast.ToInt(lr.PlayerType)
// switch lr.Boot.(type) {
// case bool:
// l.Boot = lr.Boot.(bool)
// case string:
// boolValue, err := strconv.ParseBool(lr.Boot.(string))
// if err != nil {
// global.Logger.Error(lr.Boot.(string), zap.Error(err))
// }
// l.Boot = boolValue
// default:
// l.Boot = false
// if cast.ToInt(lr.Boot) > 0 {
// l.Boot = true
// }
// }
// return nil
//}
40 changes: 16 additions & 24 deletions internal/common/parse.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
package common

import (
"TVHelper/global"
"encoding/json"

"github.com/spf13/cast"
"go.uber.org/zap"
)

type Parse struct {
Name string `json:"name,omitempty"`
Type int `json:"type,omitempty"`
Type *int `json:"type,omitempty"`
Url string `json:"url,omitempty"`
Ext Ext `json:"ext,omitempty"`
Ext *Ext `json:"ext,omitempty"`
}

type Ext struct {
Flag []string `json:"flag,omitempty"`
Header interface{} `json:"header,omitempty"`
}

func (p *Parse) UnmarshalJSON(data []byte) error {
type TempParse Parse
pr := struct {
*TempParse
Type interface{} `json:"type,omitempty"`
}{
TempParse: (*TempParse)(p),
}
if err := json.Unmarshal(data, &pr); err != nil {
global.Logger.Error(string(data), zap.Error(err))
}
p.Type = cast.ToInt(pr.Type)
return nil
}
//func (p *Parse) UnmarshalJSON(data []byte) error {
// type TempParse Parse
// pr := struct {
// *TempParse
// Type interface{} `json:"type,omitempty"`
// }{
// TempParse: (*TempParse)(p),
// }
// if err := json.Unmarshal(data, &pr); err != nil {
// global.Logger.Error(string(data), zap.Error(err))
// }
// p.Type = cast.ToInt(pr.Type)
// return nil
//}
16 changes: 15 additions & 1 deletion internal/common/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,23 @@ type Result struct {
PageCount int `json:"pagecount,omitempty"`
Limit int `json:"limit,omitempty"`
Total int `json:"total,omitempty"`
List []Vod `json:"list,omitempty"`
Parse *int `json:"parse,omitempty"`
Code *int `json:"code,omitempty"`
Jx *int `json:"jx,omitempty"`
Class []Class `json:"class,omitempty"`
List []Vod `json:"list,omitempty"`
Filters map[string][]Filter `json:"filters,omitempty"`
Url interface{} `json:"url,omitempty"`
Msg interface{} `json:"msg,omitempty"`
Header interface{} `json:"header,omitempty"`
PlayUrl string `json:"playUrl,omitempty"`
JxFrom string `json:"jxFrom,omitempty"`
Flag string `json:"flag,omitempty"`
Danmaku string `json:"danmaku,omitempty"`
Format string `json:"format,omitempty"`
Click string `json:"click,omitempty"`
Key string `json:"key,omitempty"`
Subs []Sub `json:"subs,omitempty"`
}

func (r *Result) UnmarshalJSON(data []byte) error {
Expand Down
8 changes: 8 additions & 0 deletions internal/common/rule.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package common

type Rule struct {
Name string `json:"name,omitempty"`
Hosts []string `json:"hosts,omitempty"`
Regex []string `json:"regex,omitempty"`
Script []string `json:"script,omitempty"`
}
83 changes: 41 additions & 42 deletions internal/common/site.go
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
package common

import (
"TVHelper/global"
"encoding/json"

"github.com/spf13/cast"
"go.uber.org/zap"
)

type Site struct {
Key string `json:"key,omitempty"`
Name string `json:"name,omitempty"`
Type int `json:"type,omitempty"`
Api string `json:"api,omitempty"`
PlayUrl string `json:"playUrl,omitempty"`
PlayerType int `json:"playerType,omitempty"`
Searchable int `json:"searchable,omitempty"`
Filterable int `json:"filterable,omitempty"`
Changeable int `json:"changeable,omitempty"`
Ext string `json:"ext,omitempty"`
Jar string `json:"jar,omitempty"`
Categories []string `json:"categories,omitempty"`
Key string `json:"key,omitempty"`
Name string `json:"name,omitempty"`
Api string `json:"api,omitempty"`
Ext interface{} `json:"ext,omitempty"`
Jar string `json:"jar,omitempty"`
Click string `json:"click,omitempty"`
PlayUrl string `json:"playUrl,omitempty"`
Type *int `json:"type,omitempty"`
Timeout *int `json:"timeout,omitempty"`
PlayerType *int `json:"playerType,omitempty"`
Searchable *int `json:"searchable,omitempty"`
Changeable *int `json:"changeable,omitempty"`
Recordable *int `json:"recordable,omitempty"`
Categories []string `json:"categories,omitempty"`
Header interface{} `json:"header,omitempty"`
Style *Style `json:"style,omitempty"`
ViewType interface{} `json:"viewType,omitempty"`
}

func (s *Site) UnmarshalJSON(data []byte) error {
type TempSite Site
sr := struct {
*TempSite
Type interface{} `json:"type,omitempty"`
PlayerType interface{} `json:"playerType,omitempty"`
Searchable interface{} `json:"searchable,omitempty"`
Filterable interface{} `json:"filterable,omitempty"`
Changeable interface{} `json:"changeable,omitempty"`
}{
TempSite: (*TempSite)(s),
}
if err := json.Unmarshal(data, &sr); err != nil {
global.Logger.Error(string(data), zap.Error(err))
}
s.Type = cast.ToInt(sr.Type)
s.PlayerType = cast.ToInt(sr.PlayerType)
s.Searchable = cast.ToInt(sr.Searchable)
s.Filterable = cast.ToInt(sr.Filterable)
s.Changeable = cast.ToInt(sr.Changeable)
return nil
}
//func (s *Site) UnmarshalJSON(data []byte) error {
// type TempSite Site
// sr := struct {
// *TempSite
// Type interface{} `json:"type,omitempty"`
// Timeout interface{} `json:"timeout,omitempty"`
// PlayerType interface{} `json:"playerType,omitempty"`
// Searchable interface{} `json:"searchable,omitempty"`
// Changeable interface{} `json:"changeable,omitempty"`
// Recordable interface{} `json:"recordable,omitempty"`
// }{
// TempSite: (*TempSite)(s),
// }
// if err := json.Unmarshal(data, &sr); err != nil {
// global.Logger.Error(string(data), zap.Error(err))
// }
// s.Type = cast.ToInt(sr.Type)
// s.Timeout = cast.ToInt(sr.Timeout)
// s.PlayerType = cast.ToInt(sr.PlayerType)
// s.Searchable = cast.ToInt(sr.Searchable)
// s.Changeable = cast.ToInt(sr.Changeable)
// s.Recordable = cast.ToInt(sr.Recordable)
// return nil
//}
6 changes: 6 additions & 0 deletions internal/common/style.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package common

type Style struct {
Type string `json:"type,omitempty"`
Ratio *float32 `json:"ratio,omitempty"`
}
Loading

0 comments on commit 7401999

Please sign in to comment.