forked from Shinonome/dots-hyprland
fix(ii): add Konachan support in sidebar
This commit is contained in:
@@ -16,9 +16,20 @@ Process {
|
|||||||
return StringUtils.shellSingleQuoteEscape(FileUtils.trimFileProtocol(filePath));
|
return StringUtils.shellSingleQuoteEscape(FileUtils.trimFileProtocol(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processSourceUrl() {
|
||||||
|
return StringUtils.shellSingleQuoteEscape(sourceUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
function curlUserAgentArg() {
|
||||||
|
if (!downloadUserAgent) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return ` -H 'User-Agent: ${StringUtils.shellSingleQuoteEscape(downloadUserAgent)}'`;
|
||||||
|
}
|
||||||
|
|
||||||
running: true
|
running: true
|
||||||
command: ["bash", "-c",
|
command: ["bash", "-c",
|
||||||
`mkdir -p $(dirname '${processFilePath()}'); [ -f '${processFilePath()}' ] || curl -sSL '${sourceUrl}' -o '${processFilePath()}' && file '${processFilePath()}'`
|
`mkdir -p $(dirname '${processFilePath()}'); [ -f '${processFilePath()}' ] || curl -sSL '${processSourceUrl()}'${curlUserAgentArg()} -o '${processFilePath()}' && file '${processFilePath()}'`
|
||||||
]
|
]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
id: imageSizeOutputCollector
|
id: imageSizeOutputCollector
|
||||||
|
|||||||
@@ -174,8 +174,10 @@ Button {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
root.showActions = false;
|
root.showActions = false;
|
||||||
const targetPath = root.imageData.is_nsfw ? root.nsfwPath : root.downloadPath;
|
const targetPath = root.imageData.is_nsfw ? root.nsfwPath : root.downloadPath;
|
||||||
|
const userAgent = Config.options?.networking?.userAgent ?? ""
|
||||||
|
const userAgentHeader = userAgent ? ` -H 'User-Agent: ${StringUtils.shellSingleQuoteEscape(userAgent)}'` : ""
|
||||||
Quickshell.execDetached(["bash", "-c",
|
Quickshell.execDetached(["bash", "-c",
|
||||||
`mkdir -p '${targetPath}' && curl '${root.imageData.file_url}' -o '${targetPath}/${root.fileName}' && notify-send '${Translation.tr("Download complete")}' '${root.downloadPath}/${root.fileName}' -a 'Shell'`
|
`mkdir -p '${targetPath}' && curl '${StringUtils.shellSingleQuoteEscape(root.imageData.file_url)}'${userAgentHeader} -o '${targetPath}/${root.fileName}' && notify-send '${Translation.tr("Download complete")}' '${root.downloadPath}/${root.fileName}' -a 'Shell'`
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ Rectangle {
|
|||||||
rowHeight: imageRow.rowHeight
|
rowHeight: imageRow.rowHeight
|
||||||
imageRadius: imageRow.modelData.images.length == 1 ? 50 : Appearance.rounding.normal
|
imageRadius: imageRow.modelData.images.length == 1 ? 50 : Appearance.rounding.normal
|
||||||
// Download manually to reduce redundant requests or make sure downloading works
|
// Download manually to reduce redundant requests or make sure downloading works
|
||||||
manualDownload: ["danbooru", "waifu.im", "t.alcy.cc"].includes(root.responseData.provider)
|
manualDownload: ["danbooru", "waifu.im", "t.alcy.cc", "konachan"].includes(root.responseData.provider)
|
||||||
previewDownloadPath: root.previewDownloadPath
|
previewDownloadPath: root.previewDownloadPath
|
||||||
downloadPath: root.downloadPath
|
downloadPath: root.downloadPath
|
||||||
nsfwPath: root.nsfwPath
|
nsfwPath: root.nsfwPath
|
||||||
|
|||||||
@@ -406,8 +406,8 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Required for danbooru
|
// Required for danbooru and konachan
|
||||||
if (currentProvider == "danbooru") {
|
if (["danbooru", "konachan"].includes(currentProvider)) {
|
||||||
xhr.setRequestHeader("User-Agent", defaultUserAgent)
|
xhr.setRequestHeader("User-Agent", defaultUserAgent)
|
||||||
}
|
}
|
||||||
else if (currentProvider == "zerochan") {
|
else if (currentProvider == "zerochan") {
|
||||||
@@ -458,8 +458,8 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Required for danbooru
|
// Required for danbooru and konachan
|
||||||
if (currentProvider == "danbooru") {
|
if (["danbooru", "konachan"].includes(currentProvider)) {
|
||||||
xhr.setRequestHeader("User-Agent", defaultUserAgent)
|
xhr.setRequestHeader("User-Agent", defaultUserAgent)
|
||||||
}
|
}
|
||||||
xhr.send()
|
xhr.send()
|
||||||
|
|||||||
Reference in New Issue
Block a user