aiguoli / qcourse_scripts

腾讯课堂,模拟登陆,获取课程信息,视频下载,视频解密。
195 stars 62 forks source link

下载失败不知道原因 #15

Open Orisland opened 3 years ago

Orisland commented 3 years ago

环境mac bigsur

Traceback (most recent call last):
  File "/Users/zhaolong/qcourse_scripts/qcourse.py", line 138, in <module>
    main()
  File "/Users/zhaolong/qcourse_scripts/qcourse.py", line 132, in main
    asyncio.run(download_selected_chapter(term_id, course_name, chapter_name, courses))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/zhaolong/qcourse_scripts/qcourse.py", line 80, in download_selected_chapter
    urls = get_download_urls(term_id, file_id)
  File "/Users/zhaolong/qcourse_scripts/utils.py", line 218, in get_download_urls
    video_info = get_video_info(file_id, tokens.get('t'), tokens.get('sign'), tokens.get('us'))
AttributeError: 'NoneType' object has no attribute 'get'
zhaolong@Orislands-MacBook-Air qcourse_scripts % 
GeekTR commented 3 years ago

Traceback (most recent call last): File "/Users/tangrui/WorkSpace/qcourse_scripts/qcourse.py", line 138, in main() File "/Users/tangrui/WorkSpace/qcourse_scripts/qcourse.py", line 116, in main asyncio.run(download_selected_chapter(term_id, course_name, chapter_name, courses)) File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/Users/tangrui/WorkSpace/qcourse_scripts/qcourse.py", line 80, in download_selected_chapter urls = get_download_urls(term_id, file_id) File "/Users/tangrui/WorkSpace/qcourse_scripts/utils.py", line 218, in get_download_urls video_info = get_video_info(file_id, tokens.get('t'), tokens.get('sign'), tokens.get('us')) File "/Users/tangrui/WorkSpace/qcourse_scripts/utils.py", line 166, in get_video_info response = requests.get(url, params=params, cookies=load_json_cookies()).json() File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 900, in json return complexjson.loads(self.text, **kwargs) File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/init.py", line 346, in loads return _default_decoder.decode(s) File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) /usr/local/lib/python3.9/site-packages/httpx/_client.py:2003: UserWarning: Unclosed <httpx.AsyncClient object at 0x10a5daca0>. See https://www.python-httpx.org/async/#opening-and-closing-clients for details.

GeekTR commented 3 years ago

感觉和你的这个一样啊

aiguoli commented 2 years ago

试试新版本代码,已经改过了

yyuanshuai commented 2 years ago

试试新版本代码,已经改过了

我也是python3.9, 一样的报错。已拉最新代码, 逼我去学python吗:)

UnlimitedBurst commented 2 years ago

环境: Windows10 Python3.10

操作步骤:

  1. QQ扫码登录
  2. 下载课程全部视频
  3. 选择了一个VIP课程下载(https://ke.qq.com/course/3138651#term_id=103794832

接着就出现了以下异常堆栈信息: Traceback (most recent call last): File "E:\JetBrains\PycharmProjects\qcourse_scripts\qcourse.py", line 171, in main() File "E:\JetBrains\PycharmProjects\qcourse_scripts\qcourse.py", line 159, in main asyncio.run( File "E:\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "E:\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "E:\JetBrains\PycharmProjects\qcourse_scripts\qcourse.py", line 96, in download_selected_chapter urls = get_download_urls(term_id, file_id, cid=cid) File "E:\JetBrains\PycharmProjects\qcourse_scripts\utils.py", line 354, in get_download_urls video_info = get_video_info( File "E:\JetBrains\PycharmProjects\qcourse_scripts\utils.py", line 259, in get_video_info response = requests.get(url, params=params, cookies=load_json_cookies(), proxies=PROXIES).json() File "E:\Python\Python310\lib\site-packages\requests\models.py", line 900, in json return complexjson.loads(self.text, **kwargs) File "E:\Python\Python310\lib\json__init__.py", line 346, in loads return _default_decoder.decode(s) File "E:\Python\Python310\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "E:\Python\Python310\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

也是跟get_video_info函数有关系的报错。断点调试看了一下,接口请求https://ke.qq.com/cgi-bin/qcloud/get_token 响应体如下:

{'result': {'err_code': 101, 'err_msg': '未购买此课程,请购买后听课。'}, 'retcode': 0}

确认账号是已经拥有此课程的,所以我想是不是请求携带的params或者cookies缺少了什么参数导致出现这异常的。

aiguoli commented 2 years ago

@BurstLinker996

删掉cookies.json试试,可能是cookies文件里的账号没有这节课

girlfriendnotfoundexcept commented 2 years ago

我也是一样 Traceback (most recent call last): File "qcourse.py", line 154, in main() File "qcourse.py", line 101, in main qq_course.login() File "qcourse.py", line 35, in login cj = browser_cookie3.edge(domain_name='ke.qq.com') File "C:\Users\wangJun\Desktop\qcourse_scripts-main\qcourse-venv\lib\site-packages\browser_cookie3__init__.py", line 868, in edge return Edge(cookie_file, domain_name, key_file).load() File "C:\Users\wangJun\Desktop\qcourse_scripts-main\qcourse-venv\lib\site-packages\browser_cookie3__init.py", line 556, in init super().init(browser='Edge', cookie_file=cookie_file, domain_name=domain_name, key_file=key_file, **args) File "C:\Users\wangJun\Desktop\qcourse_scripts-main\qcourse-venv\lib\site-packages\browser_cookie3\init.py", line 229, in init self.add_key_and_cookie_file(**kwargs) File "C:\Users\wangJun\Desktop\qcourse_scripts-main\qcourse-venv\lib\site-packages\browser_cookie3__init.py", line 288, in add_key_and_cookie_file raise BrowserCookieError('Failed to find {} cookie'.format(self.browser)) browser_cookie3.BrowserCookieError: Failed to find Edge cookie

bg4vrg commented 1 year ago

我也类似问题。win2019+python3.9

下载单个视频报错如下。下载指定章节只有部分可下。都是已付费的

(qcourse-venv) E:\qcourse_scripts-main>python qcourse.py

  1. 下载单个视频
  2. 下载课程指定章节
  3. 下载课程全部视频
  4. 退出登录

输入需要的功能:0 输入课程链接:https://ke.qq.com/***** Traceback (most recent call last): File "E:\qcourse_scripts-main\qcourse.py", line 171, in main() File "E:\qcourse_scripts-main\qcourse.py", line 123, in main asyncio.run(parse_course_url_and_download(course_url)) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 647, in run_until_complete return future.result() File "E:\qcourse_scripts-main\qcourse.py", line 86, in parse_course_url_and_download urls = get_download_url_from_course_url(video_url, -1) File "E:\qcourse_scripts-main\utils.py", line 330, in get_download_url_from_course_url term_id, file_id = parse_video_url(video_url) File "E:\qcourse_scripts-main\utils.py", line 227, in parse_video_url file_id = parse_qs(video_url).get('vid')[0] TypeError: 'NoneType' object is not subscriptable