def setUp(self): # create temp output directory, return absolute path self.__downloads_temp_folder__ = tempfile.mkdtemp() print("created ", self.__downloads_temp_folder__, " to store downloads") # create a downloader with default params number_threads = 12 ratelimit_downloads = 60 ratelimit_interval = 1 verbose = False store_into_tar = False progressbar = False self.__downloader__ = Downloader(self.__downloads_temp_folder__, number_threads, ratelimit_downloads, ratelimit_interval, verbose, store_into_tar, progressbar) # test image urls file self.__test_urls_file = "tests/test_image_urls_800.txt" # read list of urls with open(self.__test_urls_file) as f: self.__test_urls_list = [ line.strip().rstrip('\n') for line in f.readlines() if line.strip().rstrip('\n') ] # create list of image context path from urls self.__test_urls_image_context_path_list = list() for url in self.__test_urls_list: # extract the image context path and store in list self.__test_urls_image_context_path_list.append( urlparse(url).path[1:])
def main(args=None): args = parse_parameters() if os.path.isabs(args.image_list_file): image_list_file=args.image_list_file else: image_list_file = os.path.join(os.getcwd(),args.image_list_file) if os.path.isabs(args.download_folder): download_folder = args.download_folder else: download_folder = os.path.join(os.getcwd(),args.download_folder) if not os.path.isfile(image_list_file): print("The given path "+image_list_file+" is not a file. Abort.") sys.exit(1) if (args.command == "download"): downloader=Downloader(download_folder,args.threads,args.ratelimit_downloads,args.ratelimit_interval,args.verbose,args.tarfile,args.progressbar) downloader.download_list(image_list_file) elif (args.command == "status"): downloader=Downloader(download_folder,args.threads,1,1,args.verbose,args.tarfile,args.progressbar) downloader.check_status(image_list_file) else: print("Command not known: "+args.command)
def __download() -> None: """ execute when trigger dl button :return: """ value = clicked.get() if value != '0' or value != 'off': extension = 'mp3' if value == 'audio' else 'mp4' dl = Downloader(extension=extension, resolution=clicked.get(), path=filedialog.askdirectory(), video=video) dl.download() else: messagebox.showinfo('No resolution selected', 'Please select resolution')
def main(): url = '' output_file = 'dummy' nthread = 20 part = 10000000 try: opts, args = getopt.getopt( sys.argv[1:], "hu:o:n:p:", ["url=", "outputfile=", "nthread=", "part="]) except getopt.GetoptError: sys.exit(2) for opt, arg in opts: if opt == '-h': usage() sys.exit(0) elif opt in ('-u', '--url'): url = arg elif opt in ('-o', '--outputfile'): output_file = arg elif opt in ('-n', '--nthread'): try: nthread = int(arg) except ValueError: usage() sys.exit(2) elif opt in ('-p', '--part'): try: part = int(arg) except ValueError: usage() sys.exit(2) if url == '': usage() sys.exit(2) #print "url = %s" % url #print "output file = %s" % output_file #print 'remove below line' #url = 'http://download.fedoraproject.org/pub/fedora/linux/releases/21/Workstation/x86_64/iso/Fedora-Live-Workstation-x86_64-21-5.iso' d = Downloader(url, output_file, nthread, part)