Example #1
0
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)
Example #2
0
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)
Example #3
0
    def game_file_url(self, game):
        parent = "http://www.abandonia.com/en/downloadgame/" + str(
            game.id) + "/index.html"

        # old
        # parser = WebParser.WebParser(parent, cached=False)
        # game_file_url =
        # parser.getFirstLink(".*files.abandonia.com/download.*")

        # example:
        #        function go_to_downloadGame()
        #        {
        #            window.open("http://files.abandonia.com/download.php?game=Return+to+Ringworld&secure=52f031ad8496c642cbbac42baf293a1c&td=1347598121");
        #        }

        fname = Downloader(cached=False).download(parent, config.CACHE)
        page = open(fname).read()
        s = page.split('go_to_downloadGame')[1]
        game_file_url = s.split('"')[1]
        return game_file_url
Example #4
0
 def loadPage(self, cached):
     downloader = Downloader(cached)
     targetDir = config.CACHE
     self.page = downloader.download(self.url, targetDir)
Example #5
0
 def loadPage(self, cached):
     downloader = Downloader(cached)
     targetDir = config.CACHE
     self.page = downloader.download(self.url, targetDir)