Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
yann0917 committed Jul 20, 2021
2 parents 742aa8e + 5e86cb8 commit d0bdc80
Show file tree
Hide file tree
Showing 7 changed files with 461 additions and 37 deletions.
54 changes: 29 additions & 25 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,34 +181,38 @@ func extractCourseDownloadData(articles *services.ArticleList, aid int) []downlo
if aid > 0 && article.ID != aid {
continue
}
audioIds[article.ID] = article.Audio.AliasID

urls := []downloader.URL{}
key := article.Enid
streams := map[string]downloader.Stream{
key: {
URLs: urls,
Size: article.Audio.Size,
Quality: key,
},
}
isCanDL := true
if len(article.Audio.AliasID) == 0 {
isCanDL = false
}
datum := &downloader.Datum{
ID: article.ID,
Enid: article.Enid,
ClassEnid: article.ClassEnid,
ClassID: article.ClassID,
Title: article.Title,
IsCanDL: isCanDL,
M3U8URL: article.Audio.Mp3PlayURL,
Streams: streams,
Type: "audio",
if article.VideoStatus == 0 {
audioIds[article.ID] = article.Audio.AliasID

var urls []downloader.URL
key := article.Enid
streams := map[string]downloader.Stream{
key: {
URLs: urls,
Size: article.Audio.Size,
Quality: key,
},
}
isCanDL := true
if len(article.Audio.AliasID) == 0 {
isCanDL = false
}
datum := &downloader.Datum{
ID: article.ID,
Enid: article.Enid,
ClassEnid: article.ClassEnid,
ClassID: article.ClassID,
Title: article.Title,
IsCanDL: isCanDL,
M3U8URL: article.Audio.Mp3PlayURL,
Streams: streams,
Type: "audio",
}

audioData = append(audioData, datum)
}

audioData = append(audioData, datum)
}

