forked from Shinonome/dots-hyprland
booru: add save image (#747)
This commit is contained in:
@@ -102,6 +102,7 @@ let configOptions = {
|
|||||||
'columns': 2,
|
'columns': 2,
|
||||||
'batchCount': 20,
|
'batchCount': 20,
|
||||||
'allowNsfw': false,
|
'allowNsfw': false,
|
||||||
|
'sortInFolderByTags': false,
|
||||||
},
|
},
|
||||||
'pages': {
|
'pages': {
|
||||||
'order': ["apis", "tools"],
|
'order': ["apis", "tools"],
|
||||||
|
|||||||
@@ -187,7 +187,6 @@ const BooruPage = (taglist, serviceName = 'Booru') => {
|
|||||||
// Show
|
// Show
|
||||||
// const downloadCommand = `wget -O '${imagePath}' '${data.preview_url}'`;
|
// const downloadCommand = `wget -O '${imagePath}' '${data.preview_url}'`;
|
||||||
const downloadCommand = `curl -L -o '${imagePath}' '${data.preview_url}'`;
|
const downloadCommand = `curl -L -o '${imagePath}' '${data.preview_url}'`;
|
||||||
// console.log(downloadCommand)
|
|
||||||
if (!force && fileExists(imagePath)) showImage();
|
if (!force && fileExists(imagePath)) showImage();
|
||||||
else Utils.timeout(delay, () => Utils.execAsync(['bash', '-c', downloadCommand])
|
else Utils.timeout(delay, () => Utils.execAsync(['bash', '-c', downloadCommand])
|
||||||
.then(showImage)
|
.then(showImage)
|
||||||
@@ -218,6 +217,19 @@ const BooruPage = (taglist, serviceName = 'Booru') => {
|
|||||||
icon: 'open_in_new',
|
icon: 'open_in_new',
|
||||||
action: () => execAsync(['xdg-open', `${data.source}`]).catch(print),
|
action: () => execAsync(['xdg-open', `${data.source}`]).catch(print),
|
||||||
}),
|
}),
|
||||||
|
ImageAction({
|
||||||
|
name: 'Save image',
|
||||||
|
icon: 'save',
|
||||||
|
action: (self) => {
|
||||||
|
const currentTags = BooruService.queries.at(-1).realTagList.filter(tag => !tag.includes('rating:'));
|
||||||
|
const tagDirectory = currentTags.join('+');
|
||||||
|
let fileExtension = data.file_ext || 'jpg';
|
||||||
|
const saveCommand = `mkdir -p $(xdg-user-dir PICTURES)/homework/${data.is_nsfw ? '🌶️/' : ''}${userOptions.sidebar.image.sortInFolderByTags ? tagDirectory : ''} && curl -L -o $(xdg-user-dir PICTURES)/homework/${data.is_nsfw ? '🌶️/' : ''}${userOptions.sidebar.image.sortInFolderByTags ? (tagDirectory + '/') : ''}${data.md5}.${fileExtension} '${data.file_url}'`;
|
||||||
|
execAsync(['bash', '-c', saveCommand])
|
||||||
|
.then(() => self.label = 'done')
|
||||||
|
.catch(print);
|
||||||
|
},
|
||||||
|
}),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ class BooruService extends Service {
|
|||||||
aspect_ratio: obj.width / obj.height,
|
aspect_ratio: obj.width / obj.height,
|
||||||
id: obj.id,
|
id: obj.id,
|
||||||
tags: obj.tags,
|
tags: obj.tags,
|
||||||
|
rating: obj.rating,
|
||||||
|
is_nsfw: (obj.rating != 's'),
|
||||||
md5: obj.md5,
|
md5: obj.md5,
|
||||||
preview_url: obj.preview_url,
|
preview_url: obj.preview_url,
|
||||||
preview_width: obj.preview_width,
|
preview_width: obj.preview_width,
|
||||||
|
|||||||
Reference in New Issue
Block a user