feat: support download tweet pic and video
This commit is contained in:
+15
-1
@@ -16,6 +16,7 @@ app.use(ctx => {
|
||||
'url': '',
|
||||
'name': '',
|
||||
'playlist': '0',
|
||||
'tweet': '',
|
||||
}, ctx.request.body);
|
||||
|
||||
const result = {
|
||||
@@ -33,7 +34,20 @@ app.use(ctx => {
|
||||
result.code = 3;
|
||||
result.msg = 'unsupported engine';
|
||||
} else {
|
||||
downloader(options, result);
|
||||
if (options.tweet && options.engine === 'wget') {
|
||||
const match = options.tweet.match(/src="(.*?)"/g);
|
||||
if (match) {
|
||||
match.forEach((src, index) => {
|
||||
const newOptions = JSON.parse(JSON.stringify(options));
|
||||
newOptions.url = src.replace(/src="(.*)"/, '$1');
|
||||
const format = (newOptions.url.match(/\.mp4/) ? 'mp4' : newOptions.url.match(/format=(.*?)&/)?.[1]) || 'jpg';
|
||||
newOptions.name = `${encodeURIComponent(options.url)}-${index}.${format}`;
|
||||
downloader(newOptions, result);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
downloader(options, result);
|
||||
}
|
||||
}
|
||||
|
||||
ctx.body = JSON.stringify(result);
|
||||
|
||||
Reference in New Issue
Block a user