log: toloka magnet
This commit is contained in:
1 parent
4f4e6b1307
commit
3792e3face
6 files changed
+474
-4
No files matched your search
+15
@@ -4,12 +4,15 @@ import { Cast, ListVideo, Magnet, Play } from 'lucide-react';
|
||||
import { Quality } from '@/api/parsers/yts/models';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import ButtonsGroup from '@/components/ui/buttons-group';
|
||||
import { toast, useToast } from '@/hooks/useToast';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import { providers } from '../../../../constants';
|
||||
import { useCastMagnet, usePrefix } from '../../../../hooks/useMagnetHosts';
|
||||
import showPlayer from '../../../Player';
|
||||
|
||||
import useMagnet from './useMagnet';
|
||||
|
||||
interface Props {
|
||||
torrent: Torrent;
|
||||
backdrop: string;
|
||||
@@ -21,6 +24,8 @@ const Actions: FC<Props> = ({ torrent, backdrop, title, provider }) => {
|
||||
const prefix = usePrefix();
|
||||
const cast = useCastMagnet();
|
||||
|
||||
const { toast } = useToast();
|
||||
|
||||
const supportedForStream = Boolean(
|
||||
(provider === providers.yts.key &&
|
||||
torrent.seeders &&
|
||||
@@ -28,6 +33,8 @@ const Actions: FC<Props> = ({ torrent, backdrop, title, provider }) => {
|
||||
torrent.container?.includes('mp4')
|
||||
);
|
||||
|
||||
const magnet = useMagnet(torrent);
|
||||
|
||||
const supportedForCast = prefix && !prefix.includes('{host}');
|
||||
|
||||
return (
|
||||
@@ -42,6 +49,14 @@ const Actions: FC<Props> = ({ torrent, backdrop, title, provider }) => {
|
||||
<Play size={15} />
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant='outline'
|
||||
className='relative grow-0 px-3'
|
||||
disabled={magnet.isPending}
|
||||
onClick={() => magnet.mutateAsync().then((magnet) => toast({ description: magnet }))}
|
||||
>
|
||||
Get magnet
|
||||
</Button>
|
||||
<Button variant='outline' className='relative grow-0 px-3' title='Play using your native video player'>
|
||||
<a
|
||||
className='absolute left-0 top-0 size-full'
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
|
||||
const useMagnet = (torrent: Torrent) => {
|
||||
return useMutation({
|
||||
mutationFn: async () =>
|
||||
torrent.magnet ? torrent.magnet : fetch(`/api/magnet?url=${torrent.download}`).then((response) => response.json())
|
||||
});
|
||||
};
|
||||
|
||||
export default useMagnet;
|
||||
Reference in new issue
Block a user