吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4111|回复: 67
收起左侧

[Web逆向] 利用土办法+AI编写的视频下载脚本过程复现

  [复制链接]
pwp 发表于 2025-4-9 09:17
写在最前:年前,学校某位领导参加了一个省级培训,他认为课程很好,想保存下来二天给他下属学习,故而让我把这视频down下来。
image.png


时间一晃就过去了大半年,我早已把这事忘得乙肝二静了,前几天他又问我,下好没,我谎称视频太多,才下得几集,并承诺清明下好。于是就准备大肝一次。

逆向了好半天,时间一点一滴地过去了,已经来到凌晨2点多,都模拟不出来,这里我就不赘述这个过程了。

无奈准备放弃,突然零机移动,既然我不能逆向怎么拿到视频地址,我直接复制服务器给的地址下载不就行啦?

直接上我的土办法:

1、既然服务器发送了课程的全部视频给我,还是json格式的:

image.png


2、那我不直接问ai写下载脚本就行啦:

image.png

image.png


3、稍等110秒,就出来脚本了:

image.png


4、打工搞成,给大家json和python玩玩:

[XML] 纯文本查看 复制代码
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
{
    "status": 200,
    "data": {
        "id": "26359",
        "code": "XMTSKC001002",
        "name": "学校安全教育的定位、职责与标准",
        "recommendLearnTime": 12,
        "sectionCount": 0,
        "teacher": "李雯",
        "introduction": "<p>                                 课程站在学校安全教育实践的视角,通过理论阐述和案例分析,确定了学校安全教育的基本定位、讲解了学校安全教育的主要职责,明确了学校安全教育的实施标准,总结了学校安全教育的创新探索。本专题课程旨在为中小学校长和教师理解、设计和实施学校安全教育提供整体思路和重要启发。                     </p>",
        "resourceItemList": [
            {
                "itemId": "32047a9f-9aa0-439d-8349-49d0f8118388",
                "parentItemId": "00000000-0000-0000-0000-000000000000",
                "directory": false,
                "itemName": "内容提要",
                "resourceId": "441",
                "resourceUrl": "https://doc.xiaoben365.com/Attachment/SCORM/86FCE567-4C8B-44DF-8247-F02D7028B881/intro.html",
                "resourceType": "URL",
                "breakPoint": 0,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "d31fadcc-1caf-44ba-a373-f451e76f9c27",
                "parentItemId": "00000000-0000-0000-0000-000000000000",
                "directory": true,
                "itemName": "第一讲 学校安全教育的基本定位",
                "breakPoint": 0,
                "finished": false,
                "lastTimeView": false
            },
            {
                "itemId": "389fdd42-5577-4dd6-bdb3-7f9fa0e197d4",
                "parentItemId": "d31fadcc-1caf-44ba-a373-f451e76f9c27",
                "directory": false,
                "itemName": "第一节 从法律、法规的要求看(一)",
                "resourceId": "443",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/1_1_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 0,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "465760db-5912-4fe5-b757-92f49c982bd2",
                "parentItemId": "d31fadcc-1caf-44ba-a373-f451e76f9c27",
                "directory": false,
                "itemName": "第二节 从法律、法规的要求看(二)",
                "resourceId": "445",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/1_2_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 374,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "5cde65e3-f7c4-404f-b7f9-5bc1e66a38f6",
                "parentItemId": "d31fadcc-1caf-44ba-a373-f451e76f9c27",
                "directory": false,
                "itemName": "第三节 从学校安全工作的构成看",
                "resourceId": "447",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/1_3_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 476,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "9df8883e-29e5-4d59-9833-86ffc0c1ba7d",
                "parentItemId": "d31fadcc-1caf-44ba-a373-f451e76f9c27",
                "directory": false,
                "itemName": "第四节 从安全教育在学校工作全局中的位置看",
                "resourceId": "449",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/1_4_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 0,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "082b5d9b-db45-4749-96a8-216be496b457",
                "parentItemId": "00000000-0000-0000-0000-000000000000",
                "directory": true,
                "itemName": "第二讲 学校安全教育的岗位职责",
                "breakPoint": 0,
                "finished": false,
                "lastTimeView": false
            },
            {
                "itemId": "02d42401-c8f6-4f31-9b0f-b20e6184501f",
                "parentItemId": "082b5d9b-db45-4749-96a8-216be496b457",
                "directory": false,
                "itemName": "第一节 《学校岗位安全工作指导手册》介绍",
                "resourceId": "451",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/2_1_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 788,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "35f6ea85-b5c3-46af-8814-642ea8540936",
                "parentItemId": "082b5d9b-db45-4749-96a8-216be496b457",
                "directory": false,
                "itemName": "第二节 不同岗位教师的安全岗位职责(一)",
                "resourceId": "453",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/2_2_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 1,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "57574909-4c68-48aa-944f-0bcfbfca3aff",
                "parentItemId": "082b5d9b-db45-4749-96a8-216be496b457",
                "directory": false,
                "itemName": "第三节 不同岗位教师的安全岗位职责(二)",
                "resourceId": "455",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/2_3_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 5,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "2a701ffb-57ae-4a61-9fee-b529a5995973",
                "parentItemId": "082b5d9b-db45-4749-96a8-216be496b457",
                "directory": false,
                "itemName": "第四节 使用要点",
                "resourceId": "457",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/2_4_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 253,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "parentItemId": "00000000-0000-0000-0000-000000000000",
                "directory": true,
                "itemName": "第三讲 学校安全教育的实施标准",
                "breakPoint": 0,
                "finished": false,
                "lastTimeView": false
            },
            {
                "itemId": "b8a65f5c-a550-449c-aef4-38abe48d9ba4",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第一节 基本情况",
                "resourceId": "459",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_1_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 242,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "8cf37c0c-e751-4fcb-88e0-6051f35bef32",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第二节 学校安全教育的指导思想和目标",
                "resourceId": "461",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_2_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 747,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "e101d0d1-0f24-4147-85a5-65784d1691e9",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第三节 学校安全教育的内容(一)分学段设置内容",
                "resourceId": "463",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_3_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 165,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "66e93371-fa09-433f-8214-257eb36a3e4f",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第四节 学校安全教育的内容(二)六个内容模块",
                "resourceId": "465",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_4_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 790,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "fb6f3bcd-a900-4766-88b6-1d538c74dffd",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第五节 学校安全教育的内容(三)不同学段内容的侧重点",
                "resourceId": "467",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_5_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 555,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "3695338b-265d-4092-81bb-744ea065a825",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第六节 学校安全教育的内容(四)不同学段的模块安排(一)",
                "resourceId": "469",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_6_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 448,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "b03b0dd0-b109-4673-a814-880cc3c60448",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第七节 学校安全教育的内容(五)不同学段的模块安排(二)",
                "resourceId": "471",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_7_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 659,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "74289706-6203-496e-b044-a78ddea3e06b",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第八节 学校安全教育的内容(六)不同学段的模块安排(三)",
                "resourceId": "473",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_8_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 691,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "ee3a913c-059c-4a91-a547-4462d5fe12d5",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第九节 学校安全教育的内容(七)不同学段的模块安排(四)",
                "resourceId": "475",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_9_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 395,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "ad8e1139-c47b-4cf5-a576-f7528b89a262",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第十节 学校安全教育的内容(八)不同学段的模块安排(五)",
                "resourceId": "477",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_10_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 207,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "62d0e4fa-7d93-41da-92c0-422b095a5e93",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第十一节 安全教育的实施原则、途径和方法",
                "resourceId": "479",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_11_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 268,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "50ad30df-b6eb-4bcd-b811-0997f335c0d7",
                "parentItemId": "15ec3146-ca0c-4267-b429-d9663d74965b",
                "directory": false,
                "itemName": "第十二节 学校安全教育的保障机制",
                "resourceId": "481",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/3_12_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 182,
                "finished": true,
                "lastTimeView": false
            },
            {
                "itemId": "0023840e-2d19-41b6-b942-af231639fa63",
                "parentItemId": "00000000-0000-0000-0000-000000000000",
                "directory": true,
                "itemName": "第四讲 安全教育的实施原则、途径和方法",
                "breakPoint": 0,
                "finished": false,
                "lastTimeView": false
            },
            {
                "itemId": "eb26bde6-530c-44ef-97f3-6a61f42078b5",
                "parentItemId": "0023840e-2d19-41b6-b942-af231639fa63",
                "directory": false,
                "itemName": "第一节 学校安全教育的创新探索(一)",
                "resourceId": "483",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/4_1_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 0,
                "finished": true,
                "lastTimeView": true
            },
            {
                "itemId": "ab826dc4-f266-46ec-8577-ad9bfdeed9a2",
                "parentItemId": "0023840e-2d19-41b6-b942-af231639fa63",
                "directory": false,
                "itemName": "第二节 学校安全教育的创新探索(二)",
                "resourceId": "485",
                "resourceUrl": "https://gpmp4.open.com.cn/M604/guopei_mp4/2014/gz_ts/XMTS0901/4_2_g.mp4",
                "resourceType": "VIDEO",
                "breakPoint": 217,
                "finished": true,
                "lastTimeView": false
            }
        ],
        "reportLearnTime": false,
        "selectedInRequired": false,
        "selectedInOptional": true
    },
    "time": "1744160879956"
}




