{"version":3,"sources":["jsdelivr-header.js","/npm/voddo@0.0.5/voddo.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,cAAgB,QAAQ,mBACxB,UAAY,IAAI,cAChB,gBAAkB,8CAClB,MAAQ,wCACR,WAAa,sCACb,aAAe,QAAQ,UACvB,MAAQ,QAAQ,iBAAiB,MACjC,SAAW,QAAQ,UAAU,SAC7B,GAAK,QAAQ,MACb,GAAK,QAAQ,MACb,KAAO,QAAQ,QACf,MAAQ,QAAQ,QAAR,CAAiB,SAGzB,aAAe,kBACf,iBAAmB,2BACnB,SAAW,4CACX,YAAa,EAEb,SAAY,IAGhB,MAAM,eAAe,KACd,UAAU,YAAY,CAAC,EAAK,KAAM,UAGrC,YAAe,IACnB,IAAI,EAAI,iBAAiB,KAAK,GAC9B,IAAK,EACH,MAAM,IAAI,MAAM,uEAElB,OAAO,EAAE,EAAE,EAGP,MAAQ,CAAC,EAAK,EAAc,KAChC,EAAe,GAAgB,KAC/B,EAAW,GAAY,IAEvB,MAAM,EAAK,IAAI,aAET,EAAW,MAAO,GACf,IAAI,SAAS,IAClB,WAAW,EAAS,EAAG,IAI3B,IAAI,EAAQ,EAEE,WACZ,OAAmB,CAEjB,IAAI,QADE,EAAS,GAEf,IACE,QAAY,SAAS,EACvB,CAAE,MAAO,GACP,QAAyB,IAAd,EAAE,UAA4B,aAAa,KAAK,EAAE,SAE3D,MADA,QAAQ,MAAM,mCACR,CAEV,CAEA,GADA,MAAM,YAAY,YAAc,KACb,iBAAR,EAAkB,CAC3B,MAAM,EAAO,YAAY,GACzB,EAAG,KAAK,WAAY,GACpB,EAAQ,CACV,MACE,EAAiB,EAAR,EAAY,EAAY,EAAmB,EAAR,CAEhD,CACD,EArBa,GAwBd,OAAO,CAAE,EAOX,OAAO,QAAU,CACf,YACA,kBACA","file":"/npm/voddo@0.0.5/voddo.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/voddo@0.0.5/voddo.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 YoutubeDlWrap = require('youtube-dl-wrap');\nconst youtubedl = new YoutubeDlWrap();\nconst helloThereVideo = 'https://www.youtube.com/watch?v=rpXMSIYDx3I';\nconst cbMel = 'https://chaturbate.com/projektmelody/';\nconst testStream = 'https://chaturbate.com/milanaaafit/';\nconst EventEmitter = require('events');\nconst spawn = require(\"child_process\").spawn;\nconst Readable = require(\"stream\").Readable;\nconst os = require('os');\nconst fs = require('fs');\nconst path = require('path');\nconst debug = require('debug')('voddo');\n\n\nconst offlineRegex = /ERROR:.*offline/;\nconst destinationRegex = /Destination:\\s+(.+\\.\\S+)/;\nconst fakePath = '/tmp/projektmalady 2021-01-01 fakevid.mp4';\nconst isWatching = true;\n\nconst download = (url) => {\n  // YoutubeDlWrap is kinda weird in that it returns an error\n  // rather than throwing the error or rejecting the promise.\n  debug(`downloading ${url}`);\n  return youtubedl.execPromise([url, '-f', 'best']);\n};\n\nconst parseOutput = (output) => {\n  let r = destinationRegex.exec(output);\n  if (!r) {\n    throw new Error('destination filename could not be found in the ffmpegWrapper output');\n  }\n  return r[1];\n}\n\nconst watch = (url, defaultDelay, maxDelay) => {\n  defaultDelay = defaultDelay || 1000 * 15; // The starting retry delay\n  maxDelay = maxDelay || 1000 * 60 * 10; // The maximum amount of time to delay beteween checking for a live stream.\n\n  const ee = new EventEmitter();\n\n  const sleepFor = async (ms) => {\n    return new Promise((resolve) => {\n      setTimeout(resolve, ms);\n    })\n  }\n\n  let delay = defaultDelay;\n\n  let _watchP = (async () => {\n    while (isWatching) {\n      await sleepFor(delay);\n      let res;\n      try {\n        res = await download(url);\n      } catch (e) {\n        if (typeof e.message === 'undefined' || !offlineRegex.test(e.message)) {\n          console.error('throwing due to unhandled error')\n          throw e;\n        }\n      }\n      debug(`response:${res}, delay:${delay}`);\n      if (typeof res === 'string') {\n        const dest = parseOutput(res);\n        ee.emit('complete', dest);\n        delay = defaultDelay;\n      } else {\n        delay = (delay * 2 > maxDelay) ? maxDelay : delay * 2;\n      }\n    }\n  })()\n\n\n  return ee;\n}\n\n\n\n\n\nmodule.exports = {\n  watch,\n  download,\n  parseOutput\n}\n"]}