jaryhe 1 year ago
parent
commit
0f5bc06749
4 changed files with 128 additions and 57 deletions
  1. 19 20
      account.txt
  2. 4 8
      common.yaml
  3. 2 26
      record.txt
  4. 103 3
      student/student.go

+ 19 - 20
account.txt

@@ -1,20 +1,19 @@
-2151101400241;Ouchn@2021;颜洪
-2151101400241;Ouchn@2021;颜洪
-2151101400242;Ouchn@2021;刘强
-2151101400243;Ouchn@2021;高刚
-2151101400244;Ouchn@2021;欧阳文强
-2151101400245;Ouchn@2021;杨鹏
-2151101400246;Ouchn@2021;罗焐尹
-2151101400247;Ouchn@2021;金柯
-2151101400248;Ouchn@2021;宁梦蝶
-2151101411017;Ouchn@2021;张凡
-2151101451023;Ouchn@2021;陈诗强
-2151101451024;Ouchn@2021;夏丹
-2151101451025;Ouchn@2021;侯灵
-2151101451026;Ouchn@2021;杨阳
-2151101451027;Ouchn@2021;张欣桐
-2151101451028;Ouchn@2021;王海
-2151101451029;Ouchn@2021;鲁丹
-2151101451030;Ouchn@2021;向培军
-2151101451031;Ouchn@2021;林明丽
-2151101451032;Ouchn@2021;陈林
+2351101200899;Ouchn@19960331;王旭东
+2351101200901;Ouchn@19971009;王绍科
+2351101200902;Ouchn@19810109;王江
+2351101200903;Ouchn@19950830;黄财源
+2351101401935;Ouchn@19891209;马晓华
+2351101401961;Ouchn@19881104;杨小林
+2351101401962;Ouchn@19821020;曾勇
+2351101401963;Ouchn@19970806;许淞浩
+2351101401964;Ouchn@19980524;张婷
+2351101401965;Ouchn@19920807;明智慧
+2351101401966;Ouchn@19920130;刘军
+2351101401967;Ouchn@19900309;孙家美
+2351101401968;Ouchn@19920407;周海燕
+2351101401969;Ouchn@19931225;刘洛灵
+2351101401970;Ouchn@19950507;魏李萍
+2351101401971;Ouchn@19960822;郑乔
+2351101402028;Ouchn@20010513;张霞
+2351101402029;Ouchn@20041018;陈馨雨
+2351101402031;Ouchn@19890213;刘超

+ 4 - 8
common.yaml

@@ -1,12 +1,8 @@
-videoInterval: 2
+videoInterval: 10
 courses:
 courses:
-- "建筑力学"
+- "习近平新时代中国特色社会主义思想概论"
 specialCourses:
 specialCourses:
-- "工程计量与计价实务"
-- "斜弱视技术"
-- "角膜接触镜并发症处理"
-- "建筑工程项目招投标与合同管理"
-- "医用基础化学"
+- "习近平新时代中国特色社会主义思想概论"
 channel: 1
 channel: 1
 visitCount: 0
 visitCount: 0
 NewStyle: false
 NewStyle: false
@@ -14,7 +10,7 @@ SleepTime: 60
 
 
 codeManual: true
 codeManual: true
 #target 1 视频和题目都处理 2 只拉视频 3 只刷题
 #target 1 视频和题目都处理 2 只拉视频 3 只刷题
-target: 2
+target: 1
 timeout: 20
 timeout: 20
 questionCount: 2
 questionCount: 2
 questionRandom : false
 questionRandom : false

+ 2 - 26
record.txt

@@ -1,26 +1,2 @@
-
-2151101450964 Ouchn@2021 刘
-2051106450087 Ouchn@2021 将
-2251106400034 Ouchn@2021 张
-2151101250453 Ouchn@2021 将
-2151101250453 Ouchn@2021 将
-2151101250453 Ouchn@2021 将
-2251101400517 Ouchn@2021 付云风
-2251101400516 Ouchn@2021 袁健
-2251101400518 Ouchn@2021 潘原仲一
-2151101400242 Ouchn@2021 刘强
-2151101400241 Ouchn@2021 颜洪
-2151101400244 Ouchn@2021 欧阳文强
-2151101400245 Ouchn@2021 杨鹏
-2151101400249 Ouchn@2021 将
-2251101400690 Ouchn@2021 将
-2251101400690 Ouchn@2021 将
-2251101400690 Ouchn@2021 将
-2151101250676 Ouchn@2021 将
-2251101200288 Ouchn@2021 将
-2151106400064 Ouchn@2021 将
-2151106400064 Ouchn@2021 将
-2151106400064 Ouchn@2021 将
-2251101200217 Ouchn@2021 将
-2251101200217 Ouchn@2021 将
-2051101250176 Ouchn@2021 将
+2251106450096 Ouchn@19850808 谢红
+2351101200900 Ouchn@19860427 文寅

