From 32d21193b1d35a5fb31504cf45a706b4d620029d Mon Sep 17 00:00:00 2001 From: MidnightKittenCat <66114416+MidnightKittenCat@users.noreply.github.com> Date: Fri, 21 Nov 2025 02:04:37 +1000 Subject: [PATCH] feat: add private torrent detection for stremthru torz (#499) Co-authored-by: Viren070 --- packages/core/src/db/schemas.ts | 6 ++++-- packages/core/src/formatters/base.ts | 2 ++ packages/core/src/parser/streams.ts | 8 ++++++++ packages/core/src/presets/stremthru.ts | 7 +++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/core/src/db/schemas.ts b/packages/core/src/db/schemas.ts index 194f2ed3..5bc63ff5 100644 --- a/packages/core/src/db/schemas.ts +++ b/packages/core/src/db/schemas.ts @@ -695,7 +695,8 @@ export const ParsedStreamSchema = z.object({ infoHash: z.string().min(1).optional(), fileIdx: z.number().optional(), seeders: z.number().optional(), - sources: z.array(z.string().min(1)).optional(), // array of tracker urls and DHT nodes + sources: z.array(z.string().min(1)).optional(), + private: z.boolean().optional(), }) .optional(), countryWhitelist: z.array(z.string().length(3)).optional(), @@ -899,7 +900,8 @@ export const AIOStream = StreamSchema.extend({ infoHash: z.string().min(1).optional(), fileIdx: z.number().optional(), seeders: z.number().optional(), - sources: z.array(z.string().min(1)).optional(), // array of tracker urls and DHT nodes + sources: z.array(z.string().min(1)).optional(), + private: z.boolean().optional(), }) .optional(), duration: z.number().optional(), diff --git a/packages/core/src/formatters/base.ts b/packages/core/src/formatters/base.ts index acf8755d..8342d9f7 100644 --- a/packages/core/src/formatters/base.ts +++ b/packages/core/src/formatters/base.ts @@ -96,6 +96,7 @@ export interface ParseValue { seasonEpisode: string[] | null; seasonPack: boolean; seeders: number | null; + private: boolean; age: string | null; ageHours: number | null; duration: number | null; @@ -296,6 +297,7 @@ export abstract class BaseFormatter { audioChannels: stream.parsedFile?.audioChannels || null, indexer: stream.indexer || null, seeders: stream.torrent?.seeders ?? null, + private: stream.torrent?.private ?? false, year: stream.parsedFile?.year || null, type: stream.type || null, title: stream.parsedFile?.title || null, diff --git a/packages/core/src/parser/streams.ts b/packages/core/src/parser/streams.ts index ebe7140d..313f6363 100644 --- a/packages/core/src/parser/streams.ts +++ b/packages/core/src/parser/streams.ts @@ -137,6 +137,7 @@ class StreamParser { sources: stream.sources ?? undefined, fileIdx: stream.fileIdx ?? this.getFileIdx(stream, parsedStream) ?? undefined, + private: this.isPrivate(stream, parsedStream), }; return parsedStream; @@ -327,6 +328,13 @@ class StreamParser { return false; } + protected isPrivate( + stream: Stream, + currentParsedStream: ParsedStream + ): boolean | undefined { + return false; + } + protected getIndexer( stream: Stream, currentParsedStream: ParsedStream diff --git a/packages/core/src/presets/stremthru.ts b/packages/core/src/presets/stremthru.ts index cdc2c522..99fd6c6c 100644 --- a/packages/core/src/presets/stremthru.ts +++ b/packages/core/src/presets/stremthru.ts @@ -13,6 +13,13 @@ export const stremthruSpecialCases: Partial< }; export class StremThruStreamParser extends StreamParser { + protected override isPrivate( + stream: Stream, + _currentParsedStream: ParsedStream + ): boolean | undefined { + return stream.name?.includes('🔑') ? true : false; + } + protected override getIndexer( stream: Stream, currentParsedStream: ParsedStream