Coder Social home page Coder Social logo

primetorrentstream's Introduction

Torrent Stream Server

Docker CodeQL Dependencies npm version

Whats new:

  • Search & stream torrents - preview
  • Stream any file from the torrent - preview
  • Monitor activity - preview

HTTP server to convert any torrent to video stream

Demo

Installation

Deploy

NPM package:

Development

One-click ready-to-code development environments:

Open in Gitpod

Frontend & backend are separate packages.

So during developemnt you will need to run two dev servers with live reload:

  • npm run dev-backend - start dev server on 3000 port
  • npm run dev-frontend - start dev server on 3001 port

Commands

  • npm install - will install both: frontend & backend
  • npm run build - will build backend to lib directory & frontend to frontend/build
  • npm run start - start HTTP server with frontend support
  • npm run dev-backend - start backend server with live reload on 3000 port
  • npm run dev-frontend - start frontend server with live reload on 3001 port

Configuration

ENV variables

Check bellow for descriptions

  • PORT
  • HOST
  • TRUST_PROXY

Configuration file can overwrite ENV variables

File

You can pass JSON config file to any run command (e.g. npm run start config.json)

Available parameters:

  • host - server host. Default is process.env.HOST or 0.0.0.0
  • port - server port. Default process.env.PORT or 3000.
  • trustProxy - get ip from X-Forwarded-* header, check more, Default is true if running inside App Engine or Heroku else false
  • logging
    • level - debug, info, warn or error. Default info.
    • transports - {"type": "console"} or {"type": "loggly","subdomain": "my-subdomain","token": "abc","tags":["my-tag"]}. Default console.
  • torrents
    • path - torrents storage path. Default /tmp/torrent-stream-server.
    • autocleanInternal - how many seconds downloaded from last stream torrent is kept before deleting. Default is 1 hour.
  • security
    • streamApi - API is disabled when using this option unless apiKey is set.
      • key - JWT token.
      • maxAge - the maximum allowed age for tokens to still be valid.
    • frontendEnabled - enable demo page. Default is true.
    • apiKey - key which should be passed to headers to access the API (authorization: bearer ${apiKey}).

API

API uses swagger.yaml to:

  1. To generate API documentation page, which can be accesed when using npm run dev on http://127.0.0.1:3000/api-docs.
  2. To generate frontend client (frontend/src/helpers/client)
  3. To generate backend models (src/models)

Check documentation

Example

Running the following command from a shell will run VLC and start playing the Sintel movie stream from its public torrent:

$ vlc "http://localhost:3000/stream?torrent=magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&file=Sintel.mp4"

JWT tokens

You can protect stream API with JWT token.

Add key to config:

{
    "secury": {
        "streamApi": {
            "key": "secret key",
            "maxAge": "5h"
        }
    }
}

Create signed key:

Headers

{
  "alg": "HS256",
  "typ": "JWT"
}

Payload

{
   "iat": 1554577257,
   "torrent": "magnet:?xt=urn:btih:4GOZACR2HENLSNHA7K6GSOFSTDWGOENJ&tr=http://nyaa.tracker.wf:7777/announce&tr=udp://tracker.coppersurfer.tk:6969/announce&tr=udp://tracker.internetwarriors.net:1337/announce&tr=udp://tracker.leechersparadise.org:6969/announce&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://open.stealth.si:80/announce&tr=udp://p4p.arenabg.com:1337/announce&tr=udp://mgtracker.org:6969/announce&tr=udp://tracker.tiny-vps.com:6969/announce&tr=udp://peerfect.org:6969/announce&tr=http://share.camoe.cn:8080/announce&tr=http://t.nyaatracker.com:80/announce&tr=https://open.kickasstracker.com:443/announce"
}
  • iat - unix timestamp, which indicates when was the key generated
  • torrent - torrent magent link

Signature

HMACSHA256(
  base64UrlEncode(header) + "." +
  base64UrlEncode(payload),
  "ENTER KEY HERE"
)

Use generated token

http://127.0.0.1:3000/stream?token=JWT_TOKEN

primetorrentstream's People

Contributors

kiralt avatar pataquets avatar primeithard avatar

Watchers

 avatar

Forkers

whiteprime

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.