+ 103 - 3
student/student.go

@@ -1115,6 +1115,40 @@ type CourseModule struct {
 	ModuleId string
 	ModuleId string
 }
 }
 
 
+func getUploadIds(moduleId string, cookie string) ([]int64, error) {
+	url := fmt.Sprintf("https://lms.ouchn.cn/api/activities/%s", moduleId)
+	request, err := http.NewRequest("GET", url, nil)
+	if err != nil {
+		return nil, err
+	}
+
+	request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+	request.Header.Set("Cookie", cookie)
+	request.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36")
+	//request.Header.Set("Host", "chengdu.ouchn.cn")
+
+	client := http.Client{}
+	resp, err := client.Do(request)
+	if err != nil {
+		return nil, err
+	}
+	defer resp.Body.Close()
+
+	respBytes, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		return nil, err
+	}
+
+	ret := []int64{}
+	uploads := gjson.GetBytes(respBytes, "uploads").Array()
+	for _, upload := range uploads {
+		id := upload.Get("id").Int()
+		ret = append(ret, id)
+	}
+
+	return ret, nil
+}
+
 func getCourseModules(courceId string, cookie string, specialCourse bool) ([]CourseModule, error) {
 func getCourseModules(courceId string, cookie string, specialCourse bool) ([]CourseModule, error) {
 	url := fmt.Sprintf("https://lms.ouchn.cn/api/courses/%s/modules", courceId)
 	url := fmt.Sprintf("https://lms.ouchn.cn/api/courses/%s/modules", courceId)
 	request, err := http.NewRequest("GET", url, nil)
 	request, err := http.NewRequest("GET", url, nil)
@@ -1228,7 +1262,7 @@ func GetModuleInfo(courseId string, moduleId string, cookie string) (*ModuleInfo
 		item.Id = array[1]
 		item.Id = array[1]
 		if stype == "page" {
 		if stype == "page" {
 			texts = append(texts, item)
 			texts = append(texts, item)
-		} else if stype == "online_video" || (stype == "web_link" && strings.Contains(item.Name, "视频")) {
+		} else if stype == "online_video" || (stype == "web_link" && strings.Contains(item.Name, "视频")) || stype == "material" {
 			index := -1
 			index := -1
 			for i := len(vedios) - 1; i >= 0; i-- {
 			for i := len(vedios) - 1; i >= 0; i-- {
 				if item.SyllabusId == vedios[i].SyllabusId {
 				if item.SyllabusId == vedios[i].SyllabusId {
@@ -1263,6 +1297,7 @@ func MakeExamUrl(courseId string, moduleId string, id string) string {
 }
 }
 
 
 func VedioCompleteHandle(cookie string, id string) error {
 func VedioCompleteHandle(cookie string, id string) error {
+
 	count := 0
 	count := 0
 	start, end := int64(0), int64(1000)
 	start, end := int64(0), int64(1000)
 	for count < 5 {
 	for count < 5 {
@@ -1961,6 +1996,53 @@ func isSpecialCourse(title string) bool {
 	return false
 	return false
 }
 }
 
 
+func finishUploadId(uploadId int64, moduleId string, cookie string) error {
+	rBody := make(map[string]int64)
+	rBody["upload_id"] = uploadId
+	rByte, _ := json.Marshal(rBody)
+	url := fmt.Sprintf("https://lms.ouchn.cn/api/course/activities-read/%s", moduleId)
+	request, err := http.NewRequest("POST", url, bytes.NewBuffer(rByte))
+	if err != nil {
+		return err
+	}
+
+	request.Header.Set("Content-Type", "application/json")
+	request.Header.Set("Cookie", cookie)
+	request.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36")
+	//request.Header.Set("Host", "chengdu.ouchn.cn")
+
+	client := http.Client{}
+	resp, err := client.Do(request)
+	if err != nil {
+		return err
+	}
+	defer resp.Body.Close()
+
+	respBytes, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		return err
+	}
+	if true {
+		fmt.Println("do material resp:", string(respBytes))
+	}
+
+	return nil
+}
+
+func finishMaterial(uploadIds []int64, moduleId string, cookie string) {
+	for _, v := range uploadIds {
+		finishUploadId(v, moduleId, cookie)
+		time.Sleep(1 * time.Second)
+	}
+}
+
+func doMaterial(moduleId string, cookie string) {
+	uploadIds, _ := getUploadIds(moduleId, cookie)
+	if len(uploadIds) > 0 {
+		finishMaterial(uploadIds, moduleId, cookie)
+	}
+}
+
 func CourseHandle(wd selenium.WebDriver, username string) error {
 func CourseHandle(wd selenium.WebDriver, username string) error {
 
 
 	title, err := wd.Title()
 	title, err := wd.Title()
@@ -1999,13 +2081,15 @@ func CourseHandle(wd selenium.WebDriver, username string) error {
 	examCount := 0
 	examCount := 0
 	for _, module := range modules {
 	for _, module := range modules {
 		fmt.Printf("***课程:%s 栏目:%s\n", title, module.Name)
 		fmt.Printf("***课程:%s 栏目:%s\n", title, module.Name)
-		if specialCourse && (config.Conf.Target == 1 || config.Conf.Target == 3) && (!strings.Contains(module.Name, "形考任务") &&
+		/*if specialCourse && (config.Conf.Target == 1 || config.Conf.Target == 3) && (!strings.Contains(module.Name, "形考任务") &&
 			!strings.Contains(module.Name, "形成性考核") &&
 			!strings.Contains(module.Name, "形成性考核") &&
 			!strings.Contains(module.Name, "形考作业") &&
 			!strings.Contains(module.Name, "形考作业") &&
 			!strings.Contains(module.Name, "课程考核") &&
 			!strings.Contains(module.Name, "课程考核") &&
+			!strings.Contains(module.Name, "大作业") &&
 			!strings.Contains(module.Name, "考试考核")) {
 			!strings.Contains(module.Name, "考试考核")) {
+			fmt.Println("module name:", module.Name)
 			continue
 			continue
-		}
+		}*/
 		if strings.Contains(module.Name, "专题一") ||
 		if strings.Contains(module.Name, "专题一") ||
 			strings.Contains(module.Name, "专题二") ||
 			strings.Contains(module.Name, "专题二") ||
 			strings.Contains(module.Name, "专题三") ||
 			strings.Contains(module.Name, "专题三") ||
@@ -2014,12 +2098,22 @@ func CourseHandle(wd selenium.WebDriver, username string) error {
 			strings.Contains(module.Name, "总论 ") {
 			strings.Contains(module.Name, "总论 ") {
 			//continue
 			//continue
 		}
 		}
+
+		if false {
+			if !strings.Contains(module.Name, "专题三") {
+				continue
+			}
+		}
+
 		// 获取某栏目下的试题和视频数据
 		// 获取某栏目下的试题和视频数据
+		//fmt.Println("111111111111111111:", courseId, module.ModuleId)
 		moduleInfo, err := GetModuleInfo(courseId, module.ModuleId, cookie)
 		moduleInfo, err := GetModuleInfo(courseId, module.ModuleId, cookie)
 		if err != nil {
 		if err != nil {
 			return errors.New(fmt.Sprintf("获取module(%s)详细信息失败:%s", module.Name, err.Error()))
 			return errors.New(fmt.Sprintf("获取module(%s)详细信息失败:%s", module.Name, err.Error()))
 		}
 		}
 
 
+		//fmt.Println("2222222222222:", moduleInfo)
+
 		// 处理网页数据
 		// 处理网页数据
 		if false {
 		if false {
 			for _, info := range moduleInfo.TxtInfos {
 			for _, info := range moduleInfo.TxtInfos {
@@ -2045,6 +2139,12 @@ func CourseHandle(wd selenium.WebDriver, username string) error {
 			for _, info := range moduleInfo.VedioInfos {
 			for _, info := range moduleInfo.VedioInfos {
 
 
 				fmt.Printf("*****正在处理视频数据:%s\n", info.Name)
 				fmt.Printf("*****正在处理视频数据:%s\n", info.Name)
+
+				if info.Stype == "material" {
+					doMaterial(info.Id, cookie)
+					continue
+				}
+
 				url := MakeTxtUrl(courseId, module.ModuleId, info.Id)
 				url := MakeTxtUrl(courseId, module.ModuleId, info.Id)
 				wd.Get(url)
 				wd.Get(url)
 				cookie, _ := getCookies(wd)
 				cookie, _ := getCookies(wd)