|
| 1 | +# MediaTool 参数说明和示例 |
| 2 | + |
| 3 | +## 1. 命令行支持的参数 |
| 4 | + |
| 5 | +### 可通过命令行传递的参数 |
| 6 | + |
| 7 | +| 参数 | 命令行标志 | 默认值 | 说明 | 示例 | |
| 8 | +|------|------------|--------|------|------| |
| 9 | +| config | `-config` | `"config.json"` | 配置文件路径 | `./pvideo -config myconfig.json` | |
| 10 | +| port | `-port` | `"2525"` | 服务器端口 | `./pvideo -port 8080` | |
| 11 | +| site | `-site` | `""` | 反代域名 | `./pvideo -site https://mydomain.com` | |
| 12 | +| proxy | `-proxy` | `""` | 代理地址 | `./pvideo -proxy socks5://127.0.0.1:1080` | |
| 13 | +| debug | `-debug` | `false` | 调试模式 | `./pvideo -debug` | |
| 14 | +| dns | `-dns` | `""` | DNS服务器 | `./pvideo -dns 8.8.8.8` | |
| 15 | + |
| 16 | +### 只能通过配置文件设置的参数 |
| 17 | + |
| 18 | +| 参数 | 类型 | 默认值 | 说明 | |
| 19 | +|------|------|--------|------| |
| 20 | +| localUrl | string | `""` | 本地服务URL,用于生成代理链接 | |
| 21 | +| connect | int64 | `32` | 最大并发连接数 | |
| 22 | +| ssl | object | `null` | SSL证书配置(cert, key) | |
| 23 | + |
| 24 | +### 命令行使用示例 |
| 25 | + |
| 26 | +```bash |
| 27 | +# 基本启动 |
| 28 | +./pvideo |
| 29 | + |
| 30 | +# 指定端口和调试模式 |
| 31 | +./pvideo -port 8080 -debug |
| 32 | + |
| 33 | +# 使用SOCKS5代理 |
| 34 | +./pvideo -proxy socks5://127.0.0.1:1080 -dns 8.8.8.8 |
| 35 | + |
| 36 | +# 完整参数示例 |
| 37 | +./pvideo -config config.json -port 7777 -site https://mydomain.com -proxy http://proxy.example.com:8080 -debug -dns 8.8.8.8 |
| 38 | +``` |
| 39 | + |
| 40 | +## 2. 多线程代理参数和示例 |
| 41 | + |
| 42 | +### 多线程代理支持的URL参数 |
| 43 | + |
| 44 | +| 参数 | 必需 | 说明 | 示例值 | |
| 45 | +|------|------|------|--------| |
| 46 | +| url | ✅ | 目标文件URL | `https://example.com/video.mp4` | |
| 47 | +| form | ❌ | 编码格式 | `base64`(URL和header使用base64编码) | |
| 48 | +| header | ❌ | 自定义请求头 | JSON格式的请求头 | |
| 49 | +| thread | ❌ | 线程数 | `4`(默认根据文件大小自动计算) | |
| 50 | +| size | ❌ | 分块大小 | `128K`(默认), `256K`, `1M`, `2M`, `512B`, `1024` | |
| 51 | +| limit | ❌ | 限制条件 | `30S`(时间限制), `100C`(次数限制) | |
| 52 | +| single | ❌ | 单线程模式 | `true`, `false` | |
| 53 | +| mark | ❌ | 缓存标记 | 自定义缓存标识 | |
| 54 | + |
| 55 | +### 多线程代理使用示例(也可以不需要带proxy路径:http://localhost:7777?url=https://example.com/video.mp4) |
| 56 | + |
| 57 | +#### 基本用法 |
| 58 | +``` |
| 59 | +http://localhost:7777/proxy?url=https://example.com/video.mp4 |
| 60 | +``` |
| 61 | + |
| 62 | +#### 自定义线程数和分块大小 |
| 63 | +``` |
| 64 | +http://localhost:7777/proxy?url=https://example.com/video.mp4&thread=8&size=256K |
| 65 | +``` |
| 66 | + |
| 67 | +#### 使用自定义请求头 |
| 68 | +``` |
| 69 | +http://localhost:7777/proxy?url=https://example.com/video.mp4&header={"User-Agent":"Custom-Agent","Referer":"https://example.com"} |
| 70 | +``` |
| 71 | + |
| 72 | +#### 使用base64编码(避免URL编码问题) |
| 73 | +``` |
| 74 | +http://localhost:7777/proxy?url=aHR0cHM6Ly9leGFtcGxlLmNvbS92aWRlby5tcDQ=&form=base64&header=eyJVc2VyLUFnZW50IjoiQ3VzdG9tLUFnZW50In0= |
| 75 | +``` |
| 76 | + |
| 77 | +#### 设置时间限制(30秒后重新获取真实URL) |
| 78 | +``` |
| 79 | +http://localhost:7777/proxy?url=https://example.com/video.mp4&limit=30S |
| 80 | +``` |
| 81 | + |
| 82 | +#### 设置次数限制(100次请求后重新获取真实URL) |
| 83 | +``` |
| 84 | +http://localhost:7777/proxy?url=https://example.com/video.mp4&limit=100C |
| 85 | +``` |
| 86 | + |
| 87 | +#### 单线程模式(适用于例如网页请求) |
| 88 | +``` |
| 89 | +http://localhost:7777/proxy?single=true&url=https://example.com/small-file.jpg |
| 90 | +``` |
| 91 | + |
| 92 | +#### 使用缓存标记(mark参数) |
| 93 | +``` |
| 94 | +# 任务1:普通下载 |
| 95 | +http://localhost:7777/proxy?url=https://example.com/video.mp4&mark=normal_download |
| 96 | +
|
| 97 | +# 任务2:带认证的下载(相同URL,不同处理方式) |
| 98 | +http://localhost:7777/proxy?url=https://example.com/video.mp4&mark=auth_download&header={"Authorization":"Bearer token123"} |
| 99 | +
|
| 100 | +# 任务3:移动端下载(相同URL,不同User-Agent) |
| 101 | +http://localhost:7777/proxy?url=https://example.com/video.mp4&mark=mobile_download&header={"User-Agent":"Mobile-App/1.0"} |
| 102 | +``` |
| 103 | + |
| 104 | +### 缓存标记(mark)说明 |
| 105 | + |
| 106 | +`mark` 参数是一个**缓存标识符**,用于区分和管理不同的下载任务: |
| 107 | + |
| 108 | +**主要作用**: |
| 109 | +1. **缓存隔离**: 相同URL的不同任务使用独立缓存 |
| 110 | +2. **连接复用**: 相同mark的请求复用HTTP连接 |
| 111 | +3. **任务标识**: 便于调试和日志追踪 |
| 112 | + |
| 113 | +**使用场景**: |
| 114 | + |
| 115 | +#### 场景1: 相同文件的不同下载方式 |
| 116 | +``` |
| 117 | +# 高清版本 |
| 118 | +http://localhost:7777/proxy?url=https://cdn.example.com/video.mp4&mark=hd_version&size=1M |
| 119 | +
|
| 120 | +# 标清版本(相同URL,不同处理参数) |
| 121 | +http://localhost:7777/proxy?url=https://cdn.example.com/video.mp4&mark=sd_version&size=256K |
| 122 | +``` |
| 123 | + |
| 124 | +#### 场景2: 不同用户的相同资源 |
| 125 | +``` |
| 126 | +# 用户A下载 |
| 127 | +http://localhost:7777/proxy?url=https://example.com/file.zip&mark=user_a&header={"Cookie":"session=abc123"} |
| 128 | +
|
| 129 | +# 用户B下载 |
| 130 | +http://localhost:7777/proxy?url=https://example.com/file.zip&mark=user_b&header={"Cookie":"session=def456"} |
| 131 | +``` |
| 132 | + |
| 133 | +#### 场景3: 不同平台的相同内容 |
| 134 | +``` |
| 135 | +# PC端下载 |
| 136 | +http://localhost:7777/proxy?url=https://example.com/app.apk&mark=pc_client |
| 137 | +
|
| 138 | +# 移动端下载 |
| 139 | +http://localhost:7777/proxy?url=https://example.com/app.apk&mark=mobile_client |
| 140 | +``` |
| 141 | + |
| 142 | +**默认行为**: |
| 143 | +- 如果不指定 `mark` 参数,系统会使用完整的 `url` 作为缓存标记 |
| 144 | +- 建议在有多种下载需求时主动设置 `mark` 参数 |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | +## 3. M3U8参数和示例 |
| 149 | + |
| 150 | +### M3U8支持的URL参数 |
| 151 | + |
| 152 | +| 参数 | 必需 | 说明 | 示例值 | |
| 153 | +|------|------|------|--------| |
| 154 | +| url | ✅ | M3U8播放列表URL | `https://example.com/playlist.m3u8` | |
| 155 | +| form | ❌ | 编码格式 | `base64`(URL和header使用base64编码) | |
| 156 | +| header | ❌ | 自定义请求头 | JSON格式的请求头 | |
| 157 | +| type | ❌ | 文件类型标识 | `m3u8` | |
| 158 | + |
| 159 | +### M3U8使用示例 |
| 160 | + |
| 161 | +#### 基本用法 |
| 162 | +``` |
| 163 | +http://localhost:7777/m3u8?url=https://example.com/playlist.m3u8 |
| 164 | +``` |
| 165 | + |
| 166 | +#### 使用自定义请求头 |
| 167 | +``` |
| 168 | +http://localhost:7777/m3u8?url=https://example.com/playlist.m3u8&header={"User-Agent":"Mozilla/5.0","Referer":"https://example.com"} |
| 169 | +``` |
| 170 | + |
| 171 | +#### 使用base64编码 |
| 172 | +``` |
| 173 | +http://localhost:7777/m3u8?url=aHR0cHM6Ly9leGFtcGxlLmNvbS9wbGF5bGlzdC5tM3U4&form=base64&header=eyJVc2VyLUFnZW50IjoiTW96aWxsYS81LjAifQ== |
| 174 | +``` |
| 175 | + |
| 176 | +#### 指定类型标识 |
| 177 | +``` |
| 178 | +http://localhost:7777/m3u8?url=https://example.com/playlist.m3u8&type=m3u8 |
| 179 | +``` |
| 180 | + |
| 181 | +### M3U8处理说明 |
| 182 | + |
| 183 | +1. **自动转换**: M3U8文件中的相对路径会自动转换为完整URL |
| 184 | +2. **代理重写**: 所有媒体文件URL会被重写为通过本地代理访问 |
| 185 | +3. **嵌套支持**: 支持嵌套的M3U8文件(主播放列表包含子播放列表) |
| 186 | +4. **加密支持**: 支持AES加密的M3U8流,密钥URL也会被代理 |
| 187 | +5. **Base64编码**: 当使用`form=base64`时,输出的代理URL也会使用base64编码 |
0 commit comments