bizydraft 0.2.83__py3-none-any.whl → 0.2.83.dev20251203095346__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.
@@ -229,7 +229,6 @@ def human_readable_size(size_bytes):
229
229
 
230
230
 
231
231
  async def view_video(request):
232
- """处理VHS插件的viewvideo接口,支持从OSS URL加载视频"""
233
232
  logger.debug(
234
233
  f"Received request for /vhs/viewvideo with query: {request.rel_url.query}"
235
234
  )
@@ -238,23 +237,39 @@ async def view_video(request):
238
237
  logger.warning("'filename' not provided in query string, returning 404")
239
238
  return web.Response(status=404, text="'filename' not provided in query string")
240
239
 
241
- # VHS插件的filename参数本身就是完整的URL(可能是URL编码的)
242
240
  filename = unquote(request.rel_url.query["filename"])
241
+ subfolder = request.rel_url.query.get("subfolder", "")
243
242
 
244
243
  http_prefix_options = ("http:", "https:")
245
244
 
246
- if not filename.startswith(http_prefix_options):
247
- logger.warning(f"Invalid filename format: {filename=}, only URLs are supported")
245
+ if not filename.startswith(http_prefix_options) and "http" not in subfolder:
246
+ logger.warning(
247
+ f"Invalid filename format: {filename=}, {subfolder=} only URLs are supported"
248
+ )
248
249
  return web.Response(
249
250
  status=400, text="Invalid filename format(only url supported)"
250
251
  )
251
252
 
252
253
  try:
253
- content_type, _ = mimetypes.guess_type(filename)
254
+ if "http" in subfolder:
255
+ subfolder = subfolder[subfolder.find("http") :]
256
+ subfolder = unquote(subfolder)
257
+ if "https:/" in subfolder and not subfolder.startswith("https://"):
258
+ subfolder = subfolder.replace("https:/", "https://", 1)
259
+ if "http:/" in subfolder and not subfolder.startswith("http://"):
260
+ subfolder = subfolder.replace("http:/", "http://", 1)
261
+
262
+ full_url = (
263
+ f"{subfolder}/{filename}"
264
+ if not filename.startswith(http_prefix_options)
265
+ else filename
266
+ )
267
+
268
+ content_type, _ = mimetypes.guess_type(full_url)
254
269
 
255
270
  timeout = ClientTimeout(total=BIZYDRAFT_REQUEST_TIMEOUT)
256
271
  async with ClientSession(timeout=timeout) as session:
257
- async with session.get(filename) as resp:
272
+ async with session.get(full_url) as resp:
258
273
  resp.raise_for_status()
259
274
 
260
275
  # 优先使用服务器返回的Content-Type
@@ -17,6 +17,19 @@ function stripTypeSuffix(value) {
17
17
  if (!value || typeof value !== 'string') return value;
18
18
  return value.replace(/\s\[(input|output)\]$/i, '');
19
19
  }
