Files
kde-linux/torrent-create.rb
Harald Sitter 75bc73d176 create torrent from raw basename
the file on the servers we want is the raw not the output (that's the
name without the .raw suffix)
2024-11-06 16:27:02 +01:00

46 lines
1.4 KiB
Ruby
Executable File

#!/usr/bin/env ruby
# frozen_string_literal: true
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
# SPDX-FileCopyrightText: 2024 Harald Sitter <sitter@kde.org>
require 'json'
require 'nokogiri'
require 'open-uri'
def mirror_list
data = URI.open('https://files.kde.org/last-updated.mirrorlist',
"User-Agent" => "KDELinux/mirror-list.rb #{RUBY_VERSION}",
"Accept" => "text/html"
).read
urls = Nokogiri::HTML(data).xpath('//a/@href').map(&:value)
urls = urls.reject { |url| url.include?('last-updated') || url == '/' || !url.end_with?('/') }
raise if urls.empty?
urls
end
VERSION = ARGV.fetch(0)
OUTPUT = ARGV.fetch(1)
RAW = ARGV.fetch(2)
base_args = %w[transmission-create
--tracker udp://tracker.opentrackr.org:1337/announce
--tracker udp://open.demonii.com:1337/announce
--tracker udp://open.tracker.cl:1337/announce
--tracker udp://open.stealth.si:80/announce
--tracker udp://tracker.torrent.eu.org:451/announce
--tracker udp://tracker-udp.gbitt.info:80/announce
--tracker udp://opentracker.io:6969/announce
--tracker udp://explodie.org:6969/announce]
webseed_args = mirror_list.map do |url|
["--webseed", "#{url}kde-linux/#{File.basename(RAW)}"]
end.flatten
args = base_args + webseed_args
args += ['--comment', "KDE Linux #{VERSION}", "--outfile", "#{OUTPUT}.torrent", RAW]
system(*args) || raise