Skip to content

Commit

Permalink
feat: Add thunderExpert priority video url switch
Browse files Browse the repository at this point in the history
  • Loading branch information
foxxorcat committed Sep 15, 2022
1 parent e3b213c commit 0d012f8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
11 changes: 11 additions & 0 deletions drivers/thunder/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func (x *ThunderExpert) Init(ctx context.Context, storage model.Storage) (err er
PackageName: x.PackageName,
UserAgent: x.UserAgent,
DownloadUserAgent: x.DownloadUserAgent,
UseVideoUrl: x.UseVideoUrl,
},
}

Expand Down Expand Up @@ -209,6 +210,7 @@ func (x *ThunderExpert) Init(ctx context.Context, storage model.Storage) (err er
}
x.XunLeiCommon.UserAgent = x.UserAgent
x.XunLeiCommon.DownloadUserAgent = x.DownloadUserAgent
x.XunLeiCommon.UseVideoUrl = x.UseVideoUrl
}
return nil
}
Expand Down Expand Up @@ -252,6 +254,15 @@ func (xc *XunLeiCommon) Link(ctx context.Context, file model.Obj, args model.Lin
},
}

if xc.UseVideoUrl {
for _, media := range lFile.Medias {
if media.Link.URL != "" {
link.URL = media.Link.URL
break
}
}
}

/*
strs := regexp.MustCompile(`e=([0-9]*)`).FindStringSubmatch(lFile.WebContentLink)
if len(strs) == 2 {
Expand Down
3 changes: 3 additions & 0 deletions drivers/thunder/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type ExpertAddition struct {
//不影响登录,影响下载速度
UserAgent string `json:"user_agent" required:"true" default:"ANDROID-com.xunlei.downloadprovider/7.51.0.8196 netWorkType/4G appid/40 deviceName/Xiaomi_M2004j7ac deviceModel/M2004J7AC OSVersion/12 protocolVersion/301 platformVersion/10 sdkVersion/220200 Oauth2Client/0.9 (Linux 4_14_186-perf-gdcf98eab238b) (JAVA 0)"`
DownloadUserAgent string `json:"download_user_agent" required:"true" default:"Dalvik/2.1.0 (Linux; U; Android 12; M2004J7AC Build/SP1A.210812.016)"`

//优先使用视频链接代替下载链接
UseVideoUrl bool `json:"use_video_url"`
}

// 登录特征,用于判断是否重新登录
Expand Down
39 changes: 23 additions & 16 deletions drivers/thunder/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ type FileList struct {
VersionOutdated bool `json:"version_outdated"`
}

type Link struct {
URL string `json:"url"`
Token string `json:"token"`
Expire time.Time `json:"expire"`
Type string `json:"type"`
}

type Files struct {
Kind string `json:"kind"`
ID string `json:"id"`
Expand All @@ -95,26 +102,26 @@ type Files struct {
ThumbnailLink string `json:"thumbnail_link"`
//Md5Checksum string `json:"md5_checksum"`
//Hash string `json:"hash"`
//Links struct{} `json:"links"`
Phase string `json:"phase"`
Links map[string]Link `json:"links"`
Phase string `json:"phase"`
Audit struct {
Status string `json:"status"`
Message string `json:"message"`
Title string `json:"title"`
} `json:"audit"`
/* Medias []struct {
Category string `json:"category"`
IconLink string `json:"icon_link"`
IsDefault bool `json:"is_default"`
IsOrigin bool `json:"is_origin"`
IsVisible bool `json:"is_visible"`
//Link interface{} `json:"link"`
MediaID string `json:"media_id"`
MediaName string `json:"media_name"`
NeedMoreQuota bool `json:"need_more_quota"`
Priority int `json:"priority"`
RedirectLink string `json:"redirect_link"`
ResolutionName string `json:"resolution_name"`
Medias []struct {
Category string `json:"category"`
IconLink string `json:"icon_link"`
IsDefault bool `json:"is_default"`
IsOrigin bool `json:"is_origin"`
IsVisible bool `json:"is_visible"`
Link Link `json:"link"`
MediaID string `json:"media_id"`
MediaName string `json:"media_name"`
NeedMoreQuota bool `json:"need_more_quota"`
Priority int `json:"priority"`
RedirectLink string `json:"redirect_link"`
ResolutionName string `json:"resolution_name"`
Video struct {
AudioCodec string `json:"audio_codec"`
BitRate int `json:"bit_rate"`
Expand All @@ -126,7 +133,7 @@ type Files struct {
Width int `json:"width"`
} `json:"video"`
VipTypes []string `json:"vip_types"`
} `json:"medias"` */
} `json:"medias"`
Trashed bool `json:"trashed"`
DeleteTime string `json:"delete_time"`
OriginalURL string `json:"original_url"`
Expand Down
1 change: 1 addition & 0 deletions drivers/thunder/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Common struct {
PackageName string
UserAgent string
DownloadUserAgent string
UseVideoUrl bool
}

func (c *Common) SetCaptchaToken(captchaToken string) {
Expand Down

0 comments on commit 0d012f8

Please sign in to comment.