viruagent-cli 0.4.2 → 0.5.0
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.
- package/package.json +1 -1
- package/src/providers/insta/apiClient.js +54 -54
- package/src/providers/insta/auth.js +10 -10
- package/src/providers/insta/index.js +17 -17
- package/src/providers/insta/session.js +2 -2
- package/src/providers/insta/smartComment.js +8 -8
- package/src/providers/insta/utils.js +5 -5
- package/src/providers/naver/auth.js +19 -19
- package/src/providers/naver/editorConvert.js +16 -16
- package/src/providers/naver/imageUpload.js +7 -7
- package/src/providers/naver/index.js +9 -9
- package/src/providers/naver/session.js +2 -2
- package/src/providers/naver/utils.js +8 -8
- package/src/providers/tistory/auth.js +12 -12
- package/src/providers/tistory/fetchLayer.js +5 -5
- package/src/providers/tistory/imageEnrichment.js +19 -19
- package/src/providers/tistory/imageNormalization.js +1 -1
- package/src/providers/tistory/imageSources.js +5 -5
- package/src/providers/tistory/index.js +15 -15
- package/src/providers/tistory/session.js +3 -3
- package/src/providers/tistory/utils.js +14 -14
- package/src/runner.js +1 -1
- package/src/services/naverApiClient.js +17 -17
- package/src/services/providerManager.js +1 -1
- package/src/services/tistoryApiClient.js +13 -13
|
@@ -31,19 +31,19 @@ const normalizeCookies = (session) => {
|
|
|
31
31
|
const readSessionCookies = (sessionPath) => {
|
|
32
32
|
const resolvedPath = path.resolve(sessionPath);
|
|
33
33
|
if (!fs.existsSync(resolvedPath)) {
|
|
34
|
-
throw new Error(
|
|
34
|
+
throw new Error(`Session file not found. Please save login credentials to ${resolvedPath} first.`);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
let raw;
|
|
38
38
|
try {
|
|
39
39
|
raw = JSON.parse(fs.readFileSync(resolvedPath, 'utf-8'));
|
|
40
40
|
} catch (error) {
|
|
41
|
-
throw new Error(
|
|
41
|
+
throw new Error(`Failed to parse session file: ${error.message}`);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const cookies = normalizeCookies(raw);
|
|
45
45
|
if (!cookies.length) {
|
|
46
|
-
throw new Error('
|
|
46
|
+
throw new Error('No valid cookies found in session. Please log in again.');
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return cookies.join('; ');
|
|
@@ -70,7 +70,7 @@ const createTistoryApiClient = ({ sessionPath }) => {
|
|
|
70
70
|
|
|
71
71
|
const getBase = () => {
|
|
72
72
|
if (!blogName) {
|
|
73
|
-
throw new Error('
|
|
73
|
+
throw new Error('Blog name not initialized. Call initBlog() first.');
|
|
74
74
|
}
|
|
75
75
|
return `https://${blogName}.tistory.com/manage`;
|
|
76
76
|
};
|
|
@@ -131,7 +131,7 @@ const createTistoryApiClient = ({ sessionPath }) => {
|
|
|
131
131
|
} catch {
|
|
132
132
|
detail = '';
|
|
133
133
|
}
|
|
134
|
-
throw new Error(
|
|
134
|
+
throw new Error(`Request failed: ${response.status} ${response.statusText}${detail}`);
|
|
135
135
|
}
|
|
136
136
|
return response.json();
|
|
137
137
|
} finally {
|
|
@@ -148,7 +148,7 @@ const createTistoryApiClient = ({ sessionPath }) => {
|
|
|
148
148
|
...options,
|
|
149
149
|
});
|
|
150
150
|
if (!response.ok) {
|
|
151
|
-
throw new Error(
|
|
151
|
+
throw new Error(`Request failed: ${response.status} ${response.statusText}`);
|
|
152
152
|
}
|
|
153
153
|
return response.text();
|
|
154
154
|
} finally {
|
|
@@ -181,18 +181,18 @@ const createTistoryApiClient = ({ sessionPath }) => {
|
|
|
181
181
|
redirect: 'follow',
|
|
182
182
|
});
|
|
183
183
|
if (!response.ok) {
|
|
184
|
-
throw new Error(
|
|
184
|
+
throw new Error(`Failed to fetch blog info: ${response.status}`);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
const contentType = response.headers.get('content-type') || '';
|
|
188
188
|
if (!contentType.includes('application/json')) {
|
|
189
|
-
throw new Error('
|
|
189
|
+
throw new Error('Session expired. Please log in again via /auth/login.');
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
const json = await response.json();
|
|
193
193
|
const defaultBlog = (json?.data || []).find((blog) => blog?.defaultBlog) || (json?.data || [])[0];
|
|
194
194
|
if (!defaultBlog) {
|
|
195
|
-
throw new Error('
|
|
195
|
+
throw new Error('Blog not found.');
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
blogName = defaultBlog.name;
|
|
@@ -255,14 +255,14 @@ const createTistoryApiClient = ({ sessionPath }) => {
|
|
|
255
255
|
|
|
256
256
|
const match = html.match(/window\.Config\s*=\s*(\{[\s\S]*?\})\s*(?:\n|;)/);
|
|
257
257
|
if (!match) {
|
|
258
|
-
throw new Error('
|
|
258
|
+
throw new Error('Failed to parse categories');
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
const sandbox = {};
|
|
262
262
|
vm.runInNewContext(`var result = ${match[1]};`, sandbox);
|
|
263
263
|
const rootCategories = sandbox?.result?.blog?.categories;
|
|
264
264
|
if (!Array.isArray(rootCategories)) {
|
|
265
|
-
throw new Error('
|
|
265
|
+
throw new Error('Failed to parse categories');
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
return flattenCategories(rootCategories, {});
|
|
@@ -287,12 +287,12 @@ const createTistoryApiClient = ({ sessionPath }) => {
|
|
|
287
287
|
|
|
288
288
|
if (!response.ok) {
|
|
289
289
|
const text = await response.text().catch(() => '');
|
|
290
|
-
throw new Error(
|
|
290
|
+
throw new Error(`Image upload failed: ${response.status} ${text ? `: ${text.slice(0, 500)}` : ''}`);
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
const uploaded = await response.json();
|
|
294
294
|
if (!uploaded?.url) {
|
|
295
|
-
throw new Error('
|
|
295
|
+
throw new Error('Image upload response does not contain a URL.');
|
|
296
296
|
}
|
|
297
297
|
return uploaded;
|
|
298
298
|
};
|