iTorrent icon indicating copy to clipboard operation
iTorrent copied to clipboard

API for interacting with other ios apps for torrent streaming

Open jarvisnexus opened this issue 5 months ago • 4 comments

Hello,

First of all, thanks for keeping this project active. Much appreciated!

I just wanted to check if iTorrent can be used a local torrent server for streaming? So that other developers can send the torrent details to iTorrent for streaming? Is it possible?

jarvisnexus avatar Aug 09 '25 01:08 jarvisnexus

you can use vlc to watch a video that is downloading. make sure you have the sequential download option turned on.

yaptx avatar Aug 10 '25 10:08 yaptx

@yaptx Yes, I know I can stream with VLC with sequential download.

What I am asking is, the support integrating with other application. I am a dev and I am currently working on a personal project for streaming Movies and TV Shows with the torrent servers like Stremio and TorrServer.

The problem with the remote streaming server, the torrent server setup needs to be running all the time whenever I wanted to watch the content. Instead, I am looking for a locally running torrent server which powers my app for streaming.

Since, iTorrent can act as a torrent server I can use it for streaming.

The app sends the torrent details (.torrent or magnet) to iTorrent and iTorrent returns with the files details for streaming.

jarvisnexus avatar Aug 10 '25 13:08 jarvisnexus

Technically I can make an intent that receive torrent file, starts it downloading and returns path where it was saved, but I don't know if apps can call intents of other apps like Shortcuts app does

XITRIX avatar Aug 10 '25 15:08 XITRIX

I’m not sure this will work, but I think it might be doable with callback URLs. I got this answer from chatgpt.

itorrent://x-callback-url/add
    ?url=magnet%3A%3Fxt%3Durn%3Abtih%3A123...
    &index=1
    &x-success=myapp://onStarted
    &x-error=myapp://onError
import * as Linking from 'expo-linking';

export async function openInITorrent(magnetLink, fileIndex) {
  const callbackUrl = Linking.createURL('onStarted'); // myapp://onStarted
  const errorUrl = Linking.createURL('onError');      // myapp://onError

  const itorrentUrl = `itorrent://x-callback-url/add?` +
    `url=${encodeURIComponent(magnetLink)}` +
    `&index=${fileIndex}` +
    `&x-success=${encodeURIComponent(callbackUrl)}` +
    `&x-error=${encodeURIComponent(errorUrl)}`;

  try {
    await Linking.openURL(itorrentUrl);
  } catch (err) {
    console.error('Failed to open iTorrent', err);
  }
}
import * as Linking from 'expo-linking';
import { useEffect } from 'react';
import { Alert } from 'react-native';

export function useITorrentCallback() {
  useEffect(() => {
    const subscription = Linking.addEventListener('url', ({ url }) => {
      const { path, queryParams } = Linking.parse(url);

      if (path === 'onStarted') {
        Alert.alert('Torrent started', JSON.stringify(queryParams));
      } else if (path === 'onError') {
        Alert.alert('Error', queryParams?.message || 'Unknown error');
      }
    });

    return () => subscription.remove();
  }, []);
}

jarvisnexus avatar Aug 10 '25 15:08 jarvisnexus