@bytebrand/export-cars 1.21.0 → 1.21.2
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/README.md +0 -1
- package/dist/exporters/mobile.exporter.js +1 -1
- package/dist/exporters/mobile.exporter.js.map +1 -1
- package/dist/services/images.service.d.ts +1 -1
- package/dist/services/images.service.js +4 -7
- package/dist/services/images.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/exporters/mobile.exporter.ts +1 -1
- package/src/services/images.service.ts +9 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/export-cars",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "bytebrand",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14.0.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "50348b29c8a016e82b1c0c972db6eaa71355a3d4"
|
|
66
66
|
}
|
|
@@ -44,7 +44,7 @@ export class MobileExporter implements Exporter {
|
|
|
44
44
|
|
|
45
45
|
if (this.configService.config.downloadImage) {
|
|
46
46
|
const urls = await this.imageService.getImages(car, images, this.configService.config.imageType, true);
|
|
47
|
-
imagesPath.push(...await this.imageService.downloadInParallel(car.metaData.vehicleId, urls, this.configService.config
|
|
47
|
+
imagesPath.push(...await this.imageService.downloadInParallel(car.metaData.vehicleId, urls, this.configService.config));
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
await writeFile(fileName, Buffer.from(`${convertToCSV(transformedData)}\n`), { flag: 'a' });
|
|
@@ -173,17 +173,14 @@ export class ImagesService {
|
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
async downloadInParallel(vehicleId: string, urls: string[], config: Config
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return Promise.all(downloadPromises);
|
|
185
|
-
}
|
|
186
|
-
return [];
|
|
176
|
+
async downloadInParallel(vehicleId: string, urls: string[], config: Config): Promise<string[]> {
|
|
177
|
+
const downloadPromises = urls.map(
|
|
178
|
+
async (url: string, j: number) => await this.download(
|
|
179
|
+
url,
|
|
180
|
+
`${config.pathesConfig.localConvertedDirectory}/${vehicleId}_${(j + 1).toLocaleString('en-US', { minimumIntegerDigits: 2 })}.jpg`
|
|
181
|
+
)
|
|
182
|
+
);
|
|
183
|
+
return Promise.all(downloadPromises);
|
|
187
184
|
}
|
|
188
185
|
|
|
189
186
|
private async download(url: string, imagePath: string) {
|
|
@@ -192,7 +189,7 @@ export class ImagesService {
|
|
|
192
189
|
const response = await axios.get(url, { responseType: 'stream' });
|
|
193
190
|
response.data.pipe(
|
|
194
191
|
createWriteStream(imagePath)
|
|
195
|
-
.on('
|
|
192
|
+
.on('close', () => { console.log(`Downloaded: ${url}`, imagePath); resolve(imagePath); })
|
|
196
193
|
.on('error', (err) => { console.error(`Failed to download: ${url}`); resolve(null); })
|
|
197
194
|
);
|
|
198
195
|
} catch (error) {
|