class Gamerom::RepoAdapters::Vimm
Vimm
- An adapter for the Vimm's Lair repository website
Constants
- PLATFORM
Public Class Methods
extract_games(platform) { |map { |game_link| game(game_link) }| ... }
click to toggle source
# File lib/gamerom/repo_adapters/vimm.rb, line 41 def self.extract_games(platform) sections.each_with_index do |section, index| page = nokogiri_get("https://vimm.net/vault/?p=list&system=#{platform}§ion=#{section}") game_links = page.css('table.hovertable td:first-child a:first-child') yield game_links.map { |game_link| game(game_link) }, index end end
game(game_link)
click to toggle source
# File lib/gamerom/repo_adapters/vimm.rb, line 49 def self.game(game_link) { id: game_link['href'].split('/').last.to_i, name: game_link.text, region: 'USA', } end
install(game) { |filenames| ... }
click to toggle source
# File lib/gamerom/repo_adapters/vimm.rb, line 57 def self.install(game) FileUtils.mkdir_p(game.filepath) agent = Mechanize.new agent.pluggable_parser.default = Mechanize::Download agent.user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36' page = agent.get("https://vimm.net/vault/#{game.id}") form = page.form_with(id: 'download_form') filenames = [] game_files = [] multiple_disks = page.css('#download_disc_number') if multiple_disks.empty? game_files << { id: form['mediaId'], name: 'single file rom' } else puts 'multiple discs detected' game_files.concat(multiple_disks.children[1..-2].map { |disk| { name: disk.text, id: disk['value'] } }) end game_files.each do |game_file| puts "downloading #{game_file[:name]}" form.method = 'GET' button = form.button_with(type: 'submit') response = nil form['mediaId'] = game_file[:id] agent.progressbar do response = form.click_button(button) end break unless response.code.to_i == 200 filename = response.filename response.save!("#{game.filepath}/#{filename}") filenames << filename end yield filenames end
platforms()
click to toggle source
# File lib/gamerom/repo_adapters/vimm.rb, line 33 def self.platforms PLATFORM end
sections()
click to toggle source
# File lib/gamerom/repo_adapters/vimm.rb, line 37 def self.sections ('a'..'z').to_a.unshift('number') end