lbry.tech/app/helpers/lbrytv-sdk.js

114 lines
3 KiB
JavaScript
Raw Permalink Normal View History

2019-09-23 19:27:04 +02:00
"use strict";
2020-04-11 09:40:00 +02:00
import messageSlack from "./slack";
2019-09-23 19:27:04 +02:00
const request = require("request");
2020-04-11 09:40:00 +02:00
const addSupport = function() {};
2019-09-23 19:27:04 +02:00
2020-04-11 09:40:00 +02:00
const publish = function() {};
2019-09-23 19:27:04 +02:00
2020-04-11 09:40:00 +02:00
const resolve = function(urls) {
2019-09-23 19:27:04 +02:00
return new Promise(function(resolve, reject) {
2020-04-11 09:40:00 +02:00
const options = {
2019-09-23 19:27:04 +02:00
method: "POST",
2021-08-07 07:44:10 +02:00
url: "https://api.na-backend.odysee.com/api/v1/proxy",
2019-09-23 19:27:04 +02:00
headers:
{
"Content-Type": "application/json"
},
body: {
method: "resolve",
params: { urls: urls }
},
json: true
};
request(options, function(error, response, daemonResponse) {
if (error) {
messageSlack({
message: "```" + error + "```",
title: "DAEMON ERROR: resolve"
});
2020-04-11 09:40:00 +02:00
return reject(new Error("DAEMON ERROR: resolve"));
2019-09-23 19:27:04 +02:00
}
if (Object.prototype.hasOwnProperty.call(daemonResponse, "error")) {
2019-09-23 19:27:04 +02:00
messageSlack({
message: "```" + daemonResponse.error + "```",
title: "DAEMON ERROR: resolve"
});
2020-04-11 09:40:00 +02:00
return reject(new Error("DAEMON ERROR: resolve"));
2019-09-23 19:27:04 +02:00
} else
return resolve(daemonResponse.result);
});
});
};
2020-04-11 09:40:00 +02:00
const getTrending = function() {
return new Promise(function(resolve, reject) {
2020-04-11 09:40:00 +02:00
const options = {
method: "POST",
2021-08-07 07:44:10 +02:00
url: "https://api.na-backend.odysee.com/api/v1/proxy",
headers:
{
"Content-Type": "application/json"
},
body:
{
method: "claim_search",
params:
{
page_size: 20,
page: 1,
no_totals: true,
any_tags:
["art",
"automotive",
"blockchain",
"comedy",
"economics",
"education",
"gaming",
"music",
"news",
"science",
"sports",
"technology"],
channel_ids: [],
not_channel_ids: [],
2021-08-07 07:47:50 +02:00
not_tags: ["porn", "porno", "nsfw", "mature", "xxx", "sex", "creampie", "blowjob", "handjob", "vagina", "boobs", "big boobs", "big dick", "pussy", "cumshot", "anal", "hard fucking", "ass", "fuck", "hentai"],
2020-02-26 19:23:25 +01:00
order_by: ["trending_group", "trending_mixed"]
}
},
json: true
};
request(options, function(error, response, daemonResponse) {
if (error) {
messageSlack({
message: "```" + error + "```",
title: "DAEMON ERROR: trending"
});
2020-04-11 09:40:00 +02:00
return reject(new Error("DAEMON ERROR: trending"));
}
if (Object.prototype.hasOwnProperty.call(daemonResponse, "error")) {
messageSlack({
message: "```" + daemonResponse.error + "```",
title: "DAEMON ERROR: trending"
});
2020-02-26 19:23:25 +01:00
return reject(JSON.stringify(daemonResponse));
} else
return resolve(daemonResponse.result.items);
});
});
2019-09-23 19:27:04 +02:00
};
export default {
addSupport,
publish,
resolve,
getTrending
};