@@ -77,6 +77,12 @@ def resource_path(relative_path):
77
77
# logger.info(sys.argv)
78
78
# print(sys.argv)
79
79
80
+ # # 测试
81
+ # if not getattr(sys, 'frozen', False) and len(sys.argv) == 1:
82
+ # # 直接运行的目标路径
83
+ # # sys.argv.append(r'\\DSM\DSM_share5\season1\aaa E02 AAA.mp4')
84
+ # sys.argv.append(r'\\DSM\DSM_share5\season1')
85
+
80
86
if len (sys .argv ) > 1 and not sys .argv [1 ].startswith ('-' ):
81
87
# 旧版的命令解析
82
88
# 简单通过判断是否有 - 来区分新旧参数
@@ -135,12 +141,10 @@ def resource_path(relative_path):
135
141
if not target_path :
136
142
# 没有路径参数直接退出
137
143
sys .exit ()
138
- # 1 / 0
139
- # 直接运行的目标路径
140
- target_path = r'E:\test\极端试验样本'
141
- target_path = r'E:\test\极端试验样本\S1'
142
144
143
- target_path = target_path .replace ('\\ ' , '/' ).replace ('//' , '/' )
145
+ # 除samba格式的路径外 其它格式的路径斜杠统一处理
146
+ if not target_path .startswith (r'\\' ):
147
+ target_path = target_path .replace ('\\ ' , '/' ).replace ('//' , '/' )
144
148
145
149
# 忽略字符串, 用于处理剧集名字中带数字的文件, 提取信息时忽略这些字符串
146
150
# ignore 文件必须用utf-8编码
@@ -287,10 +291,22 @@ def get_season(parent_folder_name):
287
291
288
292
def format_path (file_path ):
289
293
# 修正路径斜杠
290
- if system == 'Windows' :
291
- return file_path .replace ('//' , '/' ).replace ('/' , '\\ ' )
292
- return file_path .replace ('\\ ' , '/' ).replace ('//' , '/' )
293
294
295
+ # samba路径特殊处理
296
+ if file_path .startswith ('//' ):
297
+ return '\\ ' + file_path .replace ('//' , '/' ).replace ('/' , '\\ ' )
298
+ else :
299
+ if system == 'Windows' :
300
+ return file_path .replace ('//' , '/' ).replace ('/' , '\\ ' )
301
+ return file_path .replace ('\\ ' , '/' ).replace ('//' , '/' )
302
+
303
+ def get_absolute_path (file_path ):
304
+ # 获取绝对路径
305
+ if file_path .startswith (r'\\' ):
306
+ # samba 路径特殊处理
307
+ return file_path .replace ('\\ ' , '/' )
308
+ else :
309
+ return os .path .abspath (target_path .replace ('\\ ' , '/' ))
294
310
295
311
def get_season_cascaded (full_path ):
296
312
# 逐级向上解析目录季数
@@ -713,8 +729,7 @@ def clean_name(s):
713
729
continue
714
730
715
731
# 完整文件路径
716
- file_path = os .path .join (root , name ).replace ('\\ ' , '/' )
717
- file_path = os .path .abspath (file_path )
732
+ file_path = get_absolute_path (os .path .join (root , name ))
718
733
parent_folder_path = os .path .dirname (file_path )
719
734
season , ep = get_season_and_ep (file_path )
720
735
resolution = get_resolution_in_name (name )
@@ -747,7 +762,7 @@ def clean_name(s):
747
762
else :
748
763
logger .info (f"{ '单文件处理' } " )
749
764
logger .info (f'{ target_path } ' )
750
- file_path = os . path . abspath (target_path . replace ( ' \\ ' , '/' ) )
765
+ file_path = get_absolute_path (target_path )
751
766
file_name , ext = get_file_name_ext (target_path )
752
767
parent_folder_path = os .path .dirname (file_path )
753
768
if ext .lower () in COMPOUND_EXTS :
0 commit comments