Skip to content

Instantly share code, notes, and snippets.

@benhutchins
Created June 11, 2010 03:50
Show Gist options
  • Save benhutchins/434019 to your computer and use it in GitHub Desktop.
Save benhutchins/434019 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# Rapidshare Downloader
#
# I needed a way to download shit in Linux,
# This will download the links you provide
# one at a time but at least do it.
#
# @author Benjamin Hutchins
# @project Lead Bulb Download Manager
#
# Copyright 2010 Benjamin Hutchins
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
import os
import urlparse
def download( url ):
os.system( "wget %s %s" % ( args, url ) )
def main( args ):
if len(args) == 1:
print >>sys.stderr, "Well, I am sorry. You need to pass a file so we can open it. The file needs to have a URL per-line for the files you want to download."
return 1
urls = []
# Open the file of links
DIR_PATH = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
filename = os.path.join( DIR_PATH, args[1] )
f = open(filename, 'r')
# Go through lines of File, generate URL array
# We separate this because later I want URLs to load from database file too
for line in f.readlines():
urls.append( line.strip() )
# Go through urls to download, download them
for url in urls:
if download(url) is False:
print "Failed to download: %s" % url
if __name__ == '__main__':
sys.exit(main(sys.argv))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment