diff --git a/components/Preview/components/Actions/index.tsx b/components/Preview/components/Actions/index.tsx
index 59e233b..8fe84df 100644
--- a/components/Preview/components/Actions/index.tsx
+++ b/components/Preview/components/Actions/index.tsx
@@ -92,12 +92,7 @@ const Actions = ({ show, className, externalLink }: Props) => {
onClick={async () => {
const showTorrentsModal = (await import('../Torrents')).default;
- showTorrentsModal({
- imdbID: show.imdb_id!,
- title: show.title,
- backdrop: show.backdrop,
- year: new Date(show.release).getFullYear()
- });
+ showTorrentsModal(show);
}}
>
diff --git a/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx b/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx
index 193849a..b8a1d7a 100644
--- a/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx
+++ b/components/Preview/components/Torrents/components/TorrentsTable/components/Actions/index.tsx
@@ -1,4 +1,4 @@
-import { FC, useMemo } from 'react';
+import { FC, useMemo, useState } from 'react';
import { Cast, Download, ListVideo, Loader, Magnet, Play, TrafficCone } from 'lucide-react';
import { providers } from '@/components/Preview/components/Torrents/constants';
@@ -14,17 +14,18 @@ import showPlayerModal from './components/Player';
import useMagnet from './useMagnet';
interface Props {
+ show: Show & Partial;
torrent: Torrent;
- backdrop: string;
title: string;
provider: string;
}
-const Actions: FC = ({ torrent, backdrop, title, provider }) => {
+const Actions: FC = ({ torrent, title, provider, show }) => {
const prefix = usePrefix();
const cast = useCastMagnet();
const streamUrl = useStreamUrl();
const M3UUrl = useM3UUrl();
+ const [isStreamPending, setIsStreamPending] = useState(false);
const isStandalone = isStandaloneApp();
@@ -53,11 +54,24 @@ const Actions: FC = ({ torrent, backdrop, title, provider }) => {
const supportedForCast = prefix && !prefix.includes('{host}');
const handleM3ULink = () => {
- const link = window.open(
- `${M3UUrl}${encodeURIComponent(`${streamUrl}/stream?m3u&link=${encodeURIComponent(magnet)}`)}`,
- '_blank'
- );
- setTimeout(() => link?.close(), 1000);
+ setIsStreamPending(true);
+
+ const params = new URLSearchParams({
+ m3u: `${streamUrl}/stream?m3u&link=${magnet}`,
+ poster: show.poster['2x'],
+ backdrop: show.backdrop,
+ type: show.type,
+ name: show.title,
+ imdb_id: show.imdb_id ?? '',
+ year: new Date(show.release).getFullYear().toString(),
+ runtime: show.runtime?.toString() ?? ''
+ });
+
+ fetch(`${M3UUrl}?${params}`, {
+ method: 'GET'
+ })
+ .catch(() => {})
+ .finally(() => setIsStreamPending(false));
};
return (
@@ -71,7 +85,7 @@ const Actions: FC = ({ torrent, backdrop, title, provider }) => {
'hover:shadow-lg hover:shadow-red-600/60 duration-200 transition-all hover:bg-red-600'
)}
onClick={() => {
- showPlayerModal({ backdrop, title, hash, magnet });
+ showPlayerModal({ backdrop: show.backdrop, title, hash, magnet });
}}
title='Play'
>
@@ -92,8 +106,20 @@ const Actions: FC = ({ torrent, backdrop, title, provider }) => {
{M3UUrl ? (
-