Skip to content

Commit

Permalink
Add userscloud.com #364, update CURL certificate store
Browse files Browse the repository at this point in the history
  • Loading branch information
zenden2k committed Jan 2, 2024
1 parent 17ba538 commit f0ecade
Show file tree
Hide file tree
Showing 5 changed files with 352 additions and 112 deletions.
Binary file added Data/Favicons/userscloud.ico
Binary file not shown.
70 changes: 70 additions & 0 deletions Data/Scripts/userscloud.nut
@@ -0,0 +1,70 @@
const BASE_HOST = "https://userscloud.com/";

function _getUploadURL() {
nm.doGet(BASE_HOST);
if (nm.responseCode() != 200) {
WriteLog("error", "[userscloud.com] Cannot obtain upload server address. \r\nResponse code:" + nm.responseCode());
return "";
}

local doc = Document(nm.responseBody());
local uploadURL = doc.find("#uploadfile").attr("action");
if (uploadURL != "") {
return uploadURL;
}
WriteLog("error", "[userscloud.com] Cannot obtain upload server address from the main page.");
return "";
}

function UploadFile(fileName, options) {
local uploadURL = _getUploadURL();
if (uploadURL == "") {
return 0;
}
local name = ExtractFileName(fileName);
local mime = GetFileMimeType(name);
nm.setUrl(uploadURL);
nm.addQueryParam("sess_id", "");
nm.addQueryParam("utype", "anon");
nm.addQueryParam("link_rcpt", "");
nm.addQueryParam("link_pass", "");
nm.addQueryParam("keepalive", "1");
nm.addQueryParamFile("file_0", fileName, name, mime);
nm.doUploadMultipartData();

if (nm.responseCode() == 200) {
local sJSON = nm.responseBody();
local t = ParseJSON(sJSON);
if (t != null) {
if (t[0].file_status = "Ok") {
nm.doGet(BASE_HOST + "?op=upload_result&st=OK&fn=" + nm.urlEncode(t[0].file_code));

if (nm.responseCode() == 200) {
local doc = Document(nm.responseBody());
local viewURL = strip(doc.find("#tab1 textarea").text());
local directURL = strip(doc.find("#tab5 textarea").text());
local thumbURL = strip(doc.find("#tab6 textarea").text());
local deleteURL = strip(doc.find("#tab4 textarea").text());
options.setDirectUrl(directURL);
options.setViewUrl(viewURL);
options.setThumbUrl(thumbURL);
options.setDeleteUrl(deleteURL);

if (directURL != "" || viewURL != "") {
return 1;
} else {
WriteLog("error", "[userscloud.com] Cannot obtain file links from server's response.");
}
}

return 1;
} else {
WriteLog("error", "[userscloud.com] Status: " + t.file_status);
}
}
} else {
WriteLog("error", "[userscloud.com] Failed to upload. \r\nResponse code: " + nm.responseCode());
}

return 0;
}
5 changes: 5 additions & 0 deletions Data/servers.xml
Expand Up @@ -304,6 +304,11 @@
</Actions>
<Result ImageUrlTemplate="stub" ThumbUrlTemplate="stub" DownloadUrlTemplate="stub"/>
</Server>
<Server Name="userscloud.com" FileHost="1" Plugin="userscloud">
<Actions>
</Actions>
<Result ImageUrlTemplate="stub" ThumbUrlTemplate="stub" DownloadUrlTemplate="stub"/>
</Server>
<!-- 429 Too Many Requests
<Server Name="pasteboard.co" MaxThreads="1">
<Actions>
Expand Down

0 comments on commit f0ecade

Please sign in to comment.