forked from Shinonome/dots-hyprland
booru: add save image
save the image and put it in the folder based on the tag
This commit is contained in:
@@ -218,6 +218,22 @@ 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: () => {
|
||||||
|
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/${tagDirectory} && curl -L -o $(xdg-user-dir PICTURES)/homework/${tagDirectory}/${data.md5}.${fileExtension} '${data.file_url}'`;
|
||||||
|
execAsync(['bash', '-c', saveCommand])
|
||||||
|
// .then(() => {
|
||||||
|
// print(`Image saved to $(xdg-user-dir PICTURES)/homework/${tagDirectory}/${data.md5}.${data.file_ext}`);
|
||||||
|
// })
|
||||||
|
.then(() => self.label = 'done')
|
||||||
|
.catch(print);
|
||||||
|
},
|
||||||
|
}),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user