ryry-cli 2.26__tar.gz → 2.28__tar.gz

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.
Files changed (29) hide show
  1. {ryry_cli-2.26/ryry_cli.egg-info → ryry_cli-2.28}/PKG-INFO +1 -1
  2. ryry_cli-2.28/ryry/constant.py +5 -0
  3. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/ryry_server_socket.py +9 -3
  4. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/ryry_webapi.py +2 -6
  5. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/ryry_widget.py +0 -3
  6. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/server_func.py +7 -2
  7. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/task.py +1 -1
  8. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/taskUtils.py +7 -0
  9. ryry_cli-2.28/ryry/upload.py +245 -0
  10. {ryry_cli-2.26 → ryry_cli-2.28/ryry_cli.egg-info}/PKG-INFO +1 -1
  11. {ryry_cli-2.26 → ryry_cli-2.28}/setup.py +1 -1
  12. ryry_cli-2.26/ryry/constant.py +0 -5
  13. ryry_cli-2.26/ryry/upload.py +0 -106
  14. {ryry_cli-2.26 → ryry_cli-2.28}/LICENSE +0 -0
  15. {ryry_cli-2.26 → ryry_cli-2.28}/README.md +0 -0
  16. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/__init__.py +0 -0
  17. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/main.py +0 -0
  18. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/ryry_service.py +0 -0
  19. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/script_template/__init__.py +0 -0
  20. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/script_template/main.py +0 -0
  21. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/script_template/run.py +0 -0
  22. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/store.py +0 -0
  23. {ryry_cli-2.26 → ryry_cli-2.28}/ryry/utils.py +0 -0
  24. {ryry_cli-2.26 → ryry_cli-2.28}/ryry_cli.egg-info/SOURCES.txt +0 -0
  25. {ryry_cli-2.26 → ryry_cli-2.28}/ryry_cli.egg-info/dependency_links.txt +0 -0
  26. {ryry_cli-2.26 → ryry_cli-2.28}/ryry_cli.egg-info/entry_points.txt +0 -0
  27. {ryry_cli-2.26 → ryry_cli-2.28}/ryry_cli.egg-info/requires.txt +0 -0
  28. {ryry_cli-2.26 → ryry_cli-2.28}/ryry_cli.egg-info/top_level.txt +0 -0
  29. {ryry_cli-2.26 → ryry_cli-2.28}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ryry-cli
3
- Version: 2.26
3
+ Version: 2.28
4
4
  Summary: ryry tools
5
5
  Home-page: https://github.com/dalipenMedia
6
6
  Author: dalipen
@@ -0,0 +1,5 @@
1
+ #!!!!! do not change this file !!!!!
2
+ app_version="2.28"
3
+ app_bulld_number=228
4
+ app_bulld_anchor="Noh_2024-08-13 19:00:57.272337"
5
+ app_name="ryry-cli"
@@ -56,12 +56,17 @@ class RyryTaskExecutor(Thread):
56
56
  if data is None:
57
57
  break
58
58
  try:
59
+ print(f"======= get data = {data}")
59
60
  taskUUID = data["taskUUID"]
61
+ domain = ""
62
+ params_tmp = json.loads(data["data"])
63
+ if "domain" in params_tmp:
64
+ domain = params_tmp["domain"]
60
65
  timeout = 600
61
66
  if "timeout" in data:
62
67
  timeout = data["timeout"]
63
68
  taskUtils.taskPrint(taskUUID, f"{current_thread().name} === receive task : {taskUUID}")
64
- _appendTask(taskUUID)
69
+ _appendTask(taskUUID, domain)
65
70
  is_ok, msg, result = task.runTask(data, timeout)
66
71
  if is_ok == False:
67
72
  taskUtils.notifyTaskFail(taskUUID, msg)
@@ -113,11 +118,12 @@ def _readTaskConfig():
113
118
  def _saveTaskConfig(data):
114
119
  with open(task_config_file, 'w') as f:
115
120
  json.dump(data, f)
116
- def _appendTask(taskUUID):
121
+ def _appendTask(taskUUID, subDomain):
117
122
  lock.acquire()
118
123
  task_config = _readTaskConfig()
