{"version":3,"sources":["jsdelivr-header.js","/npm/subdb-node@0.1.53/lib/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,YAAE,aAAgB,QAAQ,UAC1B,QAAU,QAAQ,WAClB,SAAW,QAAQ,oBACnB,GAAK,QAAQ,MAEb,MAAQ,QAAQ,SAAS,CAC7B,QAAS,CAAC,aAAe,kDACzB,QAAS,4BAGX,OAAO,QAAQ,SAAW,MAAO,IAChC,IACC,MAAM,QAAa,YAAY,GAC/B,OAAO,IAAI,SAAQ,CAAC,EAAS,KAC5B,MAAM,EAAI,MAAM,0BAA0B,KAC1C,EAAE,GAAG,YAAW,SAAS,GACF,MAAnB,EAAI,YACN,EAAE,QACF,EAAQ,OAGR,EAAE,KAAK,GAAG,kBAAkB,EAAS,QAAQ,YAAa,IAAI,QAEhE,IACC,GAAG,SAAS,SAAU,GACnB,EAAO,EACX,IACC,GAAG,OAAO,WACV,GAAQ,EACT,GAAC,GAEH,CAAE,MAAO,GACR,QAAQ,IAAI,EACb","file":"/npm/subdb-node@0.1.53/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.19.2.\n * Original file: /npm/subdb-node@0.1.53/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const { computeHash } = require('./hash') \nconst request = require('request')\nconst progress = require('request-progress')\nconst fs = require('fs')\n\nconst fetch = request.defaults({\t\n  headers: {'User-Agent' : 'SubDB/1.0 (SubDB-node/0.1.0; http://maxeon.me)'},\n  baseUrl: 'http://api.thesubdb.com'\n})\n\nmodule.exports.download = async (filePath) => {\n\ttry{\n\t\tconst hash = await computeHash(filePath) \n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst r = fetch(`/?action=download&hash=${hash}`)\n\t\t\tr.on('response',function(res){\n\t\t\t\tif(res.statusCode === 404){\n\t\t\t\t\tr.abort()\n\t\t\t\t\tresolve(null)\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tr.pipe(fs.createWriteStream(filePath.replace(/\\.[^/.]+$/, \"\")+'.srt'))\n\t\t\t\t}\n\t\t\t})\n\t\t\t.on('error', function (err) {\n\t\t\t    reject(err)\n\t\t\t})\n\t\t\t.on('end', function(){\n\t\t\t\tresolve(true)\n\t\t\t})\n\t\t})\n\t} catch (err) {\n\t\tconsole.log(err)\n\t}\n}"]}