feat(torrents): add Galaxy (TorrentGalaxy) provider with IMDb-first search and inline magnets

- new tg parser: /imdb-detail/<tt...> when an IMDb id is available (exact title, local seeder/size sort), keyword search as fallback; rows carry full magnets inline so Play works without a second fetch
- wire tg into /api/torrents and /api/magnet, TG_HOST env (default https://torrentgalaxy.info)
- Galaxy tab in the torrents modal; tabs now share equal space and hidden-scroll on overflow
- fix tab drag&drop: reorder on the sanitized order so tabs added later (like Galaxy) can be dragged
This commit is contained in:
ner committed 2026-10-25 18:24:08 +02:00
1 parent fb645b75a5
commit c41f1f098f
8 files changed
+184 -9

No files matched your search

@@ -20,6 +20,12 @@ export const providers = {
queryFn: (options: Options) => queryFn({ ...options, key: 'tpb' }),
sortable: true
},
tg: {
label: 'Galaxy',
key: 'tg',
queryFn: (options: Options) => queryFn({ ...options, key: 'tg' }),
sortable: true
},
tlk: {
label: 'Toloka',
key: 'tlk',
@@ -34,7 +34,7 @@ const SortableTabsTrigger: FC<{ provider: (typeof providers)[ProviderKey]; isLoa
ref={setNodeRef}
value={provider.key}
style={{ transform: CSS.Transform.toString(transform), transition }}
className={cn('min-h-8 touch-none', isDragging && 'z-10 opacity-50')}
className={cn('min-h-8 min-w-fit flex-1 touch-none', isDragging && 'z-10 opacity-50')}
{...listeners}
>
{isLoading ? <Loader className='animate-spin' size={14} /> : provider.label}
@@ -77,6 +77,15 @@ const showTorrentsModal = create(({ onResolve, ...show }: Props) => {
type: show.type,
show: tracked
});
const tg = useTorrents({
query,
queryFn: providers.tg.queryFn,
sort,
key: providers.tg.key,
imdbID: show.imdb_id!,
type: show.type,
show: tracked
});
const tlk = useTorrents({
query: scopedQuery,
queryFn: providers.tlk.queryFn,
@@ -87,7 +96,7 @@ const showTorrentsModal = create(({ onResolve, ...show }: Props) => {
show: tracked
});
const queries = { yts, tpb, tlk };
const queries = { yts, tpb, tg, tlk };
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 || tg.isPending || tlk.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='no-scrollbar flex w-full overflow-x-auto'>
{tabs.map(({ provider, query }) => (
<SortableTabsTrigger key={provider.key} provider={provider} isLoading={query.isLoading} />
))}
@@ -32,12 +32,14 @@ const useProvidersOrder = () => {
if (!over || active.id === over.id) return;
void setOrder((current) => {
const activeIndex = current.indexOf(active.id as ProviderKey);
const overIndex = current.indexOf(over.id as ProviderKey);
const order = sanitize(current);
const activeIndex = order.indexOf(active.id as ProviderKey);
const overIndex = order.indexOf(over.id as ProviderKey);
if (activeIndex === -1 || overIndex === -1) return current;
return arrayMove(current, activeIndex, overIndex);
return arrayMove(order, activeIndex, overIndex);
});
};