20
+
21
+ function stripClipspacePrefix(subfolder) {
22
+ return typeof subfolder === 'string' ? subfolder.replace(/^clipspace\//, '') : subfolder;
23
+ }
24
+
25
+ function normalizeProtocolBase(base) {
26
+ return typeof base === 'string' ? base.replace(/^(https?:)\/+/, '$1//') : base;
27
+ }
28
+
29
+ function joinBaseAndFile(base, file) {
30
+ const sep = base.endsWith('/') ? '' : '/';
31
+ return `${base}${sep}${file}`;
32
+ }
20
33
  // ═══════════════════════════════════════════════════════════════════════════
21
34
  // 工具函数:替换 clipspace URL 为 OSS URL
22
35
  // ═══════════════════════════════════════════════════════════════════════════
@@ -29,6 +42,7 @@ function replaceClipspaceUrl(urlString) {
29
42
  const filename = url.searchParams.get('filename');
30
43
  const subfolder = url.searchParams.get('subfolder');
31
44
 
45
+ // subfolder 为 "clipspace",尝试映射为 OSS URL
32
46
  if (subfolder === 'clipspace' && filename) {
33
47
  const ossUrl = findOssUrl(filename);
34
48
  if (ossUrl) {
@@ -37,6 +51,15 @@ function replaceClipspaceUrl(urlString) {
37
51
  return url.pathname + url.search;
38
52
  }
39
53
  }
54
+ // 2) subfolder 形如 "clipspace/https:/..." 或 "clipspace/http:/..."
55
+ if (typeof subfolder === 'string' && subfolder.startsWith('clipspace/')) {
56
+ const fixedBase = normalizeProtocolBase(stripClipspacePrefix(subfolder));
57
+ if (filename) {
58
+ url.searchParams.set('filename', joinBaseAndFile(fixedBase, filename));
59
+ url.searchParams.set('subfolder', '');
60
+ return url.pathname + url.search;
61
+ }
62
+ }
40
63
  } catch (e) {
41
64
  console.error('[BizyDraft] Error replacing clipspace URL:', e);
42
65
  }
@@ -78,8 +101,7 @@ const originalFetchApi = api.fetchApi;
78
101
  api.fetchApi = async function(url, options) {
79
102
  const response = await originalFetchApi.call(this, url, options);
80
103
 
81
- const isUploadApi = url === '/upload/image' || url === '/upload/mask'
82
- || url === '/api/upload/image' || url === '/api/upload/mask';
104
+ const isUploadApi = url.includes('/upload/image') || url.includes('/upload/mask');
83
105
 
84
106
  if (!isUploadApi || !response.ok) {
85
107
  return response;
@@ -156,11 +178,20 @@ api.fetchApi = async function(url, options) {
156
178
  // 修改 clipspace.images
157
179
  if (clipspace.images && clipspace.images.length > 0) {
158
180
  const clipImage = clipspace.images[clipspace.selectedIndex || 0];
159
- if (clipImage && clipImage.subfolder === 'clipspace') {
160
- clipspace.images[clipspace.selectedIndex || 0] = {
161
- filename: finalUrl,
162
- subfolder: ''
163
- };
181
+ if (clipImage) {
182
+ if (clipImage.subfolder === 'clipspace') {
183
+ clipspace.images[clipspace.selectedIndex || 0] = {
184
+ filename: finalUrl,
185
+ subfolder: ''
186
+ };
187
+ } else if (typeof clipImage.subfolder === 'string' && clipImage.subfolder.startsWith('clipspace/')) {
188
+ const fixedBase = normalizeProtocolBase(stripClipspacePrefix(clipImage.subfolder));
189
+ const file = clipImage.filename || data.name;
190
+ clipspace.images[clipspace.selectedIndex || 0] = {
191
+ filename: joinBaseAndFile(fixedBase, file),
192
+ subfolder: ''
193
+ };
194
+ }
164
195
  }
165
196
  }
166
197
 
@@ -169,17 +200,30 @@ api.fetchApi = async function(url, options) {
169
200
  const imageWidgetIndex = clipspace.widgets.findIndex(w => w.name === 'image');
170
201
  if (imageWidgetIndex >= 0) {
171
202
  const widgetValue = clipspace.widgets[imageWidgetIndex].value;
172
- if (widgetValue && typeof widgetValue === 'object' && widgetValue.subfolder === 'clipspace') {
173
- clipspace.widgets[imageWidgetIndex].value = {
174
- filename: finalUrl,
175
- subfolder: ''
176
- };
203
+ if (widgetValue && typeof widgetValue === 'object') {
204
+ if (widgetValue.subfolder === 'clipspace') {
205
+ clipspace.widgets[imageWidgetIndex].value = {
206
+ filename: finalUrl,
207
+ subfolder: ''
208
+ };
209
+ } else if (typeof widgetValue.subfolder === 'string' && widgetValue.subfolder.startsWith('clipspace/')) {
210
+ const fixedBase = normalizeProtocolBase(stripClipspacePrefix(widgetValue.subfolder));
211
+ const file = (typeof widgetValue.filename === 'string' && widgetValue.filename) ? widgetValue.filename : data.name;
212
+ clipspace.widgets[imageWidgetIndex].value = {
213
+ filename: joinBaseAndFile(fixedBase, file),
214
+ subfolder: ''
215
+ };
216
+ }
217
+ } else if (typeof widgetValue === 'string' && widgetValue.startsWith('clipspace/')) {
218
+ // 处理 value 为字符串且包含 clipspace/ 前缀的情况
219
+ const fixedUrl = normalizeProtocolBase(stripClipspacePrefix(widgetValue));
220
+ clipspace.widgets[imageWidgetIndex].value = fixedUrl;
177
221
  }
178
222
  }
179
223
  }
180
224
  }
181
225
 
182
- // 篡改响应,让 ComfyUI 使用完整的 OSS URL
226
+ // 非视频类型:篡改响应,让 ComfyUI 使用完整的 OSS URL
183
227
  const modifiedData = { ...data, name: finalUrl, subfolder: '' };
184
228
  return new Response(JSON.stringify(modifiedData), {
185
229
  status: response.status,
@@ -17,13 +17,9 @@ const extMap = {
17
17
  "VHS_LoadVideo": '.mp4,.mov,.avi,.mkv,.webm,.flv,.wmv,.m4v',
18
18
  }
19
19
  export function getCookie(name) {
20
- const cookies = document.cookie.split(';');
21
- for (let cookie of cookies) {
22
- const [key, value] = cookie.trim().split('=');
23
- if (key === name) {
24
- return value;
25
- }
26
- }
20
+ const value = `; ${document.cookie}`;
21
+ const parts = value.split(`; ${name}=`);
22
+ if (parts.length === 2) return parts.pop().split(';').shift();
27
23
  return null;
28
24
  }
29
25
  export const hideWidget = (node, widget_name) => {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bizydraft
3
- Version: 0.2.83
3
+ Version: 0.2.83.dev20251203095346
4
4
  Summary: bizydraft
5
5
  Requires-Dist: loguru
6
6
  Requires-Dist: aiohttp
@@ -4,14 +4,14 @@ bizydraft/env.py,sha256=VFmGopVL2TGWA6hwxyFhIglCEcQxy6iVvL_raMNd6u4,407
4
4
  bizydraft/hijack_nodes.py,sha256=riHsp4DhU60E60bfXUl8kVqjs1QvQWmx_FsgQAdWTa4,4197
5
5
  bizydraft/hijack_routes.py,sha256=j7i9xAfaWvcu-mSoDISQyEwdERd0y-GFhvY2To7MRTU,5015
6
6
  bizydraft/oss_utils.py,sha256=IjWKFZ98KNvLw7bmFuqux5mEG36B8c9eQbQmL_gZo0M,16254
7
- bizydraft/patch_handlers.py,sha256=cP6gIYBYghWXI72hBbz3BbQHP1O5IvslS8iNK29MEbI,14159
7
+ bizydraft/patch_handlers.py,sha256=l9bNRttr2RjZJIKboZ3noYdeXLIDkXepoNrGLVFrhTk,14694
8
8
  bizydraft/postload.py,sha256=XFElKcmCajT_oO7SVJJBaN04XcWro54N5HB5cSCxfvI,1308
9
9
  bizydraft/prestartup_patch.py,sha256=4FGjmRcDHELjtlQOrfTfk2Un5OS89QIqfq-gEcB9WDs,998
10
10
  bizydraft/resp.py,sha256=8INvKOe5Dgai3peKfqKjrhUoYeuXWXn358w30-_cY-A,369
11
11
  bizydraft/server.py,sha256=L2zoJgOisr65IRphOyko74AdsLel59gh55peyMaUrO8,2102
12
12
  bizydraft/workflow_io.py,sha256=MYhJbpgkv8hrA5k_aolijOTrWpTtu62nzRznA4hv8JE,4298
13
13
  bizydraft/static/js/aiAppHandler.js,sha256=OQRhhoqvc8iZeCvHTtdaD2VTYBGzkeAGdCk1UMO2RZs,17525
14
- bizydraft/static/js/clipspaceToOss.js,sha256=brfEPs71Tky5Dnc47UXNEFeFlESDE3kQvUH8ducpIew,14265
14
+ bizydraft/static/js/clipspaceToOss.js,sha256=He9FbiS5CzsQHxGcUeeAUDNJBHXM6D6uNCYRK6KCAJA,16795
15
15
  bizydraft/static/js/disableComfyWebSocket.js,sha256=ZDOVlU3v3EvWpMRkD8s_AnO43vuWojVLLjkF2pNEVrA,1957
16
16
  bizydraft/static/js/freezeModeHandler.js,sha256=SjpHD2nYymR-E13B0YcqkA6e4WycZOVI3c48Ts9qvWE,18027
17
17
  bizydraft/static/js/handleStyle.js,sha256=GPshFVoa70UxLwFQB-kXZldVREE0cEF-BxxIM44ngkc,5436
@@ -22,13 +22,13 @@ bizydraft/static/js/nodeFocusHandler.js,sha256=24xXbS4Q-GjJdRqf11i-1pBo8MkOJ24F7
22
22
  bizydraft/static/js/nodeParamsFilter.js,sha256=H7lBB0G8HNqoGhOCH1hNXqPU-rPlrFyTxg_f_JgLEMk,4168
23
23
  bizydraft/static/js/postEvent.js,sha256=_EyA71m5DwGbhHsuf1amKhpLUBxfBWZaMMxViNhuYzU,43481
24
24
  bizydraft/static/js/socket.js,sha256=VE3fTAgEfM0FZhL526Skt7OCRokOa3mzTCAjAomI_tE,2432
25
- bizydraft/static/js/tool.js,sha256=LD7rijhv_gMRsyKiL5Cz1fgUkfAlPu8j4t_BQxkMm80,2981
25
+ bizydraft/static/js/tool.js,sha256=2Hhv2J18OaFZRWmHIlseahjd5Ot7ZVxUPb5z46YeXIo,2928
26
26
  bizydraft/static/js/uploadFile.js,sha256=WvglKzHMeOzDhOH3P-fLcPHxCLbKOJpo4DntoRxeJtI,4908
27
27
  bizydraft/static/js/workflow_io.js,sha256=FWAjncvWhvy-3nN_legD2fpRwgnIncpRLHU5X016a-U,5236
28
28
  bizydraft/static/js/hookLoad/configLoader.js,sha256=R1k0GKdEmv4IIxdT2F-oOI9X9I19ECe77P_1tO3XxgY,2525
29
29
  bizydraft/static/js/hookLoad/media.js,sha256=iX_zoZ0OzLAdYZ3bn5GpzpnwU-YjcBuEozQt-MwNuwk,17936
30
30
  bizydraft/static/js/hookLoad/model.js,sha256=aHvEPt9k3CcrawHSYnQYcvbtTRwIztk-XDRA3lvgXvA,9890
31
- bizydraft-0.2.83.dist-info/METADATA,sha256=QC6ISi0gY7fml1L4fyoaPJzj7U8L1PCnsnrnEZbhtnI,162
32
- bizydraft-0.2.83.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
- bizydraft-0.2.83.dist-info/top_level.txt,sha256=XtoBq6hjZhXIM7aas4GtPDtAiKo8FdLzMABXW8qqQ8M,10
34
- bizydraft-0.2.83.dist-info/RECORD,,
31
+ bizydraft-0.2.83.dev20251203095346.dist-info/METADATA,sha256=-rRdMygQkxyvbTl256yZrDzxVT_lAAkqhCRKydworNU,180
32
+ bizydraft-0.2.83.dev20251203095346.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ bizydraft-0.2.83.dev20251203095346.dist-info/top_level.txt,sha256=XtoBq6hjZhXIM7aas4GtPDtAiKo8FdLzMABXW8qqQ8M,10
34
+ bizydraft-0.2.83.dev20251203095346.dist-info/RECORD,,