xtn-tools-pro 1.0.1.2.0__py3-none-any.whl → 1.0.1.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # 说明:
5
+ # 音频、视频 处理
6
+ # History:
7
+ # Date Author Version Modification
8
+ # --------------------------------------------------------------------------------------------------
9
+ # 2025/5/1 xiatn V00.01.000 新建
10
+ # --------------------------------------------------------------------------------------------------
11
+ from moviepy.editor import VideoFileClip
12
+ from xtn_tools_pro.utils.file_utils import get_filename, get_parent_dir, path_join
13
+
14
+
15
+ def mp4_extracting_mp3(mp4_path, save_path=""):
16
+ """
17
+ 从mp4视频中提取音频
18
+ :param mp4_path:mp4文件路径
19
+ :param save_path:保存位置,默认在mp4文件目录下和mp4同名
20
+ :return:
21
+ """
22
+ video = VideoFileClip(mp4_path)
23
+ audio = video.audio
24
+ if save_path:
25
+ audio.write_audiofile(save_path)
26
+ return
27
+
28
+ dir_path = get_parent_dir(mp4_path, 1)
29
+ mp3_path = path_join(dir_path, f"{get_filename(mp4_path, suffix=False)}.mp3")
30
+ audio.write_audiofile(mp3_path)
31
+
32
+
33
+ if __name__ == '__main__':
34
+ pass
@@ -13,6 +13,7 @@ import pyotp
13
13
  import base64
14
14
  import hashlib
15
15
  import secrets
16
+ from Crypto.Cipher import AES
16
17
 
17
18
 
18
19
  def get_md5_32(s: str, is_upper=False):
@@ -176,5 +177,20 @@ def get_2FA(secret):
176
177
  return str(totp.now())
177
178
 
178
179
 
180
+ class A8:
181
+ def __init__(self, AES_key):
182
+ self.__AES_cipher = AES.new(AES_key, AES.MODE_ECB)
183
+
184
+ def data_en_pro(self, raw):
185
+ enc = self.__AES_cipher.encrypt(raw.encode('utf-8'))
186
+ result = base64.b64encode(enc).decode('utf-8')
187
+ return result
188
+
189
+ def data_de_pro(self, enc):
190
+ enc = base64.b64decode(enc)
191
+ result = self.__AES_cipher.decrypt(enc).decode('utf-8')
192
+ return result
193
+
194
+
179
195
  if __name__ == '__main__':
180
196
  print(get_2FA('ninqzrh367u3iahpi2mum36bgfvouv5m'))
@@ -10,7 +10,7 @@
10
10
  # --------------------------------------------------------------------------------------------------
11
11
  import os
12
12
  import re
13
-
13
+ from pathlib import Path
14
14
 
15
15
  def get_file_extension(file_name):
16
16
  """
@@ -80,7 +80,42 @@ def get_listdir(dir_path):
80
80
  return os.listdir(dir_path)
81
81
 
82
82
 
83
+ def get_filename(file_path, suffix=True):
84
+ """
85
+ 传入文件路径返回文件名
86
+ :param filename:文件路径
87
+ :param suffix:是否返回后缀名
88
+ :return:
89
+ """
90
+ file_path = Path(file_path)
91
+ if suffix:
92
+ return file_path.name
93
+ return file_path.stem
94
+
95
+
96
+ def get_parent_dir(file_path: str, levels: int = 1) -> str:
97
+ """
98
+ 获取文件的上几级目
99
+
100
+ :param file_path: 文件路径字符串
101
+ :param levels: 要向上获取的目录层级数(默认为1)
102
+ :return: 上级目录路径字符串
103
+ """
104
+ path = Path(file_path)
105
+ try:
106
+ return str(path.parents[levels - 1])
107
+ except IndexError:
108
+ raise ValueError(f"文件路径没有那么多层级(最多 {len(path.parents)} 层)")
109
+
110
+
111
+ def path_join(a_path,b_path):
112
+ """
113
+ 路径拼接
114
+ :param a_path:
115
+ :param b_path:
116
+ :return:
117
+ """
118
+ return os.path.join(a_path, b_path)
119
+
83
120
  if __name__ == '__main__':
84
121
  pass
85
- print(get_file_extension('file/2024-04-19/BOSCH GEX 125-1A/125-1AE砂磨机操作说明书:[1]_jingyan.txt'))
86
- print(get_file_check_filename('file/2024-04-19/BOSCH GEX 125-1A/125-1AE砂磨机操作说明书:[1]_jingyan.txt'))
@@ -120,9 +120,13 @@ class Log:
120
120
  # 记录日志文件的路径模板,用于之后创建新的日志文件
121
121
  self.path_template = f"logs/{{date}}/{name}.log"
122
122
  path = self.path_template.format(date=self.current_date)
123
+ # print(path)
123
124
  if is_write_to_file:
124
- mkdirs_dir_log_path = os.path.join(run_py_path, path)
125
- mkdirs_dir(mkdirs_dir_log_path)
125
+ mkdirs_dir_log_dirname = os.path.join(run_py_path, os.path.dirname(path))
126
+ self.mkdirs_dir_log_path = os.path.join(run_py_path, path)
127
+ # print(mkdirs_dir_log_dirname)
128
+ # print(mkdirs_dir_log_path)
129
+ mkdirs_dir(self.mkdirs_dir_log_path)
126
130
 
127
131
  # 创建日志格式化器
128
132
  # formatter = logging.Formatter('[%(now_datestr)s] [%(levelname)s] [%(func_name)s] - %(message)s') # 原
@@ -144,7 +148,7 @@ class Log:
144
148
  # 判断是否要写入文件
145
149
  if is_write_to_file:
146
150
  # 创建文件处理器
147
- file_handler = RotatingFileHandler(path, mode=mode, max_bytes=max_bytes,
151
+ file_handler = RotatingFileHandler(self.mkdirs_dir_log_path, mode=mode, max_bytes=max_bytes,
148
152
  backup_count=backup_count, encoding=encoding)
149
153
  # 设置文件处理器的格式化器
150
154
  file_handler.setFormatter(formatter)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xtn-tools-pro
3
- Version: 1.0.1.2.0
3
+ Version: 1.0.1.2.2
4
4
  Summary: xtn 开发工具
5
5
  Author: xtn
6
6
  Author-email: czw011122@gmail.com
@@ -19,5 +19,7 @@ Requires-Dist: PyJWT
19
19
  Requires-Dist: tqdm
20
20
  Requires-Dist: fabric
21
21
  Requires-Dist: pyotp
22
+ Requires-Dist: moviepy
23
+ Requires-Dist: pycryptodome
22
24
 
23
25
  xtnkk-tools
@@ -53,18 +53,19 @@ xtn_tools_pro/task_pro/go_fun_air_v1.py,sha256=25gHmW5aAV6nMY9Y6-wD7uQ_wqE39dr-e
53
53
  xtn_tools_pro/task_pro/go_fun_v2.py,sha256=SgcXgtEBGSVL1V2LyqO0z8Md2H8JZxucYrLLIwqtiLM,18489
54
54
  xtn_tools_pro/task_pro/go_fun_v3.py,sha256=qhsLr9vKDDNp6zqqN2GazCwHQpAhxjlNg7Juj0lyhkA,19616
55
55
  xtn_tools_pro/utils/__init__.py,sha256=I1_n_NP23F2lBqlF4EOlnOdLYxM8M4pbn63UhJN1hRE,418
56
- xtn_tools_pro/utils/crypto.py,sha256=fyqno82Tw8LeF5i8YiEpjPI3oswsqTeWE5Lc9M2ef68,4603
57
- xtn_tools_pro/utils/file_utils.py,sha256=obaBP7CaBCsXxzqGeWzV2l0yw7vicgKOaXzmpMV8ips,2567
56
+ xtn_tools_pro/utils/audio_video.py,sha256=3Im3tGOW6IbmqDcrE1SJUg6eGyLGEyq11Qu6TCutJJw,1115
57
+ xtn_tools_pro/utils/crypto.py,sha256=8uhfXbUacGQTe5yTS32QHuB43NKLgB7yt-vHsK2Jl0Y,5079
58
+ xtn_tools_pro/utils/file_utils.py,sha256=vsUgds8I8Z2pL9a4oCv1q0JrZsDP29qLyLyGVqj5sX8,3311
58
59
  xtn_tools_pro/utils/helpers.py,sha256=0CTMY7wfSQR_DC9-v1lkKQLpWcB1FL9V_kw_5DOcZ40,4454
59
- xtn_tools_pro/utils/log.py,sha256=V_NNFV6aFlQasj5Ejal2lo18EHWWCSOQiZf54j-Xhkg,10788
60
+ xtn_tools_pro/utils/log.py,sha256=DTUWwi5pvZrwwq94odGnR0JBhfStrc6SxcJREqf2Ls4,11031
60
61
  xtn_tools_pro/utils/retry.py,sha256=0wjHsR5DBBKpv4naMfxiky8kprrZes4WURIfFQ4H708,1657
61
62
  xtn_tools_pro/utils/set_data.py,sha256=BzCLbEDO83csDHBey8kP7SoE6kx6EjqE7OqRBY7k82s,17608
62
63
  xtn_tools_pro/utils/shell.py,sha256=s6sJedxLLQokcI1hF5YSD3qgGUPK0brNcP-D3-yv54I,3790
63
64
  xtn_tools_pro/utils/sql.py,sha256=EAKzbkZP7Q09j15Gm6o0_uq0qgQmcCQT6EAawbpp4v0,6263
64
65
  xtn_tools_pro/utils/time_utils.py,sha256=TUtzG61PeVYXhaQd6pBrXAdlz7tBispNIRQRcGhE2No,4859
65
- xtn_tools_pro-1.0.1.2.0.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
- xtn_tools_pro-1.0.1.2.0.dist-info/METADATA,sha256=Uq-pXRcnCK6soAPHfV2TX7om-AzcQeJQJ8EsLfKs-aY,545
67
- xtn_tools_pro-1.0.1.2.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
68
- xtn_tools_pro-1.0.1.2.0.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
69
- xtn_tools_pro-1.0.1.2.0.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
70
- xtn_tools_pro-1.0.1.2.0.dist-info/RECORD,,
66
+ xtn_tools_pro-1.0.1.2.2.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
+ xtn_tools_pro-1.0.1.2.2.dist-info/METADATA,sha256=T4yOFh24TiTc6KuRU2cUranDYrIq02AAdKSpAGxZVuY,598
68
+ xtn_tools_pro-1.0.1.2.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
69
+ xtn_tools_pro-1.0.1.2.2.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
70
+ xtn_tools_pro-1.0.1.2.2.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
71
+ xtn_tools_pro-1.0.1.2.2.dist-info/RECORD,,