chore: add priority for sorting, move VixSrc up and RgShows down

This commit is contained in:
WebStreamr 2026-01-18 13:21:17 +00:00
parent a9c281c8c4
commit 7b708e2385
No known key found for this signature in database
12 changed files with 148 additions and 6 deletions

View file

@ -16,6 +16,8 @@ export class RgShows extends Source {
public readonly baseUrl = 'https://rgshows.ru';
public override readonly priority = -1;
private readonly fetcher: Fetcher;
public constructor(fetcher: Fetcher) {

View file

@ -35,6 +35,8 @@ export abstract class Source {
public abstract readonly baseUrl: string;
public readonly priority: number = 0;
protected abstract handleInternal(ctx: Context, type: ContentType, id: Id): Promise<(SourceResult[])>;
public static stats() {

View file

@ -14,6 +14,8 @@ export class VixSrc extends Source {
public readonly baseUrl = 'https://vixsrc.to';
public override readonly priority = 1;
private readonly fetcher: Fetcher;
public constructor(fetcher: Fetcher) {

View file

@ -78,12 +78,13 @@ export enum BlockedReason {
export interface Meta {
bytes?: number | undefined;
countryCodes?: CountryCode[];
height?: number | undefined;
referer?: string | undefined;
title?: string | undefined;
sourceLabel?: string | undefined;
sourceId?: string | undefined;
extractorId?: string | undefined;
height?: number | undefined;
priority?: number | undefined;
referer?: string | undefined;
sourceId?: string | undefined;
sourceLabel?: string | undefined;
title?: string | undefined;
}
export enum Format {

View file

@ -3,12 +3,16 @@ import winston from 'winston';
import { BlockedError, HttpError, NotFoundError, QueueIsFullError, TimeoutError, TooManyRequestsError, TooManyTimeoutsError } from '../error';
import { createExtractors, Extractor, ExtractorRegistry } from '../extractor';
import { HubCloud } from '../extractor/HubCloud';
import { RgShows as RgShowsExtractor } from '../extractor/RgShows';
import { VidSrc as VidSrcExtractor } from '../extractor/VidSrc';
import { VixSrc as VixSrcExtractor } from '../extractor/VixSrc';
import { Source, SourceResult } from '../source';
import { FourKHDHub } from '../source/FourKHDHub';
import { MeineCloud } from '../source/MeineCloud';
import { MostraGuarda } from '../source/MostraGuarda';
import { RgShows } from '../source/RgShows';
import { VidSrc } from '../source/VidSrc';
import { VixSrc } from '../source/VixSrc';
import { createTestContext } from '../test';
import { BlockedReason, CountryCode, Format, UrlResult } from '../types';
import { FetcherMock } from './FetcherMock';
@ -88,6 +92,13 @@ describe('resolve', () => {
expect(streams.streams).toMatchSnapshot();
});
test('uses priority for sorting', async () => {
const streamResolver = new StreamResolver(logger, new ExtractorRegistry(logger, [new RgShowsExtractor(fetcher), new VixSrcExtractor(fetcher)]));
const streams = await streamResolver.resolve(createTestContext(), [new RgShows(fetcher), new VixSrc(fetcher)], 'series', new TmdbId(2190, 26, 2));
expect(streams.streams).toMatchSnapshot();
});
test('adds error info', async () => {
class MockSource extends Source {
public readonly id = 'mocksource';

View file

@ -54,7 +54,7 @@ export class StreamResolver {
try {
const sourceResults = await source.handle(ctx, type, id);
const sourceUrlResults = await Promise.all(
sourceResults.map(({ url, meta }) => this.extractorRegistry.handle(ctx, url, { ...meta, sourceLabel: source.label, sourceId: source.id }, true)),
sourceResults.map(({ url, meta }) => this.extractorRegistry.handle(ctx, url, { ...meta, sourceLabel: source.label, sourceId: source.id, priority: source.priority }, true)),
);
for (const urlResult of sourceUrlResults.flat()) {
@ -130,6 +130,11 @@ export class StreamResolver {
return bytesComparison;
}
const priorityComparison = (b.meta?.priority ?? 0) - (a.meta?.priority ?? 0);
if (priorityComparison !== 0) {
return priorityComparison;
}
return a.label.localeCompare(b.label);
});

View file

@ -0,0 +1 @@
{"stream":{"url":"https://sad.moriartis.store/v4/pk8/karuh/cf-master.1755845058.txt?t=121478a4&e=1765241578"}}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,6 @@
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=627686,RESOLUTION=1280x720,FRAME-RATE=24.000,CODECS="avc1.64001f,mp4a.40.2"
index-f1-v1-a1.txt
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1173799,RESOLUTION=1920x1080,FRAME-RATE=24.000,CODECS="avc1.640028,mp4a.40.2"
index-f2-v1-a1.txt

View file

@ -0,0 +1,12 @@
#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Italian",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="ita",URI="https://vixsrc.to/playlist/418073?type=audio&rendition=ita&token=xvtDbh4q0VdzVFfIH5kfwg&expires=1773926255&edge=sc-u15-01"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="English",DEFAULT=NO,AUTOSELECT=NO,FORCED=NO,LANGUAGE="eng",URI="https://vixsrc.to/playlist/418073?type=audio&rendition=eng&token=xvtDbh4q0VdzVFfIH5kfwg&expires=1773926255&edge=sc-u15-01"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English [CC]",DEFAULT=NO,AUTOSELECT=NO,FORCED=NO,LANGUAGE="eng",URI="https://vixsrc.to/playlist/418073?type=subtitle&rendition=eng-3&token=xvtDbh4q0VdzVFfIH5kfwg&expires=1773926255&edge=sc-u15-01"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=NO,AUTOSELECT=NO,FORCED=NO,LANGUAGE="eng",URI="https://vixsrc.to/playlist/418073?type=subtitle&rendition=eng-4&token=xvtDbh4q0VdzVFfIH5kfwg&expires=1773926255&edge=sc-u15-01"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Italian",DEFAULT=NO,AUTOSELECT=NO,FORCED=NO,LANGUAGE="ita",URI="https://vixsrc.to/playlist/418073?type=subtitle&rendition=ita-5&token=xvtDbh4q0VdzVFfIH5kfwg&expires=1773926255&edge=sc-u15-01"
#EXT-X-STREAM-INF:BANDWIDTH=4500000,CODECS="avc1.640028,mp4a.40.2",RESOLUTION=1920x1080,AUDIO="audio",SUBTITLES="subs"
https://vixsrc.to/playlist/418073?type=video&rendition=1080p&token=F2MTLlphkA83s_cVhdhFBA&expires=1773926255&edge=sc-u15-01
#EXT-X-STREAM-INF:BANDWIDTH=1800000,CODECS="avc1.64001f,mp4a.40.2",RESOLUTION=1280x720,AUDIO="audio",SUBTITLES="subs"
https://vixsrc.to/playlist/418073?type=video&rendition=720p&token=KoitnEkRaoatCgH9j3M7Ng&expires=1773926255&edge=sc-u15-01
#EXT-X-STREAM-INF:BANDWIDTH=1080000,CODECS="avc1.64001f,mp4a.40.2",RESOLUTION=854x480,AUDIO="audio",SUBTITLES="subs"
https://vixsrc.to/playlist/418073?type=video&rendition=480p&token=kbo5ZqvHBboUrQ0DPeniGA&expires=1773926255&edge=sc-u15-01

File diff suppressed because one or more lines are too long

View file

@ -532,3 +532,35 @@ exports[`resolve skips fallback sources if possible 1`] = `
},
]
`;
exports[`resolve uses priority for sorting 1`] = `
[
{
"behaviorHints": {
"bingeGroup": "webstreamr-vixsrc-vixsrc-multi_en_it",
"notWebReady": true,
},
"name": "WebStreamr 🌐 🇺🇸 🇮🇹 1080p",
"title": "South Park S26E02
🔗 VixSrc",
"url": "https://vixsrc.to/playlist/418073.m3u8?token=9d4070344ef84e26fa4dd3cdf5c45037&expires=1773926255&h=1",
},
{
"behaviorHints": {
"bingeGroup": "webstreamr-rgshows-rgshows-multi",
"notWebReady": true,
"proxyHeaders": {
"request": {
"Origin": "https://rgshows.ru",
"Referer": "https://rgshows.ru/",
"User-Agent": "Mozilla",
},
},
},
"name": "WebStreamr 🌐 1080p",
"title": "South Park S26E02
🔗 RgShows",
"url": "https://sad.moriartis.store/v4/pk8/karuh/cf-master.1755845058.txt?t=121478a4&e=1765241578",
},
]
`;