protected function getOriginDb(OutputInterface $output, $now)
    {
        $url = $this->getContainer()->getParameter('anime_db.ani_db.import_titles');

        if (($path = parse_url($url, PHP_URL_PATH)) === false) {
            throw new \InvalidArgumentException('Failed parse URL: '.$url);
        }

        /* @var Filesystem $fs */
        $fs = $this->getContainer()->get('filesystem');
        $filename = sys_get_temp_dir().'/'.pathinfo($path, PATHINFO_BASENAME);

        if (!$fs->exists($filename) || filemtime($filename) + self::CACHE_LIFE_TIME < $now) {
            /* @var $downloader \AnimeDb\Bundle\AppBundle\Service\Downloader */
            $downloader = $this->getContainer()->get('anime_db.downloader');
            $tmp = tempnam(sys_get_temp_dir(), 'ani_db_titles');
            if (!$downloader->download($url, $tmp, true)) {
                $fs->remove($tmp);
                throw new \RuntimeException('Failed to download the titles database');
            }
            $fs->rename($tmp, $filename, true);
            $output->writeln('The titles database is loaded');
        }

        return $filename;
    }