const http = require('http')
const fs = require('fs')

function checkIfPhishing(urlToPrint, path, lang = 'zh') {
  fs.mkdirSync(path, { recursive: true })
  const file = fs.createWriteStream(`${path}/${lang}.json`)
  const request = http.get(urlToPrint, function (response) {
    response
      .on('finish', function () {
        console.log('done')
        // console.log(fs.readFileSync(`${lang}.json`, { encoding: "utf8" }));
      })
      .pipe(file)
  })
}
//  zh
checkIfPhishing(
  'http://192.168.0.163:8080/download/4kankan/eletron_laster_local/zh_Hans/',
  'src/i18n/weblate',
  'zh'
)
//  en
checkIfPhishing(
  'http://192.168.0.163:8080/download/4kankan/eletron_laster_local/en/',
  'src/i18n/weblate',
  'en'
)
//  ja
checkIfPhishing(
  'http://192.168.0.163:8080/download/4kankan/eletron_laster_local/ja/',
  'src/i18n/weblate',
  'ja'
)

//  ja
checkIfPhishing(
  'http://192.168.0.163:8080/download/4kankan/eletron_laster_local/ko/',
  'src/i18n/weblate',
  'kr'
)



//  zh
checkIfPhishing(
  'http://192.168.0.163:8080/download/4kankan/eletron_laster_local/zh_Hans/',
  'program/lang/weblate',
  'zh'
)
//  en
checkIfPhishing(
  'http://192.168.0.163:8080/download/4kankan/eletron_laster_local/en/',
  'program/lang/weblate',
  'en'
)
//  ja
checkIfPhishing(
  'http://192.168.0.163:8080/download/4kankan/eletron_laster_local/ja/',
  'program/lang/weblate',
  'ja'
)
checkIfPhishing(
  'http://192.168.0.163:8080/download/4kankan/eletron_laster_local/ko/',
  'program/lang/weblate',
  'kr'
)