Skip to content

Instantly share code, notes, and snippets.

@Madh93
Last active April 9, 2021 07:07
Show Gist options
  • Save Madh93/1301c90c8b785e1a3af1fc10f309bd2e to your computer and use it in GitHub Desktop.
Save Madh93/1301c90c8b785e1a3af1fc10f309bd2e to your computer and use it in GitHub Desktop.
Volafile Downloader
#! /usr/bin/env ruby
# NAME : Volafile Downloader
# DESCRIPTION : Download all files from Volafile room
# AUTHOR : Madh93 (Miguel Hernandez)
# VERSION : 0.0.1
# LICENSE : GNU General Public License v3
# USAGE : ruby volafile.rb
require 'rubygems'
require 'selenium-webdriver'
# Volafile
module Volafile
PATH = '/home/username/volafile' # CHANGE
WEB_DRIVER = :chrome # :firefox, :ie
ROOMS = [ # CHANGE
'https://volafile.io/r/sdfh78df7hdfs',
'https://volafile.io/r/8d7fhsd8f7hsd'
]
def self.find_links(room)
Utils.logger("Opening #{room}...")
driver = Selenium::WebDriver.for Volafile::WEB_DRIVER
driver.manage.timeouts.implicit_wait = 30 # seconds
driver.navigate.to(room)
files = driver.find_elements(class: 'file_left_part').map do |e|
e.attribute('href')
end
driver.quit
Utils.get_links(files)
end
def self.dump
Utils.check_dir("#{PATH}/downloads")
Utils.check_dir("#{PATH}/downloads/#{Date.today}")
path = "#{PATH}/downloads/#{Date.today}/"
Utils.logger("Begin to download files in #{path}")
File.readlines("#{PATH}/links/links_#{Date.today}.txt").each do |link|
if !File.exist?("#{path}#{File.basename(link.strip)}")
begin
Utils.logger("Downloading... #{path}#{File.basename(link.strip)}")
`wget "#{link}" -O "#{path}#{File.basename(link.strip)}"`
Utils.logger("Downloaded #{path}#{File.basename(link.strip)}")
rescue
Utils.logger("Problems downloading #{path}#{File.basename(link.strip)}")
end
end
end
Utils.logger("Terminated downloads in #{path}")
end
end
# Utils
module Utils
def self.check_dir(dir)
Dir.mkdir(dir) unless File.exist?(dir)
end
def self.get_links(links)
Utils.logger('Get links...')
check_dir("#{Volafile::PATH}/links")
File.open("#{Volafile::PATH}/links/links_#{Date.today}.txt", 'w+') do |f|
links.each do |link|
f.puts link
end
end
Utils.logger("Links in #{Volafile::PATH}/links/links_#{Date.today}.txt")
end
def self.logger(text)
File.open("#{Volafile::PATH}/volafile.log", 'a') do |f|
f.puts "#{Time.now}: #{text}"
end
end
end
# Search available links in rooms
Volafile::ROOMS.each do |room|
Volafile.find_links(room)
end
# Download all found files
Volafile.dump

Volafile Downloader

Get all files from volafile rooms.

Requirements

  • Ruby
  • Selenium
How to install Selenium?
  1. Get a compatible browser: sudo apt-get install chromium-browser
  • Get appropiate version of driver: here from chrome
  • Extract and copy file to /usr/bin: sudo mv chromedriver /usr/bin
  • Set execution permissions: sudo chmod +x /usr/bin/chromedriver

Selenium is available for more browers too.

@hunden1212
Copy link

Hi,
First of all, thank you very much for this excellent script!

However, it would seem that it is no longer downloading .rar/.zip files and some video files. Do you have any idea how to get that to work?
I'm running on Windows using windows wget (http://www.gnu.org/software/wget/).
As of right now I have to manually download all rarzips and most video files.

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment