├── .gitignore ├── update.rb ├── config.json ├── CWEBP.rb ├── FFMPEG.rb ├── RIPME.rb ├── uMatrix.rb ├── ReviewHeatmap.rb ├── SingleFile.rb └── NGINX.rb /.gitignore: -------------------------------------------------------------------------------- 1 | packages -------------------------------------------------------------------------------- /update.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # @Author: Sky 3 | # @Date: 2019-03-26 18:49:06 4 | # @Last Modified by: Sky 5 | # @Last Modified time: 2019-07-24 12:40:38 6 | 7 | require_relative("ffmpeg") 8 | # require_relative("nginx") 9 | # require_relative("UMATRIX") 10 | require_relative("RIPME") 11 | # require_relative("SingleFile") 12 | # require_relative("ReviewHeatmap") 13 | 14 | for package_downloader in [FFMPEG]#, NGINX, UMATRIX, RIPME, ReviewHeatmap] 15 | $log.debug("#{package_downloader} downloader initialize") 16 | downloader = package_downloader.new 17 | downloader.update 18 | end 19 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "FFMPEG": 3 | { 4 | "host": "https://ffmpeg.zeranoe.com", 5 | "path": "/builds/win64/static/", 6 | "output": "A:\\Utilities" 7 | }, 8 | "CWEBP": 9 | { 10 | "host": "https://storage.googleapis.com", 11 | "path": "/downloads.webmproject.org/releases/webp/index.html", 12 | "output": "A:\\Utilities" 13 | }, 14 | "NGINX": 15 | { 16 | "host": "https://nginx.org", 17 | "path": "/download/", 18 | "output": "D:\\Server\\nginx", 19 | "extract_exclude": "-xr!*.conf -xr!*.types -xr!*.html", 20 | "command_before": "taskkill /f /im nginx.exe", 21 | "command_after": "D:\\Server\\nginx\\nginx.exe" 22 | }, 23 | "UMATRIX": 24 | { 25 | "host": "https://github.com", 26 | "path": "/gorhill/uMatrix/releases", 27 | "output": "D:\\Projects\\uBlockOrigin\\uMatrix" 28 | }, 29 | "ReviewHeatmap": 30 | { 31 | "host": "https://github.com", 32 | "path": "/glutanimate/review-heatmap/releases", 33 | "output": "A:\\Anki\\Default\\addons21\\review_heatmap" 34 | }, 35 | "SingleFile": 36 | { 37 | "host": "https://github.com", 38 | "path": "/gildas-lormeau/SingleFile", 39 | "output": "D:\\Projects\\SingleFile-master" 40 | }, 41 | "RIPME": 42 | { 43 | "host": "https://github.com", 44 | "path": "/ripmeapp/ripme/releases", 45 | "output": "A:\\Utilities\\bin\\ripme.jar" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /CWEBP.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # @Author: Sky 3 | # @Date: 2019-03-26 18:48:29 4 | # @Last Modified by: Sky 5 | # @Last Modified time: 2019-07-18 10:30:21 6 | 7 | require "json" 8 | require 'net/http' 9 | require 'net/https' 10 | require 'open-uri' 11 | require 'uri' 12 | require 'thread' 13 | require 'colorize' 14 | require 'logger' 15 | require 'openssl' 16 | require 'nokogiri' 17 | 18 | $log = Logger.new(STDOUT) 19 | 20 | class CWEBP 21 | def initialize 22 | @name = "CWEBP" 23 | @config = JSON.parse(File.read("config.json"))["CWEBP"] 24 | end 25 | 26 | def fetch(path) 27 | $log.debug "PAGE_DOWNLOAD page #{path}" 28 | uri = URI.parse(@config["host"]) 29 | http = Net::HTTP.new(uri.host, uri.port) 30 | http.use_ssl = true 31 | request = Net::HTTP::Get.new(path) 32 | request["referer"] = uri.to_s 33 | response = http.request(request) 34 | response.body 35 | end 36 | 37 | def update_page 38 | return Nokogiri::HTML.parse(fetch(@config["path"])) 39 | end 40 | 41 | def get_package_url 42 | page = update_page.css("a").select{ 43 | |a| 44 | /libwebp\-\d+\.\d+\.\d+\-windows-x64\.zip$/ === a.text.strip 45 | } 46 | 47 | "https:" + page.last["href"] 48 | end 49 | 50 | def download(url, save) 51 | system("wget -c \"#{url}\" -O \"#{save}\"") 52 | end 53 | 54 | def extract(path, filename) 55 | command = [ 56 | "7z", "x", "\"#{path}\"", "-o\".\"", "-aoa" 57 | ].join(" ") 58 | p command 59 | system(command) 60 | system("robocopy \"#{filename.gsub(".zip", "")}\" \"#{@config["output"]}\" /MOVE /E") 61 | end 62 | 63 | def update 64 | url = get_package_url 65 | filename = url.split("/").last 66 | save = "packages/#{filename}" 67 | return "#{@name} is upto-date" if File.exist?(save) 68 | download(url, save) 69 | extract(save, filename) 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /FFMPEG.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # @Author: Sky 3 | # @Date: 2019-03-26 18:48:29 4 | # @Last Modified by: Sky 5 | # @Last Modified time: 2019-06-13 13:12:56 6 | 7 | require "json" 8 | require 'net/http' 9 | require 'net/https' 10 | require 'open-uri' 11 | require 'uri' 12 | require 'thread' 13 | require 'colorize' 14 | require 'logger' 15 | require 'openssl' 16 | require 'nokogiri' 17 | 18 | $log = Logger.new(STDOUT) 19 | 20 | class FFMPEG 21 | def initialize 22 | @name = "FFMPEG" 23 | @config = JSON.parse(File.read("config.json"))["FFMPEG"] 24 | end 25 | 26 | def fetch(path) 27 | $log.debug "PAGE_DOWNLOAD page #{path}" 28 | uri = URI.parse(@config["host"]) 29 | http = Net::HTTP.new(uri.host, uri.port) 30 | http.use_ssl = true 31 | request = Net::HTTP::Get.new(path) 32 | request["referer"] = uri.to_s 33 | response = http.request(request) 34 | response.body 35 | end 36 | 37 | def update_page 38 | return Nokogiri::HTML.parse(fetch(@config["path"])) 39 | end 40 | 41 | def get_package_url 42 | page = update_page.css("tbody a").select{ 43 | |a| 44 | a.text.include? "2019" 45 | } 46 | [@config["host"], @config["path"], page.last["href"]].join("") 47 | end 48 | 49 | def download(url, save) 50 | system("wget -c \"#{url}\" -O \"#{save}\"") 51 | end 52 | 53 | def extract(path, filename) 54 | command = [ 55 | "7z", "x", "\"#{path}\"", "-o\".\"", "-aoa" 56 | ].join(" ") 57 | p command 58 | system(command) 59 | system("robocopy \"#{filename.gsub(".zip", "")}\" \"#{@config["output"]}\" /MOVE /E") 60 | end 61 | 62 | def update 63 | url = get_package_url 64 | filename = url.split("/").last 65 | save = "packages/#{filename}" 66 | return "#{@name} is upto-date" if File.exist?(save) 67 | download(url, save) 68 | extract(save, filename) 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /RIPME.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # @Author: Sky 3 | # @Date: 2019-03-26 18:48:29 4 | # @Last Modified by: Sky 5 | # @Last Modified time: 2019-07-17 09:30:03 6 | 7 | require "json" 8 | require 'net/http' 9 | require 'net/https' 10 | require 'open-uri' 11 | require 'uri' 12 | require 'thread' 13 | require 'colorize' 14 | require 'logger' 15 | require 'openssl' 16 | require 'nokogiri' 17 | 18 | $log = Logger.new(STDOUT) 19 | 20 | class RIPME 21 | def initialize 22 | @name = "RIPME" 23 | @config = JSON.parse(File.read("config.json"))["RIPME"] 24 | end 25 | 26 | def fetch(path) 27 | $log.debug "PAGE_DOWNLOAD page #{path}" 28 | uri = URI.parse(@config["host"]) 29 | http = Net::HTTP.new(uri.host, uri.port) 30 | http.use_ssl = true 31 | request = Net::HTTP::Get.new(path) 32 | request["referer"] = uri.to_s 33 | response = http.request(request) 34 | response.body 35 | end 36 | 37 | def update_page 38 | return Nokogiri::HTML.parse(fetch(@config["path"])) 39 | end 40 | 41 | def get_package_url 42 | package = update_page.at(".repository-content .release-entry .release details .Box a") 43 | 44 | {"version" => package["href"].split("/")[-2], "url" => @config["host"] + package["href"]} 45 | end 46 | 47 | def download(url, save) 48 | system("wget -c \"#{url}\" -O \"#{save}\"") 49 | end 50 | 51 | def extract(path, output) 52 | command = [ 53 | "copy", "\"#{path.gsub("/", "\\")}\"", "\"#{output.gsub("/", "\\")}\"", "/Y" 54 | ].join(" ") 55 | 56 | $log.info "copying to #{output}" 57 | puts command 58 | system(command) 59 | end 60 | 61 | def update 62 | package = get_package_url 63 | version = package["version"] 64 | filename = package["url"].split("/").last 65 | save = "packages/#{version}-#{filename}" 66 | # return "#{@name} is upto-date" if File.exist?(save) 67 | download(package["url"], save) 68 | extract(save, @config["output"]) 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /uMatrix.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # @Author: Sky 3 | # @Date: 2019-03-26 18:48:29 4 | # @Last Modified by: Sky 5 | # @Last Modified time: 2019-06-28 19:41:38 6 | 7 | require "json" 8 | require 'net/http' 9 | require 'net/https' 10 | require 'open-uri' 11 | require 'uri' 12 | require 'thread' 13 | require 'colorize' 14 | require 'logger' 15 | require 'openssl' 16 | require 'nokogiri' 17 | 18 | $log = Logger.new(STDOUT) 19 | 20 | class UMATRIX 21 | def initialize 22 | @name = "UMATRIX" 23 | @config = JSON.parse(File.read("config.json"))["UMATRIX"] 24 | end 25 | 26 | def fetch(path) 27 | $log.debug "PAGE_DOWNLOAD page #{path}" 28 | uri = URI.parse(@config["host"]) 29 | http = Net::HTTP.new(uri.host, uri.port) 30 | http.use_ssl = true 31 | request = Net::HTTP::Get.new(path) 32 | request["referer"] = uri.to_s 33 | response = http.request(request) 34 | response.body 35 | end 36 | 37 | def update_page 38 | return Nokogiri::HTML.parse(fetch(@config["path"])) 39 | end 40 | 41 | def get_package_url 42 | package = update_page.at(".repository-content .release-entry .release details .Box a") 43 | 44 | {"version" => package["href"].split("/")[-2], "url" => @config["host"] + package["href"]} 45 | end 46 | 47 | def download(url, save) 48 | system("wget -c \"#{url}\" -O \"#{save}\"") 49 | end 50 | 51 | def extract(path, filename) 52 | command = [ 53 | "7z", "x", "\"#{path}\"", "-o\".\"", "-aoa" 54 | ].join(" ") 55 | 56 | $log.info "extracting #{path}" 57 | p command 58 | system(command) 59 | 60 | $log.info "installating files to #{@config["output"]}" 61 | system("robocopy \"#{filename.gsub(".zip", "")}\" \"#{@config["output"]}\" /MOVE /E") 62 | end 63 | 64 | def update 65 | package = get_package_url 66 | version = package["version"] 67 | filename = package["url"].split("/").last 68 | save = "packages/#{version}-#{filename}" 69 | return "#{@name} is upto-date" if File.exist?(save) 70 | download(package["url"], save) 71 | extract(save, filename) 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /ReviewHeatmap.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # @Author: Sky 3 | # @Date: 2019-03-26 18:48:29 4 | # @Last Modified by: Sky 5 | # @Last Modified time: 2019-07-24 12:43:20 6 | 7 | require "json" 8 | require 'net/http' 9 | require 'net/https' 10 | require 'open-uri' 11 | require 'uri' 12 | require 'thread' 13 | require 'colorize' 14 | require 'logger' 15 | require 'openssl' 16 | require 'nokogiri' 17 | 18 | $log = Logger.new(STDOUT) 19 | 20 | class ReviewHeatmap 21 | def initialize 22 | @name = "ReviewHeatmap" 23 | @config = JSON.parse(File.read("config.json"))["ReviewHeatmap"] 24 | end 25 | 26 | def fetch(path) 27 | $log.debug "PAGE_DOWNLOAD page #{path}" 28 | uri = URI.parse(@config["host"]) 29 | http = Net::HTTP.new(uri.host, uri.port) 30 | http.use_ssl = true 31 | request = Net::HTTP::Get.new(path) 32 | request["referer"] = uri.to_s 33 | response = http.request(request) 34 | response.body 35 | end 36 | 37 | def update_page 38 | return Nokogiri::HTML.parse(fetch(@config["path"])) 39 | end 40 | 41 | def get_package_url 42 | package = update_page.css(".repository-content .release-entry .release details .Box a")[1] 43 | 44 | {"version" => package["href"].split("/")[-2], "url" => @config["host"] + package["href"]} 45 | end 46 | 47 | def download(url, save) 48 | system("wget -c \"#{url}\" -O \"#{save}\"") 49 | end 50 | 51 | def extract(path, filename) 52 | command = [ 53 | "7z", "x", "\"#{path}\"", "-o\"review_heatmap\"", "-aoa" 54 | ].join(" ") 55 | 56 | $log.info "extracting #{path}" 57 | p command 58 | system(command) 59 | 60 | $log.info "installating files to #{@config["output"]}" 61 | system("robocopy \"review_heatmap\" \"#{@config["output"]}\" /MOVE /E") 62 | end 63 | 64 | def update 65 | package = get_package_url 66 | version = package["version"] 67 | filename = package["url"].split("/").last 68 | save = "packages/#{filename}" 69 | return "#{@name} is upto-date" if File.exist?(save) 70 | download(package["url"], save) 71 | extract(save, filename) 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /SingleFile.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # @Author: Sky 3 | # @Date: 2019-03-26 18:48:29 4 | # @Last Modified by: Sky 5 | # @Last Modified time: 2019-07-17 09:32:41 6 | 7 | require "json" 8 | require 'net/http' 9 | require 'net/https' 10 | require 'open-uri' 11 | require 'uri' 12 | require 'thread' 13 | require 'colorize' 14 | require 'logger' 15 | require 'openssl' 16 | require 'nokogiri' 17 | 18 | $log = Logger.new(STDOUT) 19 | 20 | class SingleFile 21 | def initialize 22 | @name = "SingleFile" 23 | @config = JSON.parse(File.read("config.json"))["SingleFile"] 24 | end 25 | 26 | def fetch(path) 27 | $log.debug "PAGE_DOWNLOAD page #{path}" 28 | uri = URI.parse(@config["host"]) 29 | http = Net::HTTP.new(uri.host, uri.port) 30 | http.use_ssl = true 31 | request = Net::HTTP::Get.new(path) 32 | request["referer"] = uri.to_s 33 | response = http.request(request) 34 | response.body 35 | end 36 | 37 | def update_page 38 | return Nokogiri::HTML.parse(fetch(@config["path"])) 39 | end 40 | 41 | def get_package_url 42 | return {"version" => Time.now.to_i, "url" => "https://github.com/gildas-lormeau/SingleFile/archive/master.zip"} 43 | 44 | package = update_page.at(".repository-content .release-entry .release details .Box a") 45 | 46 | {"version" => package["href"].split("/")[-2], "url" => @config["host"] + package["href"]} 47 | end 48 | 49 | def download(url, save) 50 | system("wget -c \"#{url}\" -O \"#{save}\"") 51 | end 52 | 53 | def extract(path, filename) 54 | command = [ 55 | "7z", "x", "\"#{path}\"", "-o\".\"", "-aoa" 56 | ].join(" ") 57 | 58 | $log.info "extracting #{path}" 59 | p command 60 | system(command) 61 | 62 | $log.info "installating files to #{@config["output"]}" 63 | system("robocopy \"SingleFile-master\" \"#{@config["output"]}\" /MOVE /E") 64 | end 65 | 66 | def update 67 | package = get_package_url 68 | version = package["version"] 69 | filename = package["url"].split("/").last 70 | save = "packages/#{@name}_#{version}-#{filename}" 71 | return "#{@name} is upto-date" if File.exist?(save) 72 | download(package["url"], save) 73 | extract(save, filename) 74 | end 75 | end 76 | -------------------------------------------------------------------------------- /NGINX.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # @Author: Sky 3 | # @Date: 2019-03-26 18:48:29 4 | # @Last Modified by: Sky 5 | # @Last Modified time: 2019-06-20 17:30:01 6 | 7 | require "json" 8 | require 'net/http' 9 | require 'net/https' 10 | require 'open-uri' 11 | require 'uri' 12 | require 'thread' 13 | require 'colorize' 14 | require 'logger' 15 | require 'openssl' 16 | require 'nokogiri' 17 | 18 | $log = Logger.new(STDOUT) 19 | 20 | class NGINX 21 | def initialize 22 | @name = "NGINX" 23 | @config = JSON.parse(File.read("config.json"))["NGINX"] 24 | end 25 | 26 | def fetch(path) 27 | $log.debug "PAGE_DOWNLOAD page #{path}" 28 | uri = URI.parse(@config["host"]) 29 | http = Net::HTTP.new(uri.host, uri.port) 30 | http.use_ssl = true 31 | request = Net::HTTP::Get.new(path) 32 | request["referer"] = uri.to_s 33 | response = http.request(request) 34 | response.body 35 | end 36 | 37 | def update_page 38 | return Nokogiri::HTML.parse(fetch(@config["path"])) 39 | end 40 | 41 | def get_package_url 42 | packages = update_page.css("a").map{ 43 | |a| 44 | a.text 45 | }.select{ 46 | |a| 47 | a.include?("nginx-") && a.include?(".zip") 48 | }.sort_by { 49 | |v| Gem::Version.new(v.split("-").last.split(".zip").first) 50 | } 51 | [@config["host"], @config["path"], packages.last].join("") 52 | end 53 | 54 | def download(url, save) 55 | system("wget -c \"#{url}\" -O \"#{save}\"") 56 | end 57 | 58 | def extract(path, filename) 59 | command = [ 60 | "7z", "x", "\"#{path}\"", "-o\".\"", "-aoa", "#{@config["extract_exclude"]}" 61 | ].join(" ") 62 | 63 | 64 | $log.info "extracting #{path}" 65 | p command 66 | system(command) 67 | 68 | $log.info "executing command before installation #{@config["command_before"]}" 69 | system(@config["command_before"]) 70 | 71 | $log.info "waiting for the process to shutdown" 72 | sleep 3 73 | 74 | $log.info "installating files to #{@config["output"]}" 75 | system("robocopy \"#{filename.gsub(".zip", "")}\" \"#{@config["output"]}\" /MOVE /E") 76 | 77 | $log.info "executing command after installation #{@config["command_after"]}" 78 | system(@config["command_after"]) 79 | end 80 | 81 | def update 82 | url = get_package_url 83 | filename = url.split("/").last 84 | save = "packages/#{filename}" 85 | return "#{@name} is upto-date" if File.exist?(save) 86 | download(url, save) 87 | extract(save, filename) 88 | end 89 | end 90 | --------------------------------------------------------------------------------