├── .gitignore ├── requirements.txt ├── README.md ├── config.default.yml ├── Util.py ├── XueXiaoE.py ├── main.py ├── ZhiJiao.py └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | cookies.json 2 | config.yml 3 | main.comment.py 4 | main.search.py -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | alive-progress==1.4.4 2 | astroid==2.3.3 3 | autopep8==1.5.1 4 | certifi==2019.11.28 5 | chardet==3.0.4 6 | idna==2.9 7 | isort==4.3.21 8 | lazy-object-proxy==1.4.3 9 | mccabe==0.6.1 10 | numpy==1.18.2 11 | opencv-python==4.2.0.34 12 | pycodestyle==2.5.0 13 | pylint==2.4.4 14 | PyYAML==5.3.1 15 | requests==2.23.0 16 | six==1.14.0 17 | urllib3==1.25.8 18 | wrapt==1.11.2 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 职教云自助刷课程序 2 | 3 | > *说明*:**本程序仅供学习和参考,禁止用于商业或违法犯罪用途!** 4 | 5 | 6 | 7 | *配置* 8 | 9 | > 运行前请先将文件 **config.default.yml** 拷贝后的文件重命名为 **config.yml** 10 | > 再修改 **config.yml** 内的配置信息 11 | 12 | 13 | 14 | *运行* 15 | 16 | > ⚠️ 运行前请先确认环境是否为 ***Python 3.8*** 17 | 18 | ```shell 19 | git clone https://github.com/shanling2016/ZhiJiaoYun && cd ZhiJiaoYun/ 20 | ``` 21 | 22 | > 安装依赖库 23 | 24 | ```shell 25 | pip3 install -r requirements.txt 26 | ``` 27 | 28 | > 运行程序 29 | 30 | ```shell 31 | python3 main.py 32 | ``` 33 | 34 | 35 | 36 | ### 关于作者 37 | 38 | 作者还只是 19 级的大学生啦~ 39 | 40 | 酱紫~ 41 | 42 | 43 | 44 | ### 打赏 45 | 46 | *如果觉得本项目对你有帮助就请点个免费的 **Star** 吧!!!* 47 | 48 | *如果您觉得本项目对你帮助很大就请作者喝杯奶茶吧~~* 49 | 50 | φ(≧ω≦*)♪ -------------------------------------------------------------------------------- /config.default.yml: -------------------------------------------------------------------------------- 1 | # ______ ______ __ 2 | # / \ / \ | \ 3 | # | $$$$$$\ ______ _______ | $$$$$$\ \$$ ______ 4 | # | $$ \$$ / \ | \ | $$_ \$$| \ / \ 5 | # | $$ | $$$$$$\| $$$$$$$\| $$ \ | $$| $$$$$$\ 6 | # | $$ __ | $$ | $$| $$ | $$| $$$$ | $$| $$ | $$ 7 | # | $$__/ \| $$__/ $$| $$ | $$| $$ | $$| $$__| $$ 8 | # \$$ $$ \$$ $$| $$ | $$| $$ | $$ \$$ $$ 9 | # \$$$$$$ \$$$$$$ \$$ \$$ \$$ \$$ _\$$$$$$$ 10 | # | \__| $$ 11 | # \$$ $$ 12 | # \$$$$$$ 13 | # Title: 程序运行配置 14 | # Warning: 本程序仅供学习和参考,禁止用于商业或违法犯罪用途! 15 | 16 | # 网课网站的账号信息 17 | member: 18 | # 账号 19 | user: xxx 20 | 21 | # 密码 22 | pass: xxx 23 | 24 | # 视频任务自动评论 25 | videoComment: false 26 | 27 | # 视频评打分 28 | videoStar: 5.0 29 | 30 | # 自动评论列表 31 | commentList: 32 | - 已学 33 | - 学到了 34 | 35 | # 保存 Cookies 36 | # 当登陆成功后,保存 Cookies 到本地,当下次运行时 37 | # 若 Cookies 有效, 则使用 Cookies 进行登陆 38 | saveCookies: false 39 | 40 | # 【学小易】搜题App 的账号信息 41 | store: 42 | # 账号 43 | user: xxx 44 | 45 | # 密码 46 | pass: xxx -------------------------------------------------------------------------------- /Util.py: -------------------------------------------------------------------------------- 1 | # /usr/bin/python3 2 | # coding=utf8 3 | 4 | """ 5 | 工具集 6 | """ 7 | 8 | import time 9 | 10 | # 获取时间戳 11 | def get_timestamp(): 12 | timestamp = time.time() 13 | return int(timestamp * 1000) 14 | 15 | # json转字符 16 | def obj2str(obj): 17 | ret = "" 18 | for key in obj: 19 | if ret == "": 20 | ret = key + "=" + str(obj[key]) 21 | else: 22 | ret = ret + "&" + key + "=" + str(obj[key]) 23 | return ret 24 | 25 | def print_list(obj): 26 | if len(obj) == 0: 27 | return 28 | print("------------------------------------") 29 | print("│ id | 课程名称") 30 | index = 0 31 | for item in obj: 32 | print("| %2d | %-s %d%%" % (index, item['courseName'], item['process'])) 33 | index = index + 1 34 | print("------------------------------------") 35 | print("| 退出请输入 -1") 36 | print("------------------------------------") 37 | 38 | def print_tree(obj): 39 | if len(obj) == 0: 40 | return 41 | 42 | oc = 0 43 | 44 | index = 0 45 | for item in obj: 46 | if item['percent'] != 100: 47 | c = "❌ [{0} %]".format(item['percent']) 48 | else: 49 | c = "✅ [{0} %]".format(item['percent']) 50 | 51 | if index == 0: 52 | print("┌ %s %s" % (item['name'], c)) 53 | elif index == len(obj) - 1: 54 | print("└ %s %s" % (item['name'], c)) 55 | else: 56 | print("├ %s %s" % (item['name'], c)) 57 | 58 | if item['percent'] == 100: 59 | index = index + 1 60 | continue 61 | 62 | index2 = 0 63 | for item2 in item['data']: 64 | 65 | if index + 1 == len(obj): 66 | if len(item['data']) - 1 != index2: 67 | print(" ├ %s" % item2['name']) 68 | else: 69 | print(" └ %s" % item2['name']) 70 | else: 71 | if len(item['data']) - 1 != index2: 72 | print("│ ├ %s" % item2['name']) 73 | else: 74 | print("│ └ %s" % item2['name']) 75 | 76 | index2 = index2 + 1 77 | 78 | index = index + 1 -------------------------------------------------------------------------------- /XueXiaoE.py: -------------------------------------------------------------------------------- 1 | # /usr/bin/python3 2 | # coding=utf8 3 | 4 | import re 5 | import html 6 | import json 7 | import random 8 | import base64 9 | import hashlib 10 | import requests 11 | from urllib.parse import quote 12 | from Util import get_timestamp, obj2str 13 | 14 | """ 15 | 学小易操作类 16 | 用于搜题 17 | """ 18 | 19 | class XueXiaoE: 20 | 21 | s = requests.session() 22 | 23 | def __init__(self): 24 | # 设置全局Http协议头 25 | self.s.headers.update( 26 | { 27 | 'Accept': "*/*", 28 | 'Accept-Language': "zh-Hans-CN;q=1", 29 | 'Connection': "keep-alive", 30 | 'Accept-Encoding': "gzip, deflate, br", 31 | 'User-Agent': "xueyi/1 CFNetwork/1121.2.2 Darwin/19.3.0" 32 | }) 33 | 34 | def login_m(self, u_name, u_pass): 35 | 36 | uri = "https://app.51xuexiaoyi.com/api/v1/login" 37 | 38 | headers = { 39 | 'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8", 40 | 'Accept-Encoding': "gzip, deflate, br" 41 | } 42 | 43 | data = obj2str({ 44 | 'username': u_name, 45 | 'password': u_pass 46 | }) 47 | 48 | r = self.s.post(uri, headers=headers, data=data) 49 | 50 | res = json.loads(r.text) 51 | 52 | if res['code'] == 200: 53 | token = res['data']['api_token'] 54 | self.s.headers.update({ 55 | 'token': token 56 | }) 57 | 58 | return res['code'] == 200 59 | 60 | def searchCourse(self, key): 61 | 62 | uri = "https://app.51xuexiaoyi.com/api/v1/course/searchCourse" 63 | 64 | headers = { 65 | 'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8", 66 | 'Accept-Encoding': "gzip, deflate, br" 67 | } 68 | 69 | data = obj2str({ 70 | 'keyword': key 71 | }).encode(encoding="utf-8") 72 | 73 | r = self.s.post(uri, headers=headers, data=data) 74 | 75 | res = json.loads(r.text) 76 | 77 | if res['code'] != 200: 78 | return [] 79 | 80 | return res['data'] 81 | 82 | def searchQuestion(self, key, ids): 83 | 84 | uri = "https://app.51xuexiaoyi.com/api/v1/searchQuestion" 85 | 86 | headers = { 87 | 'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8", 88 | 'Accept-Encoding': "gzip, deflate, br" 89 | } 90 | 91 | data = obj2str({ 92 | 'keyword': key, 93 | 'id': ids 94 | }).encode(encoding="utf-8") 95 | 96 | r = self.s.post(uri, headers=headers, data=data) 97 | 98 | res = json.loads(r.text) 99 | 100 | if res['code'] != 200: 101 | return [] 102 | 103 | return res['data'] -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # /usr/bin/python3 2 | # coding=utf-8 3 | 4 | import os 5 | import yaml 6 | import json 7 | import math 8 | import time 9 | import random 10 | 11 | from ZhiJiao import ZhiJiao 12 | from alive_progress import alive_bar 13 | from Util import print_list, print_tree 14 | 15 | if __name__ == "__main__": 16 | 17 | try: 18 | # 读取配置文件 19 | with open("config.yml", "r", encoding='utf-8') as f: 20 | data = f.read() 21 | # 加载配置文件 22 | config = yaml.safe_load(data) 23 | except IOError: 24 | print("❌ 初始化时出现错误:没找到配置文件!") 25 | exit(-1) 26 | except yaml.YAMLError as exc: 27 | print("❌ 初始化时出现错误:配置文件异常!") 28 | exit(-2) 29 | 30 | # 初始化网课操作对象 31 | obj = ZhiJiao() 32 | 33 | print("开始登陆……") 34 | # 先判断有没有缓存Cookie 35 | if os.path.exists("cookies.json"): 36 | with open("cookies.json", "r", encoding='utf-8') as f: 37 | js = f.read() 38 | # 设置 Cookies 39 | obj.set_cookie(js) 40 | 41 | # 取一下数据,查看 Cookies 是否有效 42 | if len(obj.s.cookies.items()) == 0 or not ('courseList' in obj.getCourseList()): 43 | # 清空Cookies 44 | obj.s.cookies.clear() 45 | # 登陆 46 | if obj.login_m(str(config['member']['user']), str(config['member']['pass'])): 47 | if config['saveCookies']: 48 | # 获取 Cookies 49 | ck = json.dumps(obj.s.cookies.items()) 50 | # 保存到文件 51 | f = open("cookies.json", "w", encoding='utf-8') 52 | f.write(ck) 53 | f.close() 54 | else: 55 | print("登陆失败!") 56 | exit(-3) 57 | 58 | userId = obj.getUserInfo()['stuId'] 59 | 60 | print("正在获取课程列表……") 61 | course = obj.getCourseList()['courseList'] 62 | 63 | # 输出 64 | print_list(course) 65 | 66 | while True: 67 | # 异常输入判断 68 | try: 69 | # 要求输入 70 | id = int(input("课程id: ")) 71 | except ValueError: 72 | print("您输入的数据不符合规范!") 73 | continue 74 | if id == -1: 75 | exit(0) 76 | if id >= len(course) or id < 0: 77 | print("课程id不存在!") 78 | continue 79 | break 80 | 81 | # 输出选中的课程名称 82 | print("\n<%s>" % course[id]['courseName']) 83 | 84 | # 获取课程目录 85 | cata = obj.getCourseCata(course[id]['courseOpenId'], course[id]['openClassId']) 86 | 87 | # 输出目录 88 | print_tree(cata) 89 | 90 | # 遍历目录 91 | for item in cata: 92 | # 查看是否完成 93 | if item['percent'] == 100: 94 | continue 95 | 96 | # 获取目录id 97 | moduleId = item['id'] 98 | 99 | for items in item['data']: 100 | # 获取数据 101 | courseOpenId = course[id]['courseOpenId'] 102 | openClassId = course[id]['openClassId'] 103 | topicId = items['id'] 104 | # 获取任务 105 | task = obj.getData(courseOpenId, openClassId, topicId) 106 | 107 | # 遍历任务点; 判断是否完成 108 | for item2 in task: 109 | # 判断是否达到100%的进度 110 | if item2['stuCellPercent'] == 100: 111 | continue 112 | # 获取数据 113 | cellId = item2['Id'] 114 | task_type = item2['categoryName'] 115 | 116 | # 取任务详细信息 117 | info = obj.getTaskInfo(courseOpenId, openClassId, cellId, moduleId) 118 | 119 | # 判断多开 120 | if info['code'] == -100: 121 | print("\n⚠️ 因服务器限制,您只可以同时学习一门课程!") 122 | action = input("❓ 是否继续学习?(yes/no): ") 123 | if action != "yes": 124 | exit(0) 125 | 126 | # 告诉服务器我们的选择 127 | obj.choiceCourse(courseOpenId, openClassId, cellId, moduleId, info['currCellName']) 128 | 129 | # 重新获取数据 130 | info = obj.getTaskInfo(courseOpenId, openClassId, cellId, moduleId) 131 | 132 | 133 | print("\n💼 任务类型: %s" % task_type) 134 | 135 | # 获取数据 136 | cellLogId = info['cellLogId'] 137 | Token = info['guIdToken'] 138 | 139 | if task_type == 'ppt': 140 | print("📽 ppt 《%s》 \n⏳ 正在自动完成" % item2['cellName']) 141 | pageCount = info['pageCount'] 142 | obj.updateLog(courseOpenId, openClassId, moduleId, cellId, cellLogId, pageCount, 0, pageCount, Token) 143 | print("🎉 ppt任务完成!") 144 | elif task_type == '视频': 145 | 146 | audioVideoLong = info['audioVideoLong'] 147 | 148 | print("📺 视频 《%s》 " % item2['cellName']) 149 | print("⏰ 视频时长: %.2f 分钟" % (audioVideoLong / 60)) 150 | print("⏳ 正在自动完成……") 151 | 152 | # 开始进行模拟上报数据 153 | # 观看进度变量 154 | index = 0 155 | # 获取已观看的时间 156 | times = info['stuStudyNewlyTime'] #20.2 157 | # 进度条 158 | with alive_bar(int(audioVideoLong) + 1) as bar: 159 | while True: 160 | # 如果是视频长度大于 10 秒 161 | # 我们就分步走 162 | # 首先先判断,我们之前是否有看过 163 | if times > 0: 164 | # 如果有看过, 就把原进度赋值过来 165 | index = times 166 | # 然后再将进度变化反馈给用户 167 | for ited in range(int(index)): 168 | bar() 169 | # 再把进度记录给置为 0 170 | # 以免之后的循环出现问题 171 | times = 0 172 | 173 | # 首先判断视频长度的是否 小于 10 秒, 或者 剩余的播放时间是否够 10 秒 174 | if audioVideoLong > 10 and audioVideoLong - index > 10: 175 | # 到这就说明视频长度既大于10秒,并且剩余的播放时间也大于10秒 176 | # 然后就开始延时 177 | for ited in range(10): 178 | bar() 179 | time.sleep(1) 180 | # 延时后级对 index 进行递增 10 181 | index = index + 10 182 | # 然后设置一个用于告诉服务器播放进度对值 183 | temp = index + random.random() 184 | else: 185 | # 不足1秒的按照1秒算 186 | itemed = range(int(audioVideoLong - index) + 1) 187 | for ited in itemed: 188 | bar() 189 | time.sleep(1) 190 | # 然后直接赋值 191 | temp = audioVideoLong 192 | # 上报数据 193 | res = obj.updateLog(courseOpenId, openClassId, moduleId, cellId, cellLogId, 0, "%.6f" % temp, 0, Token) 194 | 195 | # 判断是否出现异常 或者 是否完成 196 | if not res or temp == audioVideoLong: 197 | break 198 | 199 | # 判断是否完成, 从循环出来只有可能是出现异常和正常 200 | if not res: 201 | print("🚫 该视频任务因数据上报异常而终止!") 202 | else: 203 | if config['videoComment']: 204 | # 获取这个视频的评论列表 205 | comment = obj.getComment(courseOpenId, openClassId, moduleId, cellId) 206 | 207 | exit = False 208 | 209 | # 判断视频是否评论 210 | for item4 in comment: 211 | if item4['userId'] == userId: 212 | exit = True 213 | break 214 | 215 | # 判断是否评论 216 | if not exit: 217 | 218 | size = len(config['commentList']) 219 | 220 | rand = random.randint(0, size - 1) 221 | 222 | content = config['commentList'][rand] 223 | 224 | star = config['videoStar'] 225 | 226 | # 执行评论 227 | obj.commentVideo(courseOpenId, openClassId, cellId, moduleId, content, star) 228 | 229 | print("🎉 视频 《%s》 已完成!" % item2['cellName']) 230 | 231 | elif task_type == '链接': 232 | print("🔗 链接 《%s》 已完成!" % item2['cellName']) 233 | elif task_type == '图片': 234 | print("🖼 图片 《%s》 已完成!" % item2['cellName']) 235 | 236 | print("\n🎉 你已完成了本课的所有课程!") 237 | -------------------------------------------------------------------------------- /ZhiJiao.py: -------------------------------------------------------------------------------- 1 | # /usr/bin/python3 2 | # coding=utf8 3 | 4 | import re 5 | import html 6 | import json 7 | import random 8 | import base64 9 | import hashlib 10 | import requests 11 | from urllib.parse import quote 12 | from Util import get_timestamp, obj2str 13 | 14 | """ 15 | 职教云操作类 16 | """ 17 | 18 | 19 | class ZhiJiao: 20 | 21 | s = requests.session() 22 | 23 | def __init__(self): 24 | # 设置全局Http协议头 25 | self.s.headers.update( 26 | { 27 | 'Accept': "*/*", 28 | 'Accept-Language': "zh-Hans-CN;q=1", 29 | 'Connection': "keep-alive", 30 | 'Accept-Encoding': "gzip, deflate, br", 31 | 'User-Agent': "yktIcve/2.8.21 (com.66ykt.66yktteacherzhihui; build:2020041004; iOS 13.3.1) Alamofire/4.7.3" 32 | }) 33 | 34 | # 获取验证码: 保存到外部 35 | def get_code(self, name): 36 | uri = "https://zjy2.icve.com.cn/api/common/VerifyCode/index?t=%f" % random.random() 37 | 38 | r = self.s.get(uri) 39 | 40 | with open(name, 'wb') as fd: 41 | for chunk in r.iter_content(): 42 | fd.write(chunk) 43 | 44 | # 执行登陆; Web网页接口 45 | def login(self, u_name, u_pass, code): 46 | 47 | uri = "https://zjy2.icve.com.cn/api/common/login/login" 48 | 49 | headers = { 50 | 'Content-Type': "application/x-www-form-urlencoded", 51 | 'Accept-Encoding': 'gzip, deflate, br', 52 | 'Origin': "https://zjy2.icve.com.cn", 53 | 'Referer': "https://zjy2.icve.com.cn/portal/login.html" 54 | } 55 | 56 | data = obj2str({ 57 | 'userName': u_name, 58 | 'userPwd': u_pass, 59 | 'verifyCode': code 60 | }) 61 | 62 | r = self.s.post(uri, headers=headers, data=data) 63 | 64 | ret = json.loads(r.text) 65 | return ret['code'] == 1 66 | 67 | # 执行登陆: Mobile端 68 | # 优点是可以免验证码登陆 69 | def login_m(self, u_name, u_pass): 70 | 71 | uri = "https://zjyapp.icve.com.cn/newMobileAPI/MobileLogin/newLogin" 72 | 73 | headers = { 74 | 'Content-Type': "application/x-www-form-urlencoded", 75 | 'Accept-Encoding': 'gzip, deflate, br', 76 | } 77 | 78 | data = obj2str({ 79 | 'appVersion': "2.8.21", 80 | 'clientId': "057386f8991f402498dfc38ed5cb7e49", 81 | 'equipmentApiVersion': "14.1", 82 | 'equipmentAppVersion': "2.8.21", 83 | 'equipmentModel': "iPhone%2012", 84 | 'sourceType': "3", 85 | 'userName': u_name, 86 | 'userPwd': u_pass 87 | }) 88 | 89 | r = self.s.post(uri, headers=headers, data=data) 90 | 91 | ret = json.loads(r.text) 92 | return ret['code'] == 1 93 | 94 | # 验证码识别; 联众打码接口 95 | def code(self, imagePath): 96 | uri = "http://v1-http-api.jsdama.com/api.php?mod=php&act=upload" 97 | 98 | user_name = "******" 99 | user_pw = "******." 100 | 101 | headers = { 102 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 103 | 'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3', 104 | 'Accept-Encoding': 'gzip, deflate', 105 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0', 106 | 'Connection': 'keep-alive', 107 | 'Host': 'v1-http-api.jsdama.com', 108 | 'Upgrade-Insecure-Requests': '1' 109 | } 110 | 111 | files = { 112 | 'upload': (imagePath, open(imagePath, 'rb'), 'image/png') 113 | } 114 | 115 | data = { 116 | 'user_name': user_name, 117 | 'user_pw': user_pw, 118 | 'yzm_type': '1001' 119 | } 120 | 121 | s = requests.session() 122 | r = s.post(uri, headers=headers, 123 | data=data, files=files, verify=False) 124 | a = json.loads(r.text) 125 | 126 | return a['data']['val'] 127 | 128 | # 设置Cookie 129 | def set_cookie(self, ck): 130 | obj = json.loads(ck) 131 | 132 | cookies = {} 133 | for o in obj: 134 | cookies[o[0]] = o[1] 135 | 136 | self.s.cookies.update(cookies) 137 | 138 | # 获取课程列表 139 | def getCourseList(self): 140 | 141 | uri = "https://zjy2.icve.com.cn/api/student/learning/getLearnningCourseList" 142 | 143 | r = self.s.post(uri) 144 | return json.loads(r.text) 145 | 146 | # 获取课程目录 147 | def getCourseCata(self, courseOpenId, openClassId): 148 | 149 | uri = "https://zjy2.icve.com.cn/api/study/process/getProcessList" 150 | 151 | headers = { 152 | 'Content-Type': "application/x-www-form-urlencoded", 153 | 'Accept-Encoding': 'gzip, deflate, br', 154 | } 155 | 156 | # 获取一级目录 157 | r = self.s.post(uri, headers=headers, data=obj2str({ 158 | 'courseOpenId': courseOpenId, 159 | 'openClassId': openClassId 160 | })) 161 | 162 | ret = json.loads(r.text) 163 | 164 | if ret['code'] != 1: 165 | raise Exception("获取目录时,出现异常!") 166 | 167 | length = len(ret['progress']['moduleList']) 168 | 169 | i = 0 170 | # 遍历 获取二级目录 171 | while i < length: 172 | 173 | item = ret['progress']['moduleList'][i] 174 | # 先进行判断 175 | # 看看是否是 100% 避免去获取已经完成的视频的二级目录 176 | if item['percent'] == 100: 177 | i = i + 1 178 | continue 179 | 180 | # 获取二级模块id 181 | moduleId = item['id'] 182 | 183 | ret2 = self.getLevelCata(courseOpenId, moduleId) 184 | 185 | ret['progress']['moduleList'][i]['data'] = ret2['topicList'] 186 | 187 | i = i + 1 188 | 189 | return ret['progress']['moduleList'] 190 | 191 | def getLevelCata(self, courseOpenId, moduleId): 192 | 193 | uri = "https://zjy2.icve.com.cn/api/study/process/getTopicByModuleId" 194 | 195 | headers = { 196 | 'Content-Type': "application/x-www-form-urlencoded", 197 | 'Accept-Encoding': 'gzip, deflate, br', 198 | } 199 | 200 | # 获取二级目录 201 | r = self.s.post(uri, headers=headers, data=obj2str({ 202 | 'courseOpenId': courseOpenId, 203 | 'moduleId': moduleId 204 | })) 205 | 206 | ret = json.loads(r.text) 207 | 208 | if ret['code'] != 1: 209 | raise Exception("获取目录时,出现异常!") 210 | 211 | return ret 212 | 213 | # 获取二级目录的视频 214 | def getData(self, courseOpenId, openClassId, topicId): 215 | 216 | uri = "https://zjy2.icve.com.cn/api/study/process/getCellByTopicId" 217 | 218 | headers = { 219 | 'Content-Type': "application/x-www-form-urlencoded", 220 | 'Accept-Encoding': 'gzip, deflate, br', 221 | } 222 | 223 | data = obj2str({ 224 | 'courseOpenId': courseOpenId, 225 | 'openClassId': openClassId, 226 | 'topicId': topicId 227 | }) 228 | 229 | r = self.s.post(uri, headers=headers, data=data) 230 | 231 | ret = json.loads(r.text) 232 | 233 | if ret['code'] != 1: 234 | raise Exception("获取任务时,出现异常!") 235 | 236 | return ret['cellList'] 237 | 238 | # 获取任务信息 239 | def getTaskInfo(self, courseOpenId, openClassId, cellId, moduleId): 240 | 241 | uri = "https://zjy2.icve.com.cn/api/common/Directory/viewDirectory" 242 | 243 | headers = { 244 | 'Content-Type': "application/x-www-form-urlencoded", 245 | 'Accept-Encoding': 'gzip, deflate, br', 246 | } 247 | 248 | data = obj2str({ 249 | 'courseOpenId': courseOpenId, 250 | 'openClassId': openClassId, 251 | 'cellId': cellId, 252 | 'flag': "s", 253 | 'moduleId': moduleId 254 | }) 255 | 256 | r = self.s.post(uri, headers=headers, data=data) 257 | 258 | return json.loads(r.text) 259 | 260 | # 上报任务完成状态 261 | def updateLog(self, courseOpenId, openClassId, moduleId, cellId, cellLogId, picNum, studyNewlyTime, studyNewlyPicNum, token): 262 | 263 | uri = "https://zjy2.icve.com.cn/api/common/Directory/stuProcessCellLog" 264 | 265 | headers = { 266 | 'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8", 267 | 'Accept-Encoding': "gzip, deflate, br", 268 | 'Origin': "https://zjy2.icve.com.cn", 269 | 'X-Requested-With': "XMLHttpRequest", 270 | 'Referer': "https://zjy2.icve.com.cn/common/directory/directory.html?courseOpenId=%s&openClassId=%s&cellId=%s&flag=s&moduleId=%s" % (courseOpenId, openClassId, cellId, moduleId) 271 | } 272 | 273 | data = obj2str({ 274 | 'courseOpenId': courseOpenId, 275 | 'openClassId': openClassId, 276 | 'cellId': cellId, 277 | 'cellLogId': cellLogId, 278 | 'picNum': picNum, 279 | 'studyNewlyTime': studyNewlyTime, 280 | 'studyNewlyPicNum': studyNewlyPicNum, 281 | 'token': token 282 | }) 283 | 284 | r = self.s.post(uri, headers=headers, data=data) 285 | 286 | ret = json.loads(r.text) 287 | 288 | return ret['code'] == 1 289 | 290 | # 确认任务 291 | def choiceCourse(self, courseOpenId, openClassId, cellId, moduleId, cellName): 292 | 293 | uri = "https://zjy2.icve.com.cn/api/common/Directory/changeStuStudyProcessCellData" 294 | 295 | headers = { 296 | 'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8", 297 | 'Accept-Encoding': "gzip, deflate, br", 298 | 'Origin': "https://zjy2.icve.com.cn", 299 | 'X-Requested-With': "XMLHttpRequest", 300 | 'Referer': "https://zjy2.icve.com.cn/common/directory/directory.html?courseOpenId=%s&openClassId=%s&cellId=%s&flag=s&moduleId=%s" % (courseOpenId, openClassId, cellId, moduleId) 301 | } 302 | 303 | data = obj2str({ 304 | 'courseOpenId': courseOpenId, 305 | 'openClassId': openClassId, 306 | 'cellId': cellId, 307 | 'moduleId': moduleId, 308 | 'cellName': cellName 309 | }).encode(encoding="utf-8") 310 | 311 | r = self.s.post(uri, headers=headers, data=data) 312 | 313 | ret = json.loads(r.text) 314 | return ret['code'] == 1 315 | 316 | # 取用户用户信息 317 | def getUserInfo(self): 318 | 319 | uri = "https://zjy2.icve.com.cn/api/student/Studio/index" 320 | 321 | r = self.s.post(uri) 322 | 323 | ret = json.loads(r.text) 324 | 325 | return ret 326 | 327 | # 获取视频评论 328 | def getComment(self, courseOpenId, openClassId, moduleId, cellId): 329 | 330 | uri = "https://zjy2.icve.com.cn/api/common/Directory/getCellCommentData" 331 | 332 | headers = { 333 | 'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8", 334 | 'Accept-Encoding': "gzip, deflate, br", 335 | 'Origin': "https://zjy2.icve.com.cn", 336 | 'X-Requested-With': "XMLHttpRequest", 337 | 'Referer': "https://zjy2.icve.com.cn/common/directory/directory.html?courseOpenId=%s&openClassId=%s&cellId=%s&flag=s&moduleId=%s" % (courseOpenId, openClassId, cellId, moduleId) 338 | } 339 | 340 | data = obj2str({ 341 | 'courseOpenId': courseOpenId, 342 | 'openClassId': openClassId, 343 | 'cellId': cellId, 344 | 'type': "0", 345 | }) 346 | 347 | r = self.s.post(uri, headers=headers, data=data) 348 | 349 | ret = json.loads(r.text) 350 | 351 | if ret['code'] != 1: 352 | return [] 353 | 354 | size = ret['pagination']['totalCount'] 355 | 356 | if size <= 8: 357 | return ret['list'] 358 | 359 | uri = "https://zjy2.icve.com.cn/common/Directory/getCellCommentData" 360 | 361 | listData = ret['list'] 362 | 363 | index = 1 364 | 365 | while index * 8 < size: 366 | 367 | index = index + 1 368 | 369 | data = obj2str({ 370 | 'courseOpenId': courseOpenId, 371 | 'openClassId': openClassId, 372 | 'cellId': cellId, 373 | 'type': "0", 374 | 'pageSize': 8, 375 | 'page': index 376 | }) 377 | 378 | r = self.s.post(uri, headers=headers, data=data) 379 | 380 | ret = json.loads(r.text) 381 | 382 | for z in ret['list']: 383 | listData.insert(len(listData), z) 384 | 385 | return listData 386 | 387 | # 给视频课程进行评论 388 | def commentVideo(self, courseOpenId, openClassId, cellId, moduleId, content, star): 389 | 390 | uri = "https://zjy2.icve.com.cn/api/common/Directory/addCellActivity" 391 | 392 | headers = { 393 | 'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8", 394 | 'Accept-Encoding': "gzip, deflate, br", 395 | 'Origin': "https://zjy2.icve.com.cn", 396 | 'X-Requested-With': "XMLHttpRequest", 397 | 'Referer': "https://zjy2.icve.com.cn/common/directory/directory.html?courseOpenId=%s&openClassId=%s&cellId=%s&flag=s&moduleId=%s" % (courseOpenId, openClassId, cellId, moduleId) 398 | } 399 | 400 | data = obj2str({ 401 | 'courseOpenId': courseOpenId, 402 | 'openClassId': openClassId, 403 | 'cellId': cellId, 404 | 'content': content, 405 | 'docJson': "", 406 | 'star': star, 407 | 'activityType': 1 408 | }).encode(encoding="utf-8") 409 | 410 | r = self.s.post(uri, headers=headers, data=data) 411 | 412 | ret = json.loads(r.text) 413 | 414 | return ret['code'] == 1 415 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------