[Python] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import json
import os
import re
import requests
from uuid import UUID
 
 
def sanitize_filename(filename):
    """清理文件名中的非法字符"""
    return re.sub(r'[\\/*?:"<>|]', '_', filename).strip()
 
 
# 从文件读取JSON数据
with open('mp4json.json', 'r', encoding='utf-8') as f:
    data = json.load(f)
 
course_name = sanitize_filename(data['data']['name'])
save_dir = os.path.join(os.getcwd(), course_name)
os.makedirs(save_dir, exist_ok=True)
 
# 构建目录结构映射表
dir_structure = {}
for item in data['data']['resourceItemList']:
    item_id = item['itemId']
    if item['directory']:
        dir_structure[item_id] = {
            'name': sanitize_filename(item['itemName']),
            'parent': item['parentItemId']
        }
 
 
def get_full_path(item_id, path=[]):
    if str(item_id) == '00000000-0000-0000-0000-000000000000':
        return []
    node = dir_structure.get(item_id, {})
    if node.get('parent'):
        return get_full_path(node['parent']) + [node['name']]
    return [node['name']]
 
 
headers = {'User-Agent': 'Mozilla/5.0'}
 
for item in data['data']['resourceItemList']:
    if item.get('resourceType') == 'VIDEO':
        parent_id = item['parentItemId']
        path_components = get_full_path(parent_id)
 
        final_dir = os.path.join(save_dir, *path_components)
        os.makedirs(final_dir, exist_ok=True)
 
        video_name = sanitize_filename(item['itemName']) + '.mp4'
        file_path = os.path.join(final_dir, video_name)
 
        if os.path.exists(file_path):
            print(f'Skipped: {file_path}')
            continue
 
        print(f'Downloading: {file_path}')
        try:
            with requests.get(item['resourceUrl'], headers=headers, stream=True, timeout=30) as r:
                r.raise_for_status()
                with open(file_path, 'wb') as f:
                    for chunk in r.iter_content(chunk_size=8192):
                        f.write(chunk)
            print(f'Success: {file_path}')
        except Exception as e:
            print(f'Failed: {file_path}, Error: {str(e)}')
            if os.path.exists(file_path):
                os.remove(file_path)
 