handleStreams(audioData, audioIds)
Expand Down
19 changes: 18 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,28 @@ require (
github.com/cheggaaa/pb/v3 v3.0.8
github.com/chromedp/cdproto v0.0.0-20210713064928-7d28b402946a
github.com/chromedp/chromedp v0.7.4
github.com/coreos/bbolt v1.3.2 // indirect
github.com/coreos/etcd v3.3.13+incompatible // indirect
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/go-rod/rod v0.101.4
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/json-iterator/go v1.1.11
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.1
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/olekukonko/tablewriter v0.0.5
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.1.3
github.com/prometheus/client_golang v0.9.3 // indirect
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/spf13/cobra v1.2.1
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
go.etcd.io/bbolt v1.3.2 // indirect
gopkg.in/resty.v1 v1.12.0 // indirect
)
352 changes: 352 additions & 0 deletions go.sum

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions services/article.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ type Article struct {
type ArticleIntro struct {
ArticleBase
MediaBaseInfo []MediaBaseInfo `json:"media_base_info"`
Audio Audio `json:"audio"`
Audio *Audio `json:"audio,omitempty"`
Video *[]Video `json:"video,omitempty"`
}

// ArticleBase article base info
Expand Down Expand Up @@ -99,7 +100,9 @@ type ArticleBase struct {
IsBuy bool `json:"is_buy"`
DdMediaID int `json:"dd_media_id"`
DdMediaIDStr string `json:"dd_media_id_str"`
VideoStatus int `json:"video_status"`
VideoStatus int `json:"video_status"` // 1-video
DdLiveID int `json:"dd_live_id"`
NotJoinPlan int `json:"not_join_plan"`
}

// ArticleList class article list
Expand Down
34 changes: 26 additions & 8 deletions services/course.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ type CourseList struct {

// CourseInfo product intro info
type CourseInfo struct {
ClassInfo ClassInfo `json:"class_info"`
Items []CourseIntro `json:"items"`
ArticleIntro ArticleIntro `json:"intro_article"`
ChapterList []Chapter `json:"chapter_list"`
FlatArticleList []FlatArticleList `json:"flat_article_list"`
UserType string `json:"user_type"`
HasMoreFlatArticleList bool `json:"has_more_flat_article_list"`
IsShowGrading bool `json:"is_show_grading"`
ClassInfo ClassInfo `json:"class_info"`
Items []CourseIntro `json:"items"`
ArticleIntro ArticleIntro `json:"intro_article"`
ChapterList []Chapter `json:"chapter_list"`
FlatArticleList []ArticleBase `json:"flat_article_list"`
UserType string `json:"user_type"`
HasMoreFlatArticleList bool `json:"has_more_flat_article_list"`
IsShowGrading bool `json:"is_show_grading"`
}

// ClassInfo class info
Expand Down Expand Up @@ -142,6 +142,7 @@ type ClassInfo struct {
EstimatedShelfTime int `json:"estimated_shelf_time"`
EstimatedDownTime int `json:"estimated_down_time"`
CornerImg string `json:"corner_img"`
CornerImgVertical string `json:"corner_img_vertical"`
WithoutGiving bool `json:"without_giving"`
DdURL string `json:"dd_url"`
PublishTime int `json:"publish_time"`
Expand All @@ -153,6 +154,21 @@ type ClassInfo struct {
IsCollected bool `json:"is_collected"`
CollectionCount int `json:"collection_count"`
} `json:"collection"`
FormalArticleCount int `json:"formal_article_count"`
VideoClass int `json:"video_class"`
VideoClassIntro string `json:"video_class_intro"`
ActivityIcon string `json:"activity_icon"`
ActivityTitle string `json:"activity_title"`
ActivityURL string `json:"activity_url"`
RealityExtraCount int `json:"reality_extra_count"`
RealityFormalCount int `json:"reality_formal_count"`
IntroArticleIds []int `json:"intro_article_ids"`
IsPreferential int `json:"is_preferential"`
IsCountDown int `json:"is_count_down"`
PreferentialStartTime int `json:"preferential_start_time"`
PreferentialEndTime int `json:"preferential_end_time"`
EarlyBirdPrice int `json:"early_bird_price"`
TrialCount int `json:"trial_count"`
}

// FlatArticleList flat
Expand Down Expand Up @@ -204,6 +220,8 @@ type FlatArticleList struct {
DdMediaID int `json:"dd_media_id"`
DdMediaIDStr string `json:"dd_media_id_str"`
VideoStatus int `json:"video_status"`
DdLiveID int `json:"dd_live_id"`
NotJoinPlan int `json:"not_join_plan"`
}

// CourseList get course list by page
Expand Down
26 changes: 25 additions & 1 deletion services/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package services

// MediaBaseInfo media info
type MediaBaseInfo struct {
MediaType int `json:"media_type"`
MediaType int `json:"media_type"` // 1-audio,2-video
SourceID string `json:"source_id"`
SecurityToken string `json:"security_token"`
}
Expand Down Expand Up @@ -50,6 +50,30 @@ type Audio struct {
ReaderName string `json:"reader_name"`
}

type Video struct {
Token string `json:"token"`
TokenVersion int `json:"token_version"`
CoverImg string `json:"cover_img"`
DdMediaID int64 `json:"dd_media_id"`
DdMediaIDStr string `json:"dd_media_id_str"`
Duration int `json:"duration"`
Bitrate480 string `json:"bitrate_480"`
Bitrate480Size int `json:"bitrate_480_size"`
Bitrate480Audio string `json:"bitrate_480_audio"`
Bitrate720 string `json:"bitrate_720"`
Bitrate720Size int `json:"bitrate_720_size"`
Bitrate720Audio string `json:"bitrate_720_audio"`
Bitrate1080 string `json:"bitrate_1080"`
Bitrate1080Size int `json:"bitrate_1080_size"`
Bitrate1080Audio string `json:"bitrate_1080_audio"`
IsDrm bool `json:"is_drm"`
ListenProgress int `json:"listen_progress"`
ListenFinished bool `json:"listen_finished"`
LogID string `json:"log_id"`
LogType string `json:"log_type"`
Caption string `json:"caption"`
}

// AudioList audio baseic info list
type AudioList struct {
List []Audio `json:"list"`
Expand Down
6 changes: 6 additions & 0 deletions services/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type CookieOptions struct {
GuardDeviceID string `json:"_guard_device_id" mapstructure:"_guard_device_id"`
SID string `json:"_sid" mapstructure:"_sid"`
AcwTc string `json:"acw_tc" mapstructure:"acw_tc"`
AliyungfTc string `json:"aliyungf_tc"`
CookieStr string `json:"cookieStr"`
}

Expand Down Expand Up @@ -104,6 +105,11 @@ func NewService(co *CookieOptions) *Service {
Value: co.Token,
Domain: "www." + dedaoCommURL.Host,
})
cookies = append(cookies, &http.Cookie{
Name: "aliyungf_tc",
Value: co.AliyungfTc,
Domain: "www." + dedaoCommURL.Host,
})
client.Client.Jar.SetCookies(dedaoCommURL, cookies)

return &Service{client: client}
Expand Down

0 comments on commit d0bdc80

Please sign in to comment.