forked from KDE/kde-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtorrent-create.rb
More file actions
executable file
·45 lines (35 loc) · 1.35 KB
/
Copy pathtorrent-create.rb
File metadata and controls
executable file
·45 lines (35 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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