print('All downloads completed!')


免费评分

参与人数 12吾爱币 +15 热心值 +11 收起 理由
bullshit + 1 + 1 谢谢@Thanks!
jaffa + 1 谢谢@Thanks!
feishibudong + 1 用心讨论,共获提升!
wuai5211314 + 1 热心回复!
a3426 + 1 + 1 看不懂
command200 + 1 + 1 你是老师吗?字都打错这么多
yuweb + 1 + 1 热心回复!
涛之雨 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
niga + 1 + 1 谢谢@Thanks!
huangkang2297 + 1 + 1 热心回复!
shengruqing + 1 我很赞同!
xiaobu666 + 1 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

wudalang123 发表于 2025-4-10 16:52

  • 采用aiohttp实现异步下载,速度提升5-8倍

  • 使用连接池限制并发数(建议10-20),避免触发反爬
  • [Python] 纯文本查看 复制代码
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    import aiohttp
    import asyncio
    from aiofiles import open as aio_open
     
    async def async_download(session, url, path):
        async with session.get(url) as response:
            async with aio_open(path, 'wb') as f:
                async for chunk in response.content.iter_chunked(1024*1024):
                    await f.write(chunk)
     
    async def main():
        conn = aiohttp.TCPConnector(limit=10, ssl=False)
        async with aiohttp.ClientSession(connector=conn) as session:
            tasks = [async_download(session, item['url'], path) for item in video_list]
            await asyncio.gather(*tasks)

免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
pwp + 1 + 1 谢谢@Thanks!

查看全部评分

52pojie11023995 发表于 2025-4-9 11:15
dfy167 发表于 2025-4-9 09:30
8204118 发表于 2025-4-9 09:21
不懂什么意思
k11838959 发表于 2025-4-9 09:29
不懂意思
lj149446 发表于 2025-4-9 09:30
人家都给你返回地址了,你从json里提取地址,发送请求就 行了啊,
may5422 发表于 2025-4-9 09:32
谢谢用心分享,受益
AlanDreamtrave 发表于 2025-4-9 09:32
学习一下看看
 楼主| pwp 发表于 2025-4-9 09:38
dfy167 发表于 2025-4-9 09:30
现在很多都不能这么下了吧

这个网站打定教师都不会下视频,视频没做防反扒措施
ZhangShaoyan 发表于 2025-4-9 09:39
学习一下
xiaobu666 发表于 2025-4-9 09:39
不明白什么意思呢
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-5-18 19:31

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表