Skip to content

Instantly share code, notes, and snippets.

@vaginessa
Forked from Konstantinusz/1f.rb
Created December 21, 2016 20:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaginessa/15a0a70b4fe064635fc644515102e144 to your computer and use it in GitHub Desktop.
Save vaginessa/15a0a70b4fe064635fc644515102e144 to your computer and use it in GitHub Desktop.
1fichier.com premium download script
#!/usr/bin/ruby
#http://premium-leechers.blogspot.com
require "cgi"
require "clipboard"
if ARGV.size != 3 then
STDERR.puts "premium-leechers.blogspot.com"
STDERR.puts "1fichier premium downloader script."
STDERR.puts "Usage: ruby 1f <email> <password> <txt file with links|1fichier link|'clipboard'>"
exit
end
email=CGI.escape(ARGV[0])
pass=CGI.escape(ARGV[1])
infile=ARGV[2]
dl = (ARGV[3]=="wget" ? "wget" : "curl")
if infile =~ /1fichier/ then
links = infile.split
elsif infile == 'clipboard' then
links = Clipboard.paste.scan(/(https?\:\/\/[a-z0-9]+\.1fichier.com)/i).flatten.uniq
else
links = open(infile,"r") { |f|
f.readlines.map{|z| z.chomp.strip}.grep(/^[^#].*1fichier/)
}
end
STDERR.puts links
if dl=="wget" then
ret=%x{wget -q --save-cookies ~/.1fichier-cookie --post-data "mail=#{email}&pass=#{pass}&lt=on&Login=Login" -O - https://1fichier.com/login.pl 2>&1}
elsif dl=="curl" then
ret=%x{curl -c ~/.1fichier-cookie -d "mail=#{email}&pass=#{pass}&lt=on&Login=Login" https://1fichier.com/login.pl 2>&1}
end
logged_in=ret.scan(/\<br\/\>(You are logged in. This page will redirect you.)/i).flatten[0]
if logged_in == nil then
STDERR.puts "Email / password doesn't match!"
exit
else
STDERR.puts "Logged in."
end
links.each do |l|
if dl=="wget" then
fname_to_save=%x{wget -O - #{l} 2>&1}.scan(/Filename \:\<\/th\>\<td\>(.*?)\<\/td\>\<\/tr\>/).flatten[0]
elsif dl=="curl" then
fname_to_save=%x{curl #{l} 2>&1}.scan(/Filename \:\<\/th\>\<td\>(.*?)\<\/td\>\<\/tr\>/).flatten[0]
end
STDERR.puts "Downloading file #{l}/#{fname_to_save} ..."
if dl=="wget" then
%x{wget -c --progress=bar:force --no-check-certificate --load-cookies ~/.1fichier-cookie -O "#{fname_to_save}" #{l} }
elsif dl=="curl" then
%x{curl -b ~/.1fichier-cookie -"#" -L -k -o \"#{fname_to_save}\" #{l}}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment