resolve infoHash for offcloud and premiumize debrid metas

This commit is contained in:
TheBeastLT
2023-12-16 14:53:52 +02:00
parent 66988c6604
commit cf3eb270a3
2 changed files with 12 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import OffcloudClient from 'offcloud-api';
import magnet from 'magnet-uri';
import { Type } from '../lib/types.js';
import { isVideo } from '../lib/extension.js';
import StaticResponse from './static.js';
@@ -45,7 +46,6 @@ export async function getCatalog(apiKey, offset = 0) {
return OC.cloud.history()
.then(torrents => torrents)
.then(torrents => (torrents || [])
.filter(torrent => torrent && statusReady(torrent))
.map(torrent => ({
id: `${KEY}:${torrent.requestId}`,
type: Type.OTHER,
@@ -58,12 +58,14 @@ export async function getItemMeta(itemId, apiKey, ip) {
const OC = new OffcloudClient(apiKey, options);
const torrents = await OC.cloud.history();
const torrent = torrents.find(torrent => torrent.requestId === itemId)
const infoHash = torrent && magnet.decode(torrent.originalLink).infoHash
const createDate = torrent ? new Date(torrent.createdOn) : new Date();
return _getFileUrls(OC, torrent)
.then(files => ({
id: `${KEY}:${itemId}`,
type: Type.OTHER,
name: torrent.name,
infoHash: infoHash,
videos: files
.filter(file => isVideo(file))
.map((file, index) => ({