Git Product home page Git Product logo

torrent-metadata's Introduction

Torrent Metadata

Torrent Metadata

A simple web app to extract metadata from .torrent file, magnet URI or torrent info hash.


Getting Started

Server

To run it locally simply install all dependencies and run pnpm dev. Also, make sure you run server on proper port or adjust the API_URL on client side.

# clone the repo
git clone https://github.com/schardev/torrent-metadata

# install dependencies (same for client)
cd torrent-metadata/server; pnpm install

pnpm dev

The server is now running on localhost:3000 and can respond with queries.

Using the API

Querying with magnet URI or info hash:

# The API endpoint takes a `query` parameter that could be set to either a torrent magnet URI or info hash
http :3000 query='magnet:?xt=urn:btih:6e8537c9160e80042f0bc5a880ea8bf9144683ff&dn=archlinux-2023.06.01-x86_64.iso'

# OR using curl
curl -X POST "http://localhost:3000" \
    -H "Content-Type: application/json" \
    -d '{"query": "magnet:?xt=urn:btih:6e8537c9160e80042f0bc5a880ea8bf9144683ff&dn=archlinux-2023.06.01-x86_64.iso"}'

You can also send the query as application/x-www-form-urlencoded or as multipart/form-data (so you don't have to think about your JSON's format):

# `httpie`
http --form POST :3000 query='magnet:?xt=urn:btih:6e8537c9160e80042f0bc5a880ea8bf9144683ff&dn=archlinux-2023.06.01-x86_64.iso'

# OR curl
curl -X POST "https://localhost:3000"
   -H "Content-Type: application/x-www-form-urlencoded"
   -d 'query=magnet:?xt=urn:btih:6e8537c9160e80042f0bc5a880ea8bf9144683ff&dn=archlinux-2023.06.01-x86_64.iso'

Querying with .torrent file:

# `httpie`
http --multipart POST :3000 torrent_file@'/path/to/file.torrent'

# OR curl
curl -X POST "http://localhost:3000" -F torrent_file=@'/path/to/file.torrent'

After successfully querying, it'll send a Response.

{
  "data": {
    "announce": [],
    "files": [
      {
        "name": "archlinux-2023.06.01-x86_64.iso",
        "path": "archlinux-2023.06.01-x86_64.iso",
        "size": 828715008
      }
    ],
    "infoHash": "6e8537c9160e80042f0bc5a880ea8bf9144683ff",
    "magnetURI": "magnet:?xt=urn:btih:6e8537c9160e80042f0bc5a880ea8bf9144683ff&dn=archlinux-2023.06.01-x86_64.iso",
    "name": "archlinux-2023.06.01-x86_64.iso",
    "peers": 28,
    "seeds": 69
  }
}

If there is an error it'll respond with an error field that has the error message and the query for which the request has failed (if a file was sent then the query field contains the filename), for example:

{
    "error": "Invalid info hash, magnet URI or .torrent file.",
    "query": "magnet:?xt=urn:this-is-an-invalid-magnet-link"
}

Endpoints

Public API Endpoint: https://torrentmeta.fly.dev

Endpoint Method Notes
/ GET Redirects to process.env.SITE_URL if present, else returns { status: "ok" }.
/ping GET To check if the server is properly responding. Returns { pong: <response time in ms> }
/ POST Takes a query parameter that should either contain a magnet URI or torrent info hash. If no query, also takes a torrent_file parameter that should be a properly form encoded .torrent file.

Response

Success:

type TorrentResponse = {
  data?: {
    name?: string;
    infoHash?: string;
    magnetURI?: string;
    peers?: number;
    seeds?: number;
    created?: string;
    createdBy?: string;
    comment?: string;
    announce?: string[];
    trackers_info?: (
      | {
          tracker: string;
          seeds: number;
          peers: number;
          downloads: number;
          response_time: number;
        }
      | { tracker: string; error: string }
    )[];
    files?: Array<{
      name: string;
      size: number;
      path: string;
    }>;
  };
};

Error:

type ErrorResponse = {
  error: string;
  query: string;
};

Client

# clone the repo
git clone https://github.com/schardev/torrent-metadata

# install dependencies
cd torrent-metadata/client; pnpm install

pnpm dev

Make sure to properly set API_URL before launching the front-end.

Stack

  • Express
  • Next.js
  • Tailwind CSS

torrent-metadata's People

Contributors

renovate[bot] avatar schardev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

torrent-metadata's Issues

Show total size

Hi, this is a great project!

I would love to be able to see the total size of a torrent for torrents that have a ton of files like the Grok model: 5f96d43576e3d386c9ba65b883210a393b68210e

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • prettier ^3.1.0
  • pnpm 9.6.0
packages/client/package.json
  • clsx ^2.0.0
  • filesize ^10.1.0
  • next ^14.0.4
  • react ^18.2.0
  • react-dom ^18.2.0
  • tailwind-variants ^0.2.0
  • @types/node ^20.10.3
  • @types/react ^18.2.47
  • @types/react-dom ^18.2.18
  • autoprefixer ^10.4.16
  • eslint ^8.56.0
  • eslint-config-next ^14.0.4
  • eslint-config-prettier ^9.1.0
  • iconoir-react ^7.1.0
  • postcss ^8.4.33
  • tailwindcss ^3.4.1
  • typescript ^5.3.3
packages/server/package.json
  • cors ^2.8.5
  • debug ^4.3.4
  • express ^4.18.2
  • multer 1.4.5-lts.1
  • parse-torrent ^11.0.14
  • webtorrent ^2.1.30
  • webtorrent-health ^1.2.0
  • @flydotio/dockerfile ^0.5.0
  • @types/cors ^2.8.17
  • @types/debug ^4.1.12
  • @types/express ^4.17.21
  • @types/multer ^1.4.11
  • @types/node ^20.10.3
  • @types/webtorrent ^0.109.7
  • tsx ^4.6.2
  • typescript ^5.3.2

  • Check this box to trigger a request for Renovate to run again on this repository

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.