|
10 | 10 | from app.utils import RequestUtils |
11 | 11 | from app.extensions import VIDEO_EXTS, SUBTITLE_EXTS, IMAGE_EXTS, NFO_EXTS |
12 | 12 | from app.modules.alist import AlistClient, AlistPath |
13 | | - |
| 13 | +from app.modules.alist2strm.mode import Alist2StrmMode |
14 | 14 |
|
15 | 15 | class Alist2Strm: |
16 | 16 | def __init__( |
@@ -58,7 +58,7 @@ def __init__( |
58 | 58 | """ |
59 | 59 |
|
60 | 60 | self.client = AlistClient(url, username, password, token) |
61 | | - self.mode = mode |
| 61 | + self.mode = Alist2StrmMode.from_str(mode) |
62 | 62 |
|
63 | 63 | self.source_dir = source_dir |
64 | 64 | self.target_dir = Path(target_dir) |
@@ -159,13 +159,8 @@ def filter(path: AlistPath) -> bool: |
159 | 159 |
|
160 | 160 | return True |
161 | 161 |
|
162 | | - if self.mode not in ["AlistURL", "RawURL", "AlistPath"]: |
163 | | - logger.warning( |
164 | | - f"Alist2Strm 的模式 {self.mode} 不存在,已设置为默认模式 AlistURL" |
165 | | - ) |
166 | | - self.mode = "AlistURL" |
167 | 162 |
|
168 | | - if self.mode == "RawURL": |
| 163 | + if self.mode == Alist2StrmMode.RawURL: |
169 | 164 | is_detail = True |
170 | 165 | else: |
171 | 166 | is_detail = False |
@@ -194,7 +189,7 @@ def filter(path: AlistPath) -> bool: |
194 | 189 | logger.info(f"最大文件: {largest_file.full_path}") |
195 | 190 |
|
196 | 191 | # 重新获取详细信息以确保有 raw_url |
197 | | - if self.mode == "RawURL" and not largest_file.raw_url: |
| 192 | + if self.mode == Alist2StrmMode.RawURL and not largest_file.raw_url: |
198 | 193 | logger.debug(f"重新获取 BDMV 文件详细信息: {largest_file.full_path}") |
199 | 194 | try: |
200 | 195 | updated_path = await self.client.async_api_fs_get(largest_file.full_path) |
@@ -233,14 +228,12 @@ async def __file_processer(self, path: AlistPath) -> None: |
233 | 228 | logger.debug(f"__file_processer: 处理文件 {path.full_path} -> 本地路径 {local_path} | 模式 {self.mode}") |
234 | 229 |
|
235 | 230 | # 统一的 URL 生成逻辑,BDMV 文件与普通文件使用相同的逻辑 |
236 | | - if self.mode == "AlistURL": |
| 231 | + if self.mode == Alist2StrmMode.AlistURL: |
237 | 232 | content = path.download_url |
238 | | - elif self.mode == "RawURL": |
| 233 | + elif self.mode == Alist2StrmMode.RawURL: |
239 | 234 | content = path.raw_url |
240 | | - elif self.mode == "AlistPath": |
| 235 | + elif self.mode == Alist2StrmMode.AlistPath: |
241 | 236 | content = path.full_path |
242 | | - else: |
243 | | - raise ValueError(f"AlistStrm 未知的模式 {self.mode}") |
244 | 237 |
|
245 | 238 | logger.debug(f"__file_processer: 初始 content = {content}") |
246 | 239 |
|
|
0 commit comments