🔌 AirDC++ integration WIP

This commit is contained in:
2021-07-21 08:43:46 -07:00
parent 42de05b36e
commit 96a6438fb4
6 changed files with 78 additions and 37 deletions

View File

@@ -10,7 +10,6 @@ import {
CV_SEARCH_SUCCESS,
CV_CLEANUP,
} from "../constants/action-types";
import { refineQuery } from "../shared/utils/filenameparser.utils";
import { matchScorer } from "../shared/utils/searchmatchscorer.utils";

View File

@@ -11,6 +11,11 @@ import { EnumLinkRel } from "opds-extra/lib/const";
import { async as FastGlob } from "@bluelovers/fast-glob/bluebird";
import { Entry, Feed } from "opds-extra/lib/v1";
import { Link } from "opds-extra/lib/v1/core";
import SocketService from "./utils/airdcpp.socket.service";
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
// call express
const app: Express = express(); // define our app using express
@@ -94,8 +99,43 @@ app.get("/", (req: Request, res: Response) => {
console.log("sending index.html");
res.sendFile("/dist/index.html");
});
interface SearchInstance {
current_search_id: string;
expires_in: number;
id: number;
owner: string;
query: Record<string, unknown>;
queue_time: number;
queued_count: number;
result_count: number;
searches_sent_ago: number;
}
app.use(opdsRouter());
const foo = SocketService.connect("admin", "password");
foo.then(async (data) => {
const instance: SearchInstance = await SocketService.post("search");
await sleep(10000);
const searchInfo = await SocketService.post(
`search/${instance.id}/hub_search`,
{
query: {
pattern: "H.P. Lovecraft",
file_type: "compressed",
extensions: ["cbz", "cbr"],
},
hub_urls: [
"nmdcs://piter.feardc.net:411",
"dchub://dc.rutrack.net",
"dchub://dc.elitedc.ru",
],
priority: 1,
},
);
await sleep(10000);
const results = await SocketService.get(`search/${instance.id}/results/0/5`);
console.log(results);
});
// REGISTER ROUTES
// all of the routes will be prefixed with /api