119
124
  task_config[taskUUID] = {
120
- "pts": calendar.timegm(time.gmtime())
125
+ "pts": calendar.timegm(time.gmtime()),
126
+ "domain": subDomain
121
127
  }
122
128
  task_config["last_task_pts"] = task_config[taskUUID]["pts"]
123
129
  _saveTaskConfig(task_config)
@@ -38,12 +38,8 @@ def _aigc_post(func, params, files={}, timeout=10):
38
38
  #======================================== Task Function ==============================
39
39
  def _extend():
40
40
  extInfo = store.readDeviceInfo()
41
- extInfo["app_version"] = constant.app_version
42
- extInfo["app_bulld_number"] = constant.app_bulld_number
43
- extInfo["app_name"] = constant.app_name
44
- extInfo["dts"] = datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S_%f')
45
- extInfo["trace_id"] = ''.join(str(uuid.uuid4()).split('-'))
46
- extInfo["host_name"] = utils.get_hostname()
41
+ extInfo["app"] = constant.app_name + " " + constant.app_version
42
+ extInfo["host"] = utils.get_hostname()
47
43
  return json.dumps(extInfo)
48
44
 
49
45
  def GetTask():
@@ -126,9 +126,6 @@ def setWidgetData(root, widgetid):
126
126
  data["widget_id"] = widgetid
127
127
  data["name"] = "Demo"
128
128
  data["version"] = "1.0"
129
- data["device_keys"] = [
130
- utils.generate_unique_id()
131
- ]
132
129
  data["cmd"] = os.path.join(root, "main.py")
133
130
  with open(os.path.join(root, "config.json"), 'w') as f:
134
131
  json.dump(data, f)
@@ -2,7 +2,7 @@ import time, urllib3, sys, os
2
2
  from threading import Thread, Lock
3
3
 
4
4
  from ryry import ryry_webapi
5
- from ryry import store
5
+ from ryry import upload
6
6
  from ryry import taskUtils
7
7
 
8
8
  lock = Lock()
@@ -40,7 +40,6 @@ class TaskThread(Thread):
40
40
  self.result = False, "Unknow"
41
41
  if len(self.func) > 0:
42
42
  self.checkUUID = ryry_webapi.createTask(self.func, self.params)
43
- print("")
44
43
  self.checking = True
45
44
  self.checkCount = 0
46
45
  time.sleep(5)
@@ -73,11 +72,17 @@ class Task:
73
72
  if realTaskUUID == None or len(realTaskUUID) <= 0:
74
73
  realTaskUUID = taskUtils.taskInfoWithFirstTask()
75
74
 
75
+ support_subdomain = upload.getFirstSupportSubdomain()
76
+ domain = ""
77
+ if support_subdomain:
78
+ domain = support_subdomain["readpath"]
79
+
76
80
  def _callback(idx, data):
77
81
  self.thread_data[str(idx)]["result"] = data
78
82
  idx = 0
79
83
  for param in multi_params:
80
84
  param["fromUUID"] = realTaskUUID
85
+ param["domain"] = domain
81
86
  self.thread_data[str(idx)] = {
82
87
  "thread" : TaskThread(idx, len(multi_params), func, param, _callback),
83
88
  "result" : None
@@ -73,7 +73,7 @@ def executeLocalPython(taskUUID, cmd, param, timeout):
73
73
  process = None
74
74
  try:
75
75
  if timeout == 0:
76
- timeout = 60*60 #max 1 hour expire time
76
+ timeout = 60*30 #max half hour expire time
77
77
  process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
78
78
  timeout_killprocess(process, timeout)
79
79
  output, error = process.communicate()
@@ -19,6 +19,13 @@ def taskInfoWithFirstTask():
19
19
  if it not in ["last_task_pts"]:
20
20
  return it
21
21
  return None
22
+ def taskDomainWithUUID(taskUUID):
23
+ if os.path.exists(task_config_file):
24
+ with open(task_config_file, 'r') as f:
25
+ task_config = json.load(f)
26
+ if taskUUID in task_config:
27
+ return task_config[taskUUID]["domain"]
28
+ return ""
22
29
 
23
30
  WECHAT_URL = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=f40c5fb0-2734-48b0-a2d0-0faedf7dd2e4"
24
31
  def uploadFile2Wechat(filepath):
@@ -0,0 +1,245 @@
1
+ from urllib.parse import *
2
+
3
+ def addtionExif(srcFile, taskUUID):
4
+ if taskUUID == None or len(taskUUID) == 0:
5
+ return
6
+ try:
7
+ from pathlib import Path
8
+ file_name = Path(srcFile).name
9
+ ext = file_name[file_name.index("."):].lower()
10
+ if ext in [".jpg", ".png", ".jpeg", ".bmp", ".webp", ".gif"]:
11
+ from PIL import Image
12
+ img = Image.open(srcFile)
13
+ exif_dict = {
14
+ "0th": { },
15
+ "Exif": { },
16
+ "1st": { },
17
+ "thumbnail": None,
18
+ "GPS": { }
19
+ }
20
+ import piexif
21
+ if taskUUID:
22
+ exif_dict["0th"] = {
23
+ piexif.ImageIFD.Software: f'make with ryry({taskUUID})'.encode(),
24
+ piexif.ImageIFD.Copyright: f'dalipen'.encode(),
25
+ }
26
+ exif_dict["Exif"] = {
27
+ piexif.ExifIFD.UserComment: f'make with ryry({taskUUID})'.encode(),
28
+ }
29
+ exif_dat = piexif.dump(exif_dict)
30
+ img.save(srcFile, "webp", quality=90, exif=exif_dat)
31
+ # elif ext in [".mp4",".mov",".avi",".wmv",".mpg",".mpeg",".rm",".ram",".flv",".swf",".ts"]:
32
+ # params = {}
33
+ # elif ext in [".mp3",".aac",".wav",".wma",".cda",".flac",".m4a",".mid",".mka",".mp2",".mpa",".mpc",".ape",".ofr",".ogg",".ra",".wv",".tta",".ac3",".dts"]:
34
+ # params = {}
35
+ # else:
36
+ # params = {}
37
+ except:
38
+ return
39
+
40
+ def transcode(srcFile):
41
+ try:
42
+ from pathlib import Path
43
+ from PIL import Image
44
+ file_name = Path(srcFile).name
45
+ ext = file_name[file_name.index("."):].lower()
46
+ if ext in [".jpg", ".png", ".jpeg", ".bmp"]:
47
+ image = Image.open(srcFile, "r")
48
+ format = image.format
49
+ if format.lower() != "webp":
50
+ fname = Path(srcFile).name
51
+ newFile = srcFile.replace(fname[fname.index("."):], ".webp")
52
+ image.save(newFile, "webp", quality=90)
53
+ image.close()
54
+ return True, newFile
55
+ except Exception as e:
56
+ pass
57
+ return False, srcFile
58
+
59
+ def additionalUrl(srcFile, ossUrl):
60
+ from pathlib import Path
61
+ from PIL import Image
62
+ try:
63
+ file_name = Path(srcFile).name
64
+ ext = file_name[file_name.index("."):].lower()
65
+ params = {}
66
+ if ext in [".jpg", ".png", ".jpeg", ".bmp", ".webp", ".gif"]:
67
+ img = Image.open(srcFile)
68
+ params["width"] = img.width
69
+ params["height"] = img.height
70
+ elif ext in [".mp4",".mov",".avi",".wmv",".mpg",".mpeg",".rm",".ram",".flv",".swf",".ts"]:
71
+ params = {}
72
+ elif ext in [".mp3",".aac",".wav",".wma",".cda",".flac",".m4a",".mid",".mka",".mp2",".mpa",".mpc",".ape",".ofr",".ogg",".ra",".wv",".tta",".ac3",".dts"]:
73
+ params = {}
74
+ else:
75
+ params = {}
76
+ parsed_url = urlparse(ossUrl)
77
+ updated_query_string = urlencode(params, doseq=True)
78
+ final_url = parsed_url._replace(query=updated_query_string).geturl()
79
+ return final_url
80
+ except:
81
+ return ossUrl
82
+
83
+ def upload(src, taskUUID, timeout=300, needTranscode=True):
84
+ import os
85
+ from pathlib import Path
86
+ from ryry import taskUtils
87
+ if os.path.exists(src) == False:
88
+ raise Exception(f"upload file not found")
89
+ if taskUUID==None or len(taskUUID) <= 0:
90
+ taskUUID = taskUtils.taskInfoWithFirstTask()
91
+ targetDomain = taskUtils.taskDomainWithUUID(taskUUID)
92
+
93
+ if needTranscode:
94
+ needDeleteSrc, newSrc = transcode(src)
95
+ else:
96
+ needDeleteSrc = False
97
+ newSrc = src
98
+ addtionExif(newSrc, taskUUID)
99
+ support_subdomain = getSubdomain(targetDomain)
100
+ if support_subdomain:
101
+ import uuid
102
+ file_name = Path(newSrc).name
103
+ ext = os.path.splitext(file_name)[-1][1:]
104
+ new_file_name = ''.join(str(uuid.uuid4()).split('-'))
105
+ ossurl = ftpUpload(newSrc, f"{new_file_name}.{ext}", support_subdomain)
106
+ else:
107
+ from ryry import ryry_webapi
108
+ file_name = Path(newSrc).name
109
+ ossurl = ryry_webapi.upload(newSrc, os.path.splitext(file_name)[-1][1:])
110
+
111
+ ossurl = additionalUrl(newSrc, ossurl)
112
+ if needDeleteSrc:
113
+ os.remove(newSrc)
114
+ return ossurl
115
+
116
+ def deepFtpUpload(file, new_file_name, ftp, writepath, readpath):
117
+ import ftplib, os
118
+ try:
119
+ ftp.cwd(writepath)
120
+ except ftplib.error_perm as e:
121
+ if e.args[0].startswith('550'):
122
+ ftp.mkd(writepath)
123
+ ftp.cwd(writepath)
124
+
125
+ with open(file, 'rb') as f:
126
+ ftp.storbinary(f'STOR {new_file_name}', f)
127
+ return f"{readpath}/{new_file_name}"
128
+
129
+ def ftpUpload(file, new_file_name, subdomain):
130
+ ip = subdomain["host"]
131
+ username = subdomain["username"]
132
+ password = subdomain["password"]
133
+ writepath = subdomain["writepath"]
134
+ readpath = subdomain["readpath"]
135
+ import ftplib
136
+ ftp = ftplib.FTP(ip)
137
+ ftp.login(username, password)
138
+
139
+ s = deepFtpUpload(file, new_file_name, ftp, writepath, readpath)
140
+ ftp.quit()
141
+ return s
142
+
143
+ def _can_connect_ftp(ip, username, password, writepath):
144
+ import ftplib
145
+ try:
146
+ ftp = ftplib.FTP(ip)
147
+ ftp.login(username, password)
148
+ try:
149
+ ftp.cwd(writepath)
150
+ except ftplib.error_perm as e:
151
+ if e.args[0].startswith('550'):
152
+ # 如果远程目录不存在,则创建它
153
+ ftp.mkd(writepath)
154
+ ftp.cwd(writepath)
155
+ ftp.quit()
156
+ return True
157
+ except Exception as e:
158
+ print(f"Failed to connect to FTP server {ip}:{writepath} {e}")
159
+ return False
160
+
161
+ SUBDOMAIN = {
162
+ "192.168.3.220": {
163
+ "host": "192.168.3.220",
164
+ "username" : "xinyu100",
165
+ "password" : "xinyu100.com",
166
+ "writepath" : "1TB01/data/cache/",
167
+ # "readpath" : "http://192.168.3.220/01/cache"
168
+ "readpath" : "ftp://192.168.3.220/1TB01/data/cache"
169
+ },
170
+ "192.168.50.113": {
171
+ "host" : "192.168.50.113",
172
+ "username" : "ftpuser",
173
+ "password" : "ftpuser",
174
+ "writepath" : "cache/",
175
+ "readpath" : "ftp://192.168.50.113/cache"
176
+ }
177
+ }
178
+ def getSubdomain(targetDomain):
179
+ if len(targetDomain) <= 0:
180
+ return None
181
+ for ip in SUBDOMAIN.keys():
182
+ if _can_connect_ftp(ip, SUBDOMAIN[ip]["username"], SUBDOMAIN[ip]["password"], SUBDOMAIN[ip]["writepath"]) and targetDomain == SUBDOMAIN[ip]["readpath"]:
183
+ return SUBDOMAIN[ip]
184
+ return None
185
+
186
+ def getFirstSupportSubdomain():
187
+ for ip in SUBDOMAIN.keys():
188
+ if _can_connect_ftp(ip, SUBDOMAIN[ip]["username"], SUBDOMAIN[ip]["password"], SUBDOMAIN[ip]["writepath"]):
189
+ return SUBDOMAIN[ip]
190
+ return None
191
+
192
+ def download(url, saveDir):
193
+ import uuid, requests, os
194
+ from urlparser import urlparser
195
+ from fake_useragent import UserAgent
196
+ if len(url) <= 0:
197
+ return None
198
+ try:
199
+ name = ''.join(str(uuid.uuid4()).split('-'))
200
+ ext = urlparser.urlparse(url).path[urlparser.urlparse(url).path.index("."):]
201
+ savePath = os.path.join(saveDir, f"{name}{ext}")
202
+
203
+ if url.startswith("ftp"):
204
+ import ftplib
205
+ parsed_url = urlparse(url)
206
+ host = parsed_url.hostname
207
+ if host in SUBDOMAIN:
208
+ ip = SUBDOMAIN[host]["host"]
209
+ username = SUBDOMAIN[host]["username"]
210
+ password = SUBDOMAIN[host]["password"]
211
+ writepath = SUBDOMAIN[host]["writepath"]
212
+ readpath = SUBDOMAIN[host]["readpath"]
213
+ ftp = ftplib.FTP(ip)
214
+ ftp.login(username, password)
215
+
216
+ remote_filepath = parsed_url.path[1:]
217
+ with open(savePath, 'wb') as f:
218
+ ftp.retrbinary(f'RETR {remote_filepath}', f.write)
219
+ ftp.quit()
220
+ else:
221
+ print(f"download fail: domain {host} not support")
222
+ elif url.startswith("http"):
223
+ requests.adapters.DEFAULT_RETRIES = 2
224
+ s = requests.session()
225
+ s.keep_alive = False
226
+ s.headers.update({'Connection':'close'})
227
+ ua = UserAgent()
228
+ file = s.get(url, verify=False, headers={'User-Agent': ua.random}, timeout=30)
229
+ if os.path.exists(savePath):
230
+ os.remove(savePath)
231
+ with open(savePath, "wb") as c:
232
+ c.write(file.content)
233
+ s.close()
234
+ if os.path.exists(savePath):
235
+ return savePath
236
+ else:
237
+ print(f"download success but file not found")
238
+ else:
239
+ print(f"url {url} not support")
240
+ except Exception as e:
241
+ print(f"download fail: {e}")
242
+ return None
243
+
244
+ # url = upload("D:\\0505.mp4", "111", 300)
245
+ # download(url, "D:\\")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ryry-cli
3
- Version: 2.26
3
+ Version: 2.28
4
4
  Summary: ryry tools
5
5
  Home-page: https://github.com/dalipenMedia
6
6
  Author: dalipen
@@ -3,7 +3,7 @@ import os
3
3
  import subprocess
4
4
  import datetime
5
5
 
6
- ryry_version = "2.26"
6
+ ryry_version = "2.28"
7
7
  ryry_build_number = int(ryry_version.replace(".",""))
8
8
  cur_dir = os.path.dirname(os.path.abspath(__file__))
9
9
  constanspy = os.path.join(cur_dir, "ryry", "constant.py")
@@ -1,5 +0,0 @@
1
- #!!!!! do not change this file !!!!!
2
- app_version="2.26"
3
- app_bulld_number=226
4
- app_bulld_anchor="Noh_2024-08-05 19:23:55.100225"
5
- app_name="ryry-cli"
@@ -1,106 +0,0 @@
1
- from urllib.parse import *
2
-
3
- def addtionExif(srcFile, taskUUID):
4
- if taskUUID == None or len(taskUUID) == 0:
5
- return
6
- try:
7
- from pathlib import Path
8
- file_name = Path(srcFile).name
9
- ext = file_name[file_name.index("."):].lower()
10
- if ext in [".jpg", ".png", ".jpeg", ".bmp", ".webp", ".gif"]:
11
- from PIL import Image
12
- img = Image.open(srcFile)
13
- exif_dict = {
14
- "0th": { },
15
- "Exif": { },
16
- "1st": { },
17
- "thumbnail": None,
18
- "GPS": { }
19
- }
20
- import piexif
21
- if taskUUID:
22
- exif_dict["0th"] = {
23
- piexif.ImageIFD.Software: f'make with ryry({taskUUID})'.encode(),
24
- piexif.ImageIFD.Copyright: f'dalipen'.encode(),
25
- }
26
- exif_dict["Exif"] = {
27
- piexif.ExifIFD.UserComment: f'make with ryry({taskUUID})'.encode(),
28
- }
29
- exif_dat = piexif.dump(exif_dict)
30
- img.save(srcFile, "webp", quality=90, exif=exif_dat)
31
- # elif ext in [".mp4",".mov",".avi",".wmv",".mpg",".mpeg",".rm",".ram",".flv",".swf",".ts"]:
32
- # params = {}
33
- # elif ext in [".mp3",".aac",".wav",".wma",".cda",".flac",".m4a",".mid",".mka",".mp2",".mpa",".mpc",".ape",".ofr",".ogg",".ra",".wv",".tta",".ac3",".dts"]:
34
- # params = {}
35
- # else:
36
- # params = {}
37
- except:
38
- return
39
-
40
- def transcode(srcFile):
41
- try:
42
- from pathlib import Path
43
- from PIL import Image
44
- file_name = Path(srcFile).name
45
- ext = file_name[file_name.index("."):].lower()
46
- if ext in [".jpg", ".png", ".jpeg", ".bmp"]:
47
- image = Image.open(srcFile, "r")
48
- format = image.format
49
- if format.lower() != "webp":
50
- fname = Path(srcFile).name
51
- newFile = srcFile.replace(fname[fname.index("."):], ".webp")
52
- image.save(newFile, "webp", quality=90)
53
- image.close()
54
- return True, newFile
55
- except Exception as e:
56
- pass
57
- return False, srcFile
58
-
59
- def additionalUrl(srcFile, ossUrl):
60
- from pathlib import Path
61
- from PIL import Image
62
- try:
63
- file_name = Path(srcFile).name
64
- ext = file_name[file_name.index("."):].lower()
65
- params = {}
66
- if ext in [".jpg", ".png", ".jpeg", ".bmp", ".webp", ".gif"]:
67
- img = Image.open(srcFile)
68
- params["width"] = img.width
69
- params["height"] = img.height
70
- elif ext in [".mp4",".mov",".avi",".wmv",".mpg",".mpeg",".rm",".ram",".flv",".swf",".ts"]:
71
- params = {}
72
- elif ext in [".mp3",".aac",".wav",".wma",".cda",".flac",".m4a",".mid",".mka",".mp2",".mpa",".mpc",".ape",".ofr",".ogg",".ra",".wv",".tta",".ac3",".dts"]:
73
- params = {}
74
- else:
75
- params = {}
76
- parsed_url = urlparse(ossUrl)
77
- updated_query_string = urlencode(params, doseq=True)
78
- final_url = parsed_url._replace(query=updated_query_string).geturl()
79
- return final_url
80
- except:
81
- return ossUrl
82
-
83
- def upload(src, taskUUID, timeout=300, needTranscode=True):
84
- import os
85
- from ryry import store
86
- from pathlib import Path
87
- from ryry import taskUtils
88
- from ryry import ryry_webapi
89
- import requests
90
- if os.path.exists(src) == False:
91
- raise Exception(f"upload file not found")
92
- if taskUUID==None or len(taskUUID) <= 0:
93
- taskUUID = taskUtils.taskInfoWithFirstTask()
94
-
95
- if needTranscode:
96
- needDeleteSrc, newSrc = transcode(src)
97
- else:
98
- needDeleteSrc = False
99
- newSrc = src
100
- addtionExif(newSrc, taskUUID)
101
- file_name = Path(newSrc).name
102
- ossurl = ryry_webapi.upload(newSrc, os.path.splitext(file_name)[-1][1:])
103
- ossurl = additionalUrl(newSrc, ossurl)
104
- if needDeleteSrc:
105
- os.remove(newSrc)
106
- return ossurl
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes