Merge pull request #10 from rishighan/automated-download-loop
Automated download loop
This commit was merged in pull request #10.
This commit is contained in:
61
Dockerfile
61
Dockerfile
@@ -1,40 +1,61 @@
|
|||||||
FROM alpine:3.14
|
# Use a base image with Node.js 22.1.0
|
||||||
|
FROM node:22.1.0
|
||||||
|
|
||||||
|
# Set metadata for contact
|
||||||
LABEL maintainer="Rishi Ghan <rishi.ghan@gmail.com>"
|
LABEL maintainer="Rishi Ghan <rishi.ghan@gmail.com>"
|
||||||
|
|
||||||
# Show all node logs
|
# Set environment variables
|
||||||
ENV NPM_CONFIG_LOGLEVEL warn
|
ENV NPM_CONFIG_LOGLEVEL warn
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
WORKDIR /core-services
|
WORKDIR /core-services
|
||||||
|
|
||||||
|
# Install required packages
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
libvips-tools \
|
||||||
|
wget \
|
||||||
|
imagemagick \
|
||||||
|
python3 \
|
||||||
|
xvfb \
|
||||||
|
xz-utils \
|
||||||
|
curl \
|
||||||
|
bash \
|
||||||
|
software-properties-common
|
||||||
|
|
||||||
RUN apk add --update \
|
# Install p7zip
|
||||||
--repository http://nl.alpinelinux.org/alpine/v3.14/main \
|
RUN apt-get update && apt-get install -y p7zip
|
||||||
vips-tools \
|
|
||||||
wget \
|
|
||||||
imagemagick \
|
|
||||||
python3 \
|
|
||||||
unrar \
|
|
||||||
p7zip \
|
|
||||||
nodejs \
|
|
||||||
npm \
|
|
||||||
xvfb \
|
|
||||||
xz
|
|
||||||
|
|
||||||
|
# Install unrar directly from RARLAB
|
||||||
|
RUN wget https://www.rarlab.com/rar/rarlinux-x64-621.tar.gz \
|
||||||
|
&& tar -zxvf rarlinux-x64-621.tar.gz \
|
||||||
|
&& cp rar/unrar /usr/bin/ \
|
||||||
|
&& rm -rf rarlinux-x64-621.tar.gz rar
|
||||||
|
|
||||||
|
# Clean up package lists
|
||||||
|
RUN rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Verify Node.js installation
|
||||||
|
RUN node -v && npm -v
|
||||||
|
|
||||||
|
# Copy application configuration files
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
COPY moleculer.config.ts ./
|
COPY moleculer.config.ts ./
|
||||||
COPY tsconfig.json ./
|
COPY tsconfig.json ./
|
||||||
|
|
||||||
RUN npm i
|
# Install application dependencies
|
||||||
# Install Dependncies
|
RUN npm install
|
||||||
RUN npm install -g typescript ts-node
|
RUN npm install -g typescript ts-node
|
||||||
|
|
||||||
|
# Copy the rest of the application files
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build and cleanup
|
# Build and clean up
|
||||||
RUN npm run build \
|
RUN npm run build \
|
||||||
&& npm prune
|
&& npm prune
|
||||||
|
|
||||||
|
|
||||||
|
# Expose the application's port
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
# Start server
|
|
||||||
|
# Command to run the application
|
||||||
CMD ["npm", "start"]
|
CMD ["npm", "start"]
|
||||||
@@ -67,6 +67,8 @@ const wantedSchema = mongoose.Schema(
|
|||||||
id: Number,
|
id: Number,
|
||||||
url: String,
|
url: String,
|
||||||
image: { type: Array, default: [] },
|
image: { type: Array, default: [] },
|
||||||
|
coverDate: String,
|
||||||
|
issueNumber: String,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: null,
|
default: null,
|
||||||
|
|||||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -13921,9 +13921,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/r2-shared-js": {
|
"node_modules/r2-shared-js": {
|
||||||
"version": "1.0.72",
|
"version": "1.0.74",
|
||||||
"resolved": "https://registry.npmjs.org/r2-shared-js/-/r2-shared-js-1.0.72.tgz",
|
"resolved": "https://registry.npmjs.org/r2-shared-js/-/r2-shared-js-1.0.74.tgz",
|
||||||
"integrity": "sha512-aP0M8uqnyLtJ5TZkNx+q4fgVZbjmuhFQPL/N5Qd6W6ybCozZgiQc+FYZOqu1vdsNaYw0FaMzYlp0/DH6m3TdYA==",
|
"integrity": "sha512-aNk8kkb4W9nMKKXrzTC76AXOVSLUx78V73hk4DJ7g81M3gfX2FZQD63Tohgt7VSAbVBdKy/7wo6KOBNFN8Kvow==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@xmldom/xmldom": "^0.8.10",
|
"@xmldom/xmldom": "^0.8.10",
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export default class AirDCPPService extends Service {
|
|||||||
},
|
},
|
||||||
getHubs: {
|
getHubs: {
|
||||||
rest: "POST /getHubs",
|
rest: "POST /getHubs",
|
||||||
|
timeout: 70000,
|
||||||
handler: async (
|
handler: async (
|
||||||
ctx: Context<{
|
ctx: Context<{
|
||||||
host: {
|
host: {
|
||||||
@@ -69,7 +70,6 @@ export default class AirDCPPService extends Service {
|
|||||||
};
|
};
|
||||||
}>
|
}>
|
||||||
) => {
|
) => {
|
||||||
console.log(ctx.params);
|
|
||||||
const {
|
const {
|
||||||
host: {
|
host: {
|
||||||
hostname,
|
hostname,
|
||||||
@@ -93,8 +93,64 @@ export default class AirDCPPService extends Service {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
search: {
|
||||||
|
rest: "POST /search",
|
||||||
|
timeout: 20000,
|
||||||
|
handler: async (
|
||||||
|
ctx: Context<{
|
||||||
|
host: {
|
||||||
|
hostname;
|
||||||
|
port;
|
||||||
|
protocol;
|
||||||
|
username;
|
||||||
|
password;
|
||||||
|
};
|
||||||
|
dcppSearchQuery;
|
||||||
|
}>
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
host: {
|
||||||
|
hostname,
|
||||||
|
port,
|
||||||
|
protocol,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
},
|
||||||
|
dcppSearchQuery,
|
||||||
|
} = ctx.params;
|
||||||
|
const airDCPPSocket = new AirDCPPSocket({
|
||||||
|
protocol,
|
||||||
|
hostname: `${hostname}:${port}`,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
});
|
||||||
|
await airDCPPSocket.connect();
|
||||||
|
const searchInstance = await airDCPPSocket.post(
|
||||||
|
`search`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Post the search
|
||||||
|
const searchInfo = await airDCPPSocket.post(
|
||||||
|
`search/${searchInstance.id}/hub_search`,
|
||||||
|
dcppSearchQuery
|
||||||
|
);
|
||||||
|
await this.sleep(10000);
|
||||||
|
const results = await airDCPPSocket.get(
|
||||||
|
`search/${searchInstance.id}/results/0/5`
|
||||||
|
);
|
||||||
|
return results;
|
||||||
|
} catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
sleep: (ms: number) => {
|
||||||
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ export default class SocketService extends Service {
|
|||||||
port: process.env.PORT || 3001,
|
port: process.env.PORT || 3001,
|
||||||
io: {
|
io: {
|
||||||
namespaces: {
|
namespaces: {
|
||||||
"/": {
|
"/automated": {
|
||||||
events: {
|
events: {
|
||||||
call: {
|
call: {
|
||||||
whitelist: ["socket.*"],
|
whitelist: [
|
||||||
|
"socket.*", // Allow 'search' in the automated namespace
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -123,8 +125,12 @@ export default class SocketService extends Service {
|
|||||||
config: "object",
|
config: "object",
|
||||||
},
|
},
|
||||||
async handler(ctx) {
|
async handler(ctx) {
|
||||||
const { query, config } = ctx.params;
|
console.log("a, a kanha kanha...");
|
||||||
|
|
||||||
|
const { query, config, namespace } = ctx.params;
|
||||||
|
const namespacedInstance = this.io.of(namespace || "/");
|
||||||
const ADCPPSocket = new AirDCPPSocket(config);
|
const ADCPPSocket = new AirDCPPSocket(config);
|
||||||
|
console.log("asdas", ADCPPSocket);
|
||||||
try {
|
try {
|
||||||
await ADCPPSocket.connect();
|
await ADCPPSocket.connect();
|
||||||
const instance = await ADCPPSocket.post(
|
const instance = await ADCPPSocket.post(
|
||||||
@@ -133,7 +139,7 @@ export default class SocketService extends Service {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Send the instance to the client
|
// Send the instance to the client
|
||||||
await this.io.emit("searchInitiated", {
|
await namespacedInstance.emit("searchInitiated", {
|
||||||
instance,
|
instance,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -142,7 +148,7 @@ export default class SocketService extends Service {
|
|||||||
`search`,
|
`search`,
|
||||||
`search_result_added`,
|
`search_result_added`,
|
||||||
(groupedResult) => {
|
(groupedResult) => {
|
||||||
this.io.emit(
|
namespacedInstance.emit(
|
||||||
"searchResultAdded",
|
"searchResultAdded",
|
||||||
groupedResult
|
groupedResult
|
||||||
);
|
);
|
||||||
@@ -154,8 +160,7 @@ export default class SocketService extends Service {
|
|||||||
`search`,
|
`search`,
|
||||||
`search_result_updated`,
|
`search_result_updated`,
|
||||||
(updatedResult) => {
|
(updatedResult) => {
|
||||||
console.log("hi", updatedResult);
|
namespacedInstance.emit(
|
||||||
this.io.emit(
|
|
||||||
"searchResultUpdated",
|
"searchResultUpdated",
|
||||||
updatedResult
|
updatedResult
|
||||||
);
|
);
|
||||||
@@ -173,14 +178,21 @@ export default class SocketService extends Service {
|
|||||||
`search/${instance.id}`
|
`search/${instance.id}`
|
||||||
);
|
);
|
||||||
// Send the instance to the client
|
// Send the instance to the client
|
||||||
await this.io.emit("searchesSent", {
|
await namespacedInstance.emit(
|
||||||
searchInfo,
|
"searchesSent",
|
||||||
});
|
{
|
||||||
|
searchInfo,
|
||||||
|
}
|
||||||
|
);
|
||||||
if (currentInstance.result_count === 0) {
|
if (currentInstance.result_count === 0) {
|
||||||
console.log("No more search results.");
|
console.log("No more search results.");
|
||||||
this.io.emit("searchComplete", {
|
namespacedInstance.emit(
|
||||||
message: "No more search results.",
|
"searchComplete",
|
||||||
});
|
{
|
||||||
|
message:
|
||||||
|
"No more search results.",
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
instance.id
|
instance.id
|
||||||
@@ -192,7 +204,10 @@ export default class SocketService extends Service {
|
|||||||
query
|
query
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await this.io.emit("searchError", error.message);
|
await namespacedInstance.emit(
|
||||||
|
"searchError",
|
||||||
|
error.message
|
||||||
|
);
|
||||||
throw new MoleculerError(
|
throw new MoleculerError(
|
||||||
"Search failed",
|
"Search failed",
|
||||||
500,
|
500,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export default class ImageTransformation extends Service {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
public constructor(
|
public constructor(
|
||||||
public broker: ServiceBroker,
|
public broker: ServiceBroker,
|
||||||
schema: ServiceSchema<{}> = { name: "imagetransformation" }
|
schema: ServiceSchema<{}> = { name: "torrentjobs" }
|
||||||
) {
|
) {
|
||||||
super(broker);
|
super(broker);
|
||||||
this.parseServiceSchema({
|
this.parseServiceSchema({
|
||||||
@@ -77,7 +77,7 @@ export default class ImageTransformation extends Service {
|
|||||||
"qbittorrent.getTorrentRealTimeStats",
|
"qbittorrent.getTorrentRealTimeStats",
|
||||||
{ infoHashes }
|
{ infoHashes }
|
||||||
);
|
);
|
||||||
// 4. Emit the LS_COVER_EXTRACTION_FAILED event with the necessary details
|
// 4.
|
||||||
await this.broker.call("socket.broadcast", {
|
await this.broker.call("socket.broadcast", {
|
||||||
namespace: "/",
|
namespace: "/",
|
||||||
event: "AS_TORRENT_DATA",
|
event: "AS_TORRENT_DATA",
|
||||||
|
|||||||
Reference in New Issue
Block a user