Giter Site home page Giter Site logo

msbapi's Introduction

MSBAPI

MSBAPI stands for "my-seedbox.com API" and it aims to simplify the process of adding new torrents to your seedbox. It is the standard brick to enable full automation of torrent downloading. You can request the API with a URL linking to a torrent file or a magnet link, and it will manage adding it to your (my-)seedbox(.com) instance.

The key features are:

  • Auto add torrent to your seedbox given the .torrent file URL or a magnet link
  • Manage download directories based on the type of torrent movie, series, etc.

Requirements

This API is designed to be used with a my-seedbox.com instance running with the ruTorrent frontend.

API Usage

There is only one route /add-torrent where you can make a POST request sending a JSON containing the url of the .torrent file or the magnet link. You can optionally add the type of torrent, this will change the download directory.

curl -X 'POST' \
  'http://localhost:5000/add-torrent' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "url": "https://webtorrent.io/torrents/big-buck-bunny.torrent",
  "type": "movie"
}'

Torrent types

Torrent types are useful to directly change the download directory based on what torrent you are downloading. Torrent types and download paths are not customizable for now, but they are already set up for a my-seedbox.com instance with a Plex server.

type Download path
movie BASE_PATH + /Plex/Films
series BASE_PATH + /Plex/Series
music BASE_PATH + /music
default BASE_PATH
null BASE_PATH

Installation

Use the package manager poetry to install msbapi.

poetry install

Use --no-dev flag if you do not need dev dependencies

Usage

Launch API server

The API server uses uvicorn and fastapi, you can launch with the following command.

uvicorn main:app --host=localhost --port 5000

API Swagger

Once the API server is launched, the API Swagger will be available at http://localhost:5000/docs/

Launch using docker container

docker run -d \
  -p 5000:5000 \
  -e CLIENT_URL=$CLIENT_URL \
  -e BASE_PATH=$BASE_PATH \
  -e AUTH_TOKEN=$AUTH_TOKEN \
  --name msbapi \
  ghcr.io/samuelrince/msbapi

Environment variables

Paramter Function
CLIENT_URL The ruTorrent URL where you usually connect to add new torrents (e.g. https://seed20.my-seedbox.com:22000)
BASE_PATH The path where torrents are downloaded by default (e.g. /data/client_2000/outp/)
AUTH_TOKEN The access token from ruTorrent interface. Please read the section "How to get your access token" below

Tests

To launch tests run the following command.

python -m pytest tests/

Additional setup steps

How to get your access token

To get your ACCESS_TOKEN you will need to log in your ruTorrent interface and the launch the Web Developer Tools from your browser. In the network tab look for a backend call (to action.php for instance) and check the request headers. You will find an Authorization header that contains your ACCESS_TOKEN as following:

Authorization: Basic <ACCESS_TOKEN>

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

msbapi's People

Contributors

samuelrince avatar

Watchers

 avatar

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.