feat: Add thunderExpert priority video url switch

pull/1831/head
foxxorcat 2022-09-15 22:50:27 +08:00
parent e3b213c398
commit 0d012f85cb
4 changed files with 38 additions and 16 deletions

View File

@ -146,6 +146,7 @@ func (x *ThunderExpert) Init(ctx context.Context, storage model.Storage) (err er
PackageName: x.PackageName, PackageName: x.PackageName,
UserAgent: x.UserAgent, UserAgent: x.UserAgent,
DownloadUserAgent: x.DownloadUserAgent, DownloadUserAgent: x.DownloadUserAgent,
UseVideoUrl: x.UseVideoUrl,
}, },
} }
@ -209,6 +210,7 @@ func (x *ThunderExpert) Init(ctx context.Context, storage model.Storage) (err er
} }
x.XunLeiCommon.UserAgent = x.UserAgent x.XunLeiCommon.UserAgent = x.UserAgent
x.XunLeiCommon.DownloadUserAgent = x.DownloadUserAgent x.XunLeiCommon.DownloadUserAgent = x.DownloadUserAgent
x.XunLeiCommon.UseVideoUrl = x.UseVideoUrl
} }
return nil return nil
} }
@ -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) strs := regexp.MustCompile(`e=([0-9]*)`).FindStringSubmatch(lFile.WebContentLink)
if len(strs) == 2 { if len(strs) == 2 {

View File

@ -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)"` 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)"` 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"`
} }
// 登录特征,用于判断是否重新登录 // 登录特征,用于判断是否重新登录

View File

@ -77,6 +77,13 @@ type FileList struct {
VersionOutdated bool `json:"version_outdated"` 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 { type Files struct {
Kind string `json:"kind"` Kind string `json:"kind"`
ID string `json:"id"` ID string `json:"id"`
@ -95,20 +102,20 @@ type Files struct {
ThumbnailLink string `json:"thumbnail_link"` ThumbnailLink string `json:"thumbnail_link"`
//Md5Checksum string `json:"md5_checksum"` //Md5Checksum string `json:"md5_checksum"`
//Hash string `json:"hash"` //Hash string `json:"hash"`
//Links struct{} `json:"links"` Links map[string]Link `json:"links"`
Phase string `json:"phase"` Phase string `json:"phase"`
Audit struct { Audit struct {
Status string `json:"status"` Status string `json:"status"`
Message string `json:"message"` Message string `json:"message"`
Title string `json:"title"` Title string `json:"title"`
} `json:"audit"` } `json:"audit"`
/* Medias []struct { Medias []struct {
Category string `json:"category"` Category string `json:"category"`
IconLink string `json:"icon_link"` IconLink string `json:"icon_link"`
IsDefault bool `json:"is_default"` IsDefault bool `json:"is_default"`
IsOrigin bool `json:"is_origin"` IsOrigin bool `json:"is_origin"`
IsVisible bool `json:"is_visible"` IsVisible bool `json:"is_visible"`
//Link interface{} `json:"link"` Link Link `json:"link"`
MediaID string `json:"media_id"` MediaID string `json:"media_id"`
MediaName string `json:"media_name"` MediaName string `json:"media_name"`
NeedMoreQuota bool `json:"need_more_quota"` NeedMoreQuota bool `json:"need_more_quota"`
@ -126,7 +133,7 @@ type Files struct {
Width int `json:"width"` Width int `json:"width"`
} `json:"video"` } `json:"video"`
VipTypes []string `json:"vip_types"` VipTypes []string `json:"vip_types"`
} `json:"medias"` */ } `json:"medias"`
Trashed bool `json:"trashed"` Trashed bool `json:"trashed"`
DeleteTime string `json:"delete_time"` DeleteTime string `json:"delete_time"`
OriginalURL string `json:"original_url"` OriginalURL string `json:"original_url"`

View File

@ -52,6 +52,7 @@ type Common struct {
PackageName string PackageName string
UserAgent string UserAgent string
DownloadUserAgent string DownloadUserAgent string
UseVideoUrl bool
} }
func (c *Common) SetCaptchaToken(captchaToken string) { func (c *Common) SetCaptchaToken(captchaToken string) {