vankasteelj / frak

A frakingly good multimedia center
GNU General Public License v3.0
22 stars 4 forks source link

replace Got with Axios #189

Open vankasteelj opened 1 year ago

vankasteelj commented 1 year ago

In gulpfile to download mpv:

  return Promise.all(parsePlatforms().map((platform) => {
    // bundled mpv is for win only
    if (platform.match(/osx|linux/) !== null) {
      console.log('No `mpv` task for', platform)
      return null
    }

    return new Promise((resolve, reject) => {
      console.log('downloading mpv...')
      axios({
        url: pkJson.mpv.url,
        responseType: 'stream'
      }).then(response => {
        const stream = response.data
        stream.pipe(fs.createWriteStream(path.join(temp, 'mpv.7z')))
        stream.on('end', resolve)
      })
    }).then(() => {
      console.log('mpv downloaded, extracting...')
      return Z7.extractFull(path.join(temp, 'mpv.7z'), 'mpv')
    }).then(() => {
      console.log('mpv extracted')
      console.log('downloading youtube-dl...')
      return new Promise((resolve, reject) => {
        axios({
          url: pkJson.mpv['youtube-dl'],
          responseType: 'stream'
        }).then(response => {
          const stream = response.data
          stream.pipe(fs.createWriteStream('mpv/youtube-dl.exe'))
          stream.on('end', resolve)
        })
      })
    }).then(() => {
      console.log('all done.')
    })
  }))

in modules with cheerio:

axios.get(reqUrl, { timeout: 3500, responseType: 'text' }).then(res => {
    const $page = cheerio.load(res.data) ...
vankasteelj commented 1 year ago

The switch should be gradual with every step verifier. I would advise to add "axios" to the require() list then change one occurence in the main code, test it, then go on to the next one. And only remove 'got' when it is no longer used anywhere.