feat(torrents): pass tmdb_id and season to m3u stream for series
Add seasonFromEpisodes (single season only, skips ranges) and include tmdb_id plus the resolved season in the m3u/cast stream params. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
735c63471a
commit
284458f783
2 files changed
+14
-1
No files matched your search
+7
-1
@@ -8,7 +8,7 @@ import ButtonsGroup from '@/components/ui/buttons-group';
|
|||||||
import { Quality } from '@/data/parsers/yts/models';
|
import { Quality } from '@/data/parsers/yts/models';
|
||||||
import { useM3UUrl } from '@/hooks/useM3UStreamUrl';
|
import { useM3UUrl } from '@/hooks/useM3UStreamUrl';
|
||||||
import { useStreamUrl } from '@/hooks/useStreamUrl';
|
import { useStreamUrl } from '@/hooks/useStreamUrl';
|
||||||
import { cn, detectSafari, getMagnetHash, isStandaloneApp, torrentKey } from '@/lib/utils';
|
import { cn, detectSafari, getMagnetHash, isStandaloneApp, seasonFromEpisodes, torrentKey } from '@/lib/utils';
|
||||||
|
|
||||||
import usePinnedTorrents from '../../../../usePinnedTorrents';
|
import usePinnedTorrents from '../../../../usePinnedTorrents';
|
||||||
import useUnplayable from '../../../../useUnplayable';
|
import useUnplayable from '../../../../useUnplayable';
|
||||||
@@ -82,10 +82,16 @@ const Actions: FC<Props> = ({ torrent, title, provider, show }) => {
|
|||||||
type: show.type,
|
type: show.type,
|
||||||
name: show.title,
|
name: show.title,
|
||||||
imdb_id: show.imdb_id ?? '',
|
imdb_id: show.imdb_id ?? '',
|
||||||
|
tmdb_id: show.id?.toString() ?? '',
|
||||||
year: new Date(show.release).getFullYear().toString(),
|
year: new Date(show.release).getFullYear().toString(),
|
||||||
runtime: show.runtime?.toString() ?? ''
|
runtime: show.runtime?.toString() ?? ''
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (show.type === 'tv') {
|
||||||
|
const season = seasonFromEpisodes(torrent.episodes) ?? show.airing?.season;
|
||||||
|
if (season != null) params.set('season', season.toString());
|
||||||
|
}
|
||||||
|
|
||||||
if (isSafari) {
|
if (isSafari) {
|
||||||
const link = window.open(`${M3UUrl}?${params}`, '_blank');
|
const link = window.open(`${M3UUrl}?${params}`, '_blank');
|
||||||
return setTimeout(() => {
|
return setTimeout(() => {
|
||||||
|
|||||||
@@ -55,6 +55,13 @@ export const getMagnetHash = (link: string) => {
|
|||||||
export const torrentKey = (torrent: Torrent) =>
|
export const torrentKey = (torrent: Torrent) =>
|
||||||
torrent.download || getMagnetHash(torrent.magnet) || torrent.hash || torrent.id;
|
torrent.download || getMagnetHash(torrent.magnet) || torrent.hash || torrent.id;
|
||||||
|
|
||||||
|
export const seasonFromEpisodes = (episodes?: string): number | undefined => {
|
||||||
|
if (!episodes) return undefined;
|
||||||
|
if (/^S\d+\s*[-–—]\s*\d+/i.test(episodes)) return undefined;
|
||||||
|
const [, season] = episodes.match(/^S(\d+)/i) || [];
|
||||||
|
return season ? Number(season) : undefined;
|
||||||
|
};
|
||||||
|
|
||||||
export const formatBytes = (bytes?: number) => {
|
export const formatBytes = (bytes?: number) => {
|
||||||
if (bytes == null || !isFinite(bytes)) return '';
|
if (bytes == null || !isFinite(bytes)) return '';
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user