def download_game(game, nocache=False): targetDir = config.GameArchives / game.source src_plugin = GameSource(game.source) downloadOptions = {} if hasattr(src_plugin, 'download_options'): downloadOptions = src_plugin.download_options(game) if hasattr(src_plugin, 'game_file_url'): log.debug( 'game_file_url is not static, calling plugin:%s' % src_plugin) gameUrl = src_plugin.game_file_url(game) else: gameUrl = game.game_file_url assert gameUrl downloader = Downloader(cached=not nocache) print 'downloading %s...' % game.name, sys.stdout.flush() game.zip = downloader.download(gameUrl, targetDir, **downloadOptions) print 'OK' # downloader = DownloaderFactory.createDownloader(not nocache) # def game_downloader(game, targetDir, downloader): # gameUrl = game.game_file_url # game.zip = downloader.downloadFile(gameUrl, targetDir, # downloadOptions=downloadOptions) # if src_plugin.game_downloader: # game_downloader = src_plugin.game_downloader # game_downloader(game, targetDir, downloader) db.save_game(game)
def download_game(game, nocache=False): targetDir = config.GameArchives / game.source src_plugin = GameSource(game.source) downloadOptions = {} if hasattr(src_plugin, 'download_options'): downloadOptions = src_plugin.download_options(game) if hasattr(src_plugin, 'game_file_url'): log.debug('game_file_url is not static, calling plugin:%s' % src_plugin) gameUrl = src_plugin.game_file_url(game) else: gameUrl = game.game_file_url assert gameUrl downloader = Downloader(cached=not nocache) print 'downloading %s...' % game.name, sys.stdout.flush() game.zip = downloader.download(gameUrl, targetDir, **downloadOptions) print 'OK' # downloader = DownloaderFactory.createDownloader(not nocache) # def game_downloader(game, targetDir, downloader): # gameUrl = game.game_file_url # game.zip = downloader.downloadFile(gameUrl, targetDir, # downloadOptions=downloadOptions) # if src_plugin.game_downloader: # game_downloader = src_plugin.game_downloader # game_downloader(game, targetDir, downloader) db.save_game(game)
def loadPage(self, cached): downloader = Downloader(cached) targetDir = config.CACHE self.page = downloader.download(self.url, targetDir)