Spaces:
Paused
Paused
Upload 26 files
Browse files- Dockerfile +1 -1
- commons/index.js +1 -1
- commons/queryBuilder.js +6 -75
- config/env.js +1 -1
- index.js +2 -2
- package.json +1 -1
- server.js +7 -7
- use-cases/catalog.js +39 -0
- use-cases/index.js +16 -22
- use-cases/meta.js +8 -26
- use-cases/stream.js +20 -33
Dockerfile
CHANGED
|
@@ -36,4 +36,4 @@ COPY --from=build /app /app
|
|
| 36 |
|
| 37 |
# Start the server by default, this can be overwritten at runtime
|
| 38 |
EXPOSE 3000
|
| 39 |
-
CMD [ "npm", "run", "start" ]
|
|
|
|
| 36 |
|
| 37 |
# Start the server by default, this can be overwritten at runtime
|
| 38 |
EXPOSE 3000
|
| 39 |
+
CMD [ "npm", "run", "start" ]
|
commons/index.js
CHANGED
|
@@ -8,4 +8,4 @@ module.exports = {
|
|
| 8 |
transformModel,
|
| 9 |
validate,
|
| 10 |
parseTorrent,
|
| 11 |
-
}
|
|
|
|
| 8 |
transformModel,
|
| 9 |
validate,
|
| 10 |
parseTorrent,
|
| 11 |
+
}
|
commons/queryBuilder.js
CHANGED
|
@@ -1,76 +1,7 @@
|
|
| 1 |
-
const
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
for (const key in params) {
|
| 9 |
-
if (params[key]) {
|
| 10 |
-
queryParts.push(`${key}:${params[key]}`);
|
| 11 |
-
}
|
| 12 |
-
}
|
| 13 |
-
return queryParts.join(' AND ');
|
| 14 |
-
},
|
| 15 |
-
env: {
|
| 16 |
-
url: {
|
| 17 |
-
search: 'https://archive.org/advancedsearch.php',
|
| 18 |
-
},
|
| 19 |
-
},
|
| 20 |
-
};
|
| 21 |
-
|
| 22 |
-
// Catalog function
|
| 23 |
-
const Catalog = (dependencies) => {
|
| 24 |
-
const { httpClient, queryBuilder, env } = dependencies;
|
| 25 |
-
|
| 26 |
-
const searchCatalog = async (request) => {
|
| 27 |
-
const { search, genre, skip } = request;
|
| 28 |
-
|
| 29 |
-
try {
|
| 30 |
-
// Build the query using the queryBuilder
|
| 31 |
-
const query = queryBuilder({
|
| 32 |
-
collection: 'feature_films',
|
| 33 |
-
mediatype: 'movies',
|
| 34 |
-
search: search ? `${search}*` : null,
|
| 35 |
-
subject: genre,
|
| 36 |
-
});
|
| 37 |
-
|
| 38 |
-
// Log the query for debugging
|
| 39 |
-
console.log("Generated query:", query);
|
| 40 |
-
|
| 41 |
-
// Make the API request
|
| 42 |
-
const response = await httpClient.get(env.url.search, {
|
| 43 |
-
params: {
|
| 44 |
-
rows: (+skip || 0) + 50,
|
| 45 |
-
sort: 'num_reviews desc,avg_rating desc',
|
| 46 |
-
fields: 'avg_rating,description,genre,identifier,title,subject',
|
| 47 |
-
q: query,
|
| 48 |
-
output: 'json',
|
| 49 |
-
},
|
| 50 |
-
});
|
| 51 |
-
|
| 52 |
-
// Log the response data for debugging
|
| 53 |
-
console.log("Archive.org Response:", response.data);
|
| 54 |
-
|
| 55 |
-
// Format the results for Stremio
|
| 56 |
-
const catalogItems = response.data.response.docs.map((doc) => ({
|
| 57 |
-
id: `archorg.addon:${doc.identifier}`,
|
| 58 |
-
name: doc.title || "Untitled",
|
| 59 |
-
description: doc.description || "No description available.",
|
| 60 |
-
poster: `https://archive.org/services/img/${doc.identifier}`,
|
| 61 |
-
background: `https://archive.org/services/img/${doc.identifier}`,
|
| 62 |
-
type: 'movie',
|
| 63 |
-
genre: genre,
|
| 64 |
-
}));
|
| 65 |
-
|
| 66 |
-
return { metas: catalogItems };
|
| 67 |
-
} catch (error) {
|
| 68 |
-
console.error("Error in searchCatalog:", error.message);
|
| 69 |
-
return { metas: [] };
|
| 70 |
-
}
|
| 71 |
-
};
|
| 72 |
-
|
| 73 |
-
return { searchCatalog };
|
| 74 |
-
};
|
| 75 |
-
|
| 76 |
-
module.exports = Catalog(dependencies);
|
|
|
|
| 1 |
+
const generator = require('lucene-query-generator')
|
| 2 |
|
| 3 |
+
module.exports = (args) => {
|
| 4 |
+
return generator.convert({
|
| 5 |
+
$operands: [args],
|
| 6 |
+
})
|
| 7 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config/env.js
CHANGED
|
@@ -3,7 +3,7 @@ require('dotenv').config()
|
|
| 3 |
const { SEARCH_URL, METADATA_URL, IMAGE_URL, STREAM_URL, PORT } = process.env
|
| 4 |
|
| 5 |
const config = {
|
| 6 |
-
port: PORT ||
|
| 7 |
addonContentIdPrefix: 'archorg.addon:',
|
| 8 |
url: {
|
| 9 |
search: SEARCH_URL,
|
|
|
|
| 3 |
const { SEARCH_URL, METADATA_URL, IMAGE_URL, STREAM_URL, PORT } = process.env
|
| 4 |
|
| 5 |
const config = {
|
| 6 |
+
port: PORT || 7000,
|
| 7 |
addonContentIdPrefix: 'archorg.addon:',
|
| 8 |
url: {
|
| 9 |
search: SEARCH_URL,
|
index.js
CHANGED
|
@@ -4,7 +4,7 @@ const axios = require('axios')
|
|
| 4 |
|
| 5 |
const builder = require('./addon')
|
| 6 |
const server = require('./server')
|
| 7 |
-
const useCases = require('./
|
| 8 |
const handlers = require('./handlers')
|
| 9 |
|
| 10 |
const {
|
|
@@ -34,4 +34,4 @@ addon.defineStreamHandler(getStreams)
|
|
| 34 |
|
| 35 |
server(addon).serve({
|
| 36 |
port: env.port,
|
| 37 |
-
})
|
|
|
|
| 4 |
|
| 5 |
const builder = require('./addon')
|
| 6 |
const server = require('./server')
|
| 7 |
+
const useCases = require('./use-cases')
|
| 8 |
const handlers = require('./handlers')
|
| 9 |
|
| 10 |
const {
|
|
|
|
| 34 |
|
| 35 |
server(addon).serve({
|
| 36 |
port: env.port,
|
| 37 |
+
})
|
package.json
CHANGED
|
@@ -21,4 +21,4 @@
|
|
| 21 |
"nodemon": "^2.0.3",
|
| 22 |
"prettier": "^3.2.5"
|
| 23 |
}
|
| 24 |
-
}
|
|
|
|
| 21 |
"nodemon": "^2.0.3",
|
| 22 |
"prettier": "^3.2.5"
|
| 23 |
}
|
| 24 |
+
}
|
server.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
-
const { serveHTTP } = require('stremio-addon-sdk')
|
| 2 |
|
| 3 |
const Server = (builder) => {
|
| 4 |
const serve = ({ port }) => {
|
| 5 |
-
serveHTTP(builder.getInterface(), { port })
|
| 6 |
-
}
|
| 7 |
|
| 8 |
return {
|
| 9 |
-
serve,
|
| 10 |
-
}
|
| 11 |
-
}
|
| 12 |
|
| 13 |
-
module.exports = Server
|
|
|
|
| 1 |
+
const { serveHTTP } = require('stremio-addon-sdk')
|
| 2 |
|
| 3 |
const Server = (builder) => {
|
| 4 |
const serve = ({ port }) => {
|
| 5 |
+
serveHTTP(builder.getInterface(), { port })
|
| 6 |
+
}
|
| 7 |
|
| 8 |
return {
|
| 9 |
+
serve,
|
| 10 |
+
}
|
| 11 |
+
}
|
| 12 |
|
| 13 |
+
module.exports = Server
|
use-cases/catalog.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const Catalog = (dependencies) => {
|
| 2 |
+
const { httpClient, queryBuilder, env } = dependencies
|
| 3 |
+
|
| 4 |
+
// https://archive.org/advancedsearch.php?q=collection%3A%28feature_films%29+AND+mediatype%3A%28movies%29&fl%5B%5D=avg_rating&fl%5B%5D=description&fl%5B%5D=genre&fl%5B%5D=headerImage&fl%5B%5D=identifier&fl%5B%5D=publicdate&fl%5B%5D=rights&fl%5B%5D=subject&fl%5B%5D=title&sort%5B%5D=&sort%5B%5D=&sort%5B%5D=&rows=50&page=1&output=json
|
| 5 |
+
|
| 6 |
+
const searchCatalog = async (request) => {
|
| 7 |
+
const { search, genre, skip } = request
|
| 8 |
+
|
| 9 |
+
try {
|
| 10 |
+
const query = queryBuilder({
|
| 11 |
+
collection: 'feature_films',
|
| 12 |
+
mediatype: 'movies',
|
| 13 |
+
search: search ? `${search}*` : null,
|
| 14 |
+
subject: genre,
|
| 15 |
+
})
|
| 16 |
+
|
| 17 |
+
const response = await httpClient.get(env.url.search, {
|
| 18 |
+
params: {
|
| 19 |
+
count: (+skip || 0) + 100,
|
| 20 |
+
sorts: 'num_reviews desc,avg_rating desc',
|
| 21 |
+
license: 'publicdomain',
|
| 22 |
+
fields:
|
| 23 |
+
'avg_rating,creator,date,description,genre,identifier,language,subject,title,type',
|
| 24 |
+
q: query,
|
| 25 |
+
},
|
| 26 |
+
})
|
| 27 |
+
|
| 28 |
+
return response.data.items
|
| 29 |
+
} catch (error) {
|
| 30 |
+
return []
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
return {
|
| 35 |
+
searchCatalog,
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
module.exports = Catalog
|
use-cases/index.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
| 1 |
-
const
|
| 2 |
-
const
|
| 3 |
-
const
|
| 4 |
-
const Stream = require('./stream');
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
module.exports = {
|
| 20 |
-
...Catalog(dependencies),
|
| 21 |
-
...Meta(dependencies),
|
| 22 |
-
...Stream(dependencies),
|
| 23 |
-
};
|
|
|
|
| 1 |
+
const Catalog = require('./catalog')
|
| 2 |
+
const Meta = require('./meta')
|
| 3 |
+
const Stream = require('./stream')
|
|
|
|
| 4 |
|
| 5 |
+
module.exports = (dependencies) => {
|
| 6 |
+
return {
|
| 7 |
+
...Catalog({
|
| 8 |
+
...dependencies,
|
| 9 |
+
}),
|
| 10 |
+
...Meta({
|
| 11 |
+
...dependencies,
|
| 12 |
+
}),
|
| 13 |
+
...Stream({
|
| 14 |
+
...dependencies,
|
| 15 |
+
}),
|
| 16 |
+
}
|
| 17 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use-cases/meta.js
CHANGED
|
@@ -1,35 +1,17 @@
|
|
| 1 |
const Meta = (dependencies) => {
|
| 2 |
-
const { httpClient, env } = dependencies
|
| 3 |
|
| 4 |
const getMeta = async (request) => {
|
| 5 |
-
const { id } = request
|
| 6 |
|
| 7 |
-
|
| 8 |
-
// Fetch metadata for the specific ID from Archive.org
|
| 9 |
-
const response = await httpClient.get(`${env.url.metadata}/${id}`);
|
| 10 |
-
const data = response.data;
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
id: `archorg.addon:${id}`,
|
| 15 |
-
name: data.metadata.title || "Unknown Title",
|
| 16 |
-
description: data.metadata.description || "No description available.",
|
| 17 |
-
genre: data.metadata.subject ? data.metadata.subject.join(", ") : "Unknown",
|
| 18 |
-
poster: `https://archive.org/services/img/${id}`, // Use identifier for image
|
| 19 |
-
background: `https://archive.org/services/img/${id}`,
|
| 20 |
-
type: 'movie',
|
| 21 |
-
};
|
| 22 |
-
|
| 23 |
-
return { meta };
|
| 24 |
-
} catch (error) {
|
| 25 |
-
console.error("Error in getMeta:", error.message);
|
| 26 |
-
return { meta: null };
|
| 27 |
-
}
|
| 28 |
-
};
|
| 29 |
|
| 30 |
return {
|
| 31 |
getMeta,
|
| 32 |
-
}
|
| 33 |
-
}
|
| 34 |
|
| 35 |
-
module.exports = Meta
|
|
|
|
| 1 |
const Meta = (dependencies) => {
|
| 2 |
+
const { httpClient, env } = dependencies
|
| 3 |
|
| 4 |
const getMeta = async (request) => {
|
| 5 |
+
const { id } = request
|
| 6 |
|
| 7 |
+
const response = await httpClient.get(`${env.url.metadata}/${id}`)
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
return response.data.metadata
|
| 10 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
return {
|
| 13 |
getMeta,
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
|
| 17 |
+
module.exports = Meta
|
use-cases/stream.js
CHANGED
|
@@ -1,51 +1,38 @@
|
|
| 1 |
const Stream = (dependencies) => {
|
| 2 |
-
const { httpClient, env } = dependencies
|
| 3 |
|
| 4 |
const getStreams = async (request) => {
|
| 5 |
-
const { id } = request
|
| 6 |
|
| 7 |
-
|
| 8 |
-
// Fetch file list from Archive.org for the specific item
|
| 9 |
-
const response = await httpClient.get(`${env.url.metadata}/${id}/files`);
|
| 10 |
-
const streams = extractStreams({ id, result: response.data.files });
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
console.error("Error in getStreams:", error.message);
|
| 15 |
-
return { streams: [], subtitles: [] };
|
| 16 |
-
}
|
| 17 |
-
};
|
| 18 |
|
| 19 |
-
//
|
| 20 |
const extractStreams = ({ id, result }) => {
|
| 21 |
-
const streams = []
|
| 22 |
-
const subtitles = []
|
| 23 |
|
| 24 |
for (const file of result) {
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
streams.push({
|
| 28 |
-
title: "Watch Now",
|
| 29 |
-
url: `${env.url.stream}/${id}/${file.name}`,
|
| 30 |
-
});
|
| 31 |
}
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
subtitles.push({
|
| 36 |
-
id: file.name,
|
| 37 |
-
lang: file.language || "en",
|
| 38 |
-
url: `${env.url.stream}/${id}/${file.name}`,
|
| 39 |
-
});
|
| 40 |
}
|
| 41 |
}
|
| 42 |
|
| 43 |
-
return {
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
return {
|
| 47 |
getStreams,
|
| 48 |
-
}
|
| 49 |
-
}
|
| 50 |
|
| 51 |
-
module.exports = Stream
|
|
|
|
| 1 |
const Stream = (dependencies) => {
|
| 2 |
+
const { httpClient, env } = dependencies
|
| 3 |
|
| 4 |
const getStreams = async (request) => {
|
| 5 |
+
const { id } = request
|
| 6 |
|
| 7 |
+
const response = await httpClient.get(`${env.url.metadata}/${id}/files`)
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
return extractStreams({ id, result: response.data.result })
|
| 10 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
// Returns only streams supported by Stremio
|
| 13 |
const extractStreams = ({ id, result }) => {
|
| 14 |
+
const streams = []
|
| 15 |
+
const subtitles = []
|
| 16 |
|
| 17 |
for (const file of result) {
|
| 18 |
+
if (file.name.match(`${id}(.*)(.mp4|.torrent)`)) {
|
| 19 |
+
streams.push(file)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
|
| 22 |
+
if (file.name.match(`${id}(.*)(.srt)`)) {
|
| 23 |
+
subtitles.push(file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
}
|
| 25 |
}
|
| 26 |
|
| 27 |
+
return {
|
| 28 |
+
streams,
|
| 29 |
+
subtitles,
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
|
| 33 |
return {
|
| 34 |
getStreams,
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
|
| 38 |
+
module.exports = Stream
|