feat(torrents): add 0day.community tracker as a torrent provider

Private xbtit tracker (tracker.0day.community): session login via
takelogin.php with cookie jar persisted to Redis, cp1251-decoded
word-AND search scoped to movie/TV categories, magnet built from the
fetched .torrent (download.php requires the name param) + public
trackers. Generalizes /api/magnet to dispatch by provider.
This commit is contained in:
ner committed 2026-10-25 17:09:51 +02:00
1 parent 87513bb6a8
commit 1fd8f0f7e5
11 files changed
+291 -11

No files matched your search

@@ -52,7 +52,7 @@ const Actions: FC<Props> = ({ torrent, title, provider, show }) => {
return !container || /mp4|mkv|webm|mov|m4v|avi|ts/.test(container);
}, [torrent, provider]);
const fetchMagnet = useMagnet(torrent);
const fetchMagnet = useMagnet(torrent, provider);
const { savedMagnet, rememberMagnet } = usePinnedTorrents();
const { isLaunched, launch } = useLaunchedTorrents();
@@ -1,11 +1,15 @@
import { useMutation } from '@tanstack/react-query';
const useMagnet = (torrent: Torrent) => {
const useMagnet = (torrent: Torrent, provider?: string) => {
return useMutation({
retry: 4,
mutationFn: async () => {
try {
const response = await fetch(`/api/magnet?url=${torrent.download}`);
const params = new URLSearchParams({ url: torrent.download as string });
if (provider) params.set('provider', provider);
const response = await fetch(`/api/magnet?${params.toString()}`);
if (!response.ok) return Promise.reject();
@@ -25,5 +25,11 @@ export const providers = {
key: 'tlk',
queryFn: (options: Options) => queryFn({ ...options, key: 'tlk' }),
sortable: true
},
odc: {
label: '0day',
key: 'odc',
queryFn: (options: Options) => queryFn({ ...options, key: 'odc' }),
sortable: true
}
};
@@ -52,10 +52,10 @@ const showTorrentsModal = create(({ onResolve, ...show }: Props) => {
const isSeries = show.type === 'tv';
// Toloka's search is a plain "contains" word-AND match with no IMDB filter. For movies,
// Toloka's and 0day's searches are plain word-AND matches with no IMDB filter. For movies,
// scope the query by the show's year to keep, e.g., "Dune" (2021) away from "Dune: Part Two" (2024);
// for series the TV sections do the disambiguation and a year suffix would hide other seasons.
const tolokaQuery = isSeries ? query : query && Number.isFinite(year) ? `${query} ${year}` : query;
const scopedQuery = isSeries ? query : query && Number.isFinite(year) ? `${query} ${year}` : query;
const tracked = { id: show.id, type: show.type, title: show.title };
@@ -78,7 +78,7 @@ const showTorrentsModal = create(({ onResolve, ...show }: Props) => {
show: tracked
});
const tlk = useTorrents({
query: tolokaQuery,
query: scopedQuery,
queryFn: providers.tlk.queryFn,
sort,
key: providers.tlk.key,
@@ -86,8 +86,17 @@ const showTorrentsModal = create(({ onResolve, ...show }: Props) => {
type: show.type,
show: tracked
});
const odc = useTorrents({
query: scopedQuery,
queryFn: providers.odc.queryFn,
sort,
key: providers.odc.key,
imdbID: show.imdb_id!,
type: show.type,
show: tracked
});
const queries = { yts, tpb, tlk };
const queries = { yts, tpb, tlk, odc };
const { order, ...dndProps } = useProvidersOrder();
@@ -117,7 +126,7 @@ const showTorrentsModal = create(({ onResolve, ...show }: Props) => {
<Button
type='submit'
className='h-full !px-3 transition-all duration-200 hover:bg-secondary-foreground hover:shadow-lg hover:shadow-secondary-foreground/60'
disabled={tpb.isPending || tlk.isPending}
disabled={tpb.isPending || tlk.isPending || odc.isPending}
>
<Search size={16} />
</Button>
@@ -126,7 +135,7 @@ const showTorrentsModal = create(({ onResolve, ...show }: Props) => {
<Tabs defaultValue={tabs[0].provider.key} className='w-full rounded-none px-2'>
<DndContext {...dndProps}>
<SortableContext items={visibleOrder} strategy={horizontalListSortingStrategy}>
<TabsList className={cn('grid w-full', isSeries ? 'grid-cols-2' : 'grid-cols-3')}>
<TabsList className={cn('grid w-full', isSeries ? 'grid-cols-3' : 'grid-cols-4')}>
{tabs.map(({ provider, query }) => (
<SortableTabsTrigger key={provider.key} provider={provider} isLoading={query.isLoading} />
))}