DEV Community

Anim Mouse
Anim Mouse

Posted on

Convert direct download links into Torrent using GitHub Actions

My Workflow

Back in the day, we have BurnBit that allows us to leverage the P2P power of BitTorrent for our files hosted on our web servers. BurnBit downloads the file in their servers and creates a .torrent metadata of the file and adds your web server as an HTTP webseed for that torrent. This works flawlessly, your file is getting downloaded from your server and at the same time, with other peers already downloaded the file through seeding. This saves bandwidth on your web server, costing you less, and improves the download experience of your users if your web server can't handle the load.

Fast-forward today, BurnBit got down, and there are no alternatives until URLHash, but URLHash has limits, and sometimes goes down.

This GitHub Action workflow allows you to create .torrent file from a direct HTTP link of your web sever and uses that link for webseeding.

This will download the file from your HTTP link and hash it using a torrent creator program using GitHub Actions.

Submission Category:

Wacky Wildcards

Yaml File or Link to Code



name: torrenttools
on:
  workflow_dispatch:
    inputs:
      name:
        description: Name of the torrent file
        required: true
        default: Firefox Setup 94.0.2
      comment:
        description: Comment
        required: true
        default: Firefox Setup 94.0.2 win64 en-US by torrent-webseed-creator
      url:
        description: URL of the file
        required: true
        default: 'https://download-installer.cdn.mozilla.net/pub/firefox/releases/94.0.2/win64/en-US/Firefox%20Setup%2094.0.2.exe'
      file_name:
        description: File name of the file in the torrent
        required: true
        default: Firefox Setup 94.0.2.exe
      piece_size:
        description: Piece Size. Use auto for automatic calculation, or use the recommended piece size on the README.md file
        required: true
        default: auto
      protocol_version:
        description: BitTorrent Protocol version 1, 2, or hybrid
        required: true
        default: '1'
      maximize_disk_space:
        description: Maximize disk space. Set to true if getting out of disk space error
        default: 'false'

jobs:
  create_torrent:
    runs-on: ubuntu-latest
    steps:
      - name: Maximize disk space
        if: ${{ github.event.inputs.maximize_disk_space == 'true' }}
        uses: easimon/maximize-build-space@v4
        with:
          remove-dotnet: 'true'
          remove-android: 'true'
          remove-haskell: 'true'

      - name: Install torrenttools
        run: |
          sudo add-apt-repository ppa:fbdtemme/torrenttools
          sudo apt-get update
          sudo apt-get install torrenttools

      - name: Download file
        run: aria2c -x 16 -o "${{ github.event.inputs.file_name }}" "${{ github.event.inputs.url }}"

      - name: Create torrent using torrenttools
        run: torrenttools create -v "${{ github.event.inputs.protocol_version }}" -o "${{ github.event.inputs.name }}.torrent" -w "${{ github.event.inputs.url }}" -c "${{ github.event.inputs.comment }}" -l "${{ github.event.inputs.piece_size }}" -s "torrent-webseed-creator" "${{ github.event.inputs.file_name }}"

      - name: Upload torrent file
        uses: actions/upload-artifact@v2
        with:
          name: ${{ github.event.inputs.name }}
          path: ${{ github.event.inputs.name }}.torrent


Enter fullscreen mode Exit fullscreen mode

GitHub logo AnimMouse / torrent-webseed-creator

Webseeded torrent creator using GitHub Actions

Torrent Webseed Creator

Webseeded Torrent Creator using GitHub Actions.

Inspired by BurnBit † and URLHash.

Powered by these programs to create a torrent file.

An alternative to BurnBit and URLHash.

Convert direct HTTP link to .torrent

Your file is then burned into a torrent.

Torrents created are trackerless, relying on Distributed Hash Table and Peer EXchange, to help reduce the burden of torrent trackers.

For people that have unstable internet.
Can be paused because it is a torrent.
Utilizes the power of peer to peer downloads and the client-server downloads.
Combines the best of both worlds (P2P and Direct HTTP Link).

How to use

  1. Create a repository on GitHub using this template by clicking "Use this template" and then click "Create a new repository".
  2. Go to the Actions tab.
  3. Choose a program to use by clicking the name of the program under "All workflows"…

Additional Resources / Info

GitHub logo fbdtemme / torrenttools

Commandline tool for inspecting, creating and editing BitTorrent metafiles.

build Copr build status GitHub release (latest SemVer) C++ standard Codacy Badge License: MIT

A commandline tool for creating, inspecting and modifying bittorrent metafiles.

Features | Documentation | Binary releases | Building | License

Features

  • Creating bittorrent metafiles.
  • Inspecting bittorrent metafiles.
  • Verifying bittorrent metafiles against local data.
  • Editing existing bittorrent metafiles.
  • Support for the new v2 and hybrid protocols .
  • Support for tracker abbreviations.
  • Support for announce substitution parameters.
  • Fast multi-buffer hashing with Intel ISA-L.

Example

Status

This project is under development. The commandline interface can change at any release prior to 1.0.0.

Performance

Following test were performed on a in in-memory filesystem with 1 MiB piece size and as target a file filed with random data totalling 15.0 GiB: The tested CPU is an Intel i7-7700HQ in a Dell XPS 15-9560 machine.

Benchmark

Documentation

Documentation is hosted on Github Pages.

Binary releases

Contents

Windows

An .msi installer…

Burnbit Turns Any Web-Hosted File into a Torrent Article
Burn Any Web-Hosted File into a Torrent With Burnbit Article

Top comments (0)