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,EAAM,EAAI,QAAQ,QAAS,MACb,EAChB,KAxBU,CACV,QAAQ,IAAI,gDACZ,IAAI,EAAK,SACT,EAAG,WAAU,SAAU,EAAK,EAAO,GACjC,EAAG,QACC,IAGQ,KAAR,GAAgC,OAAlB,EAAI,OAAO,IAC3B,QAAQ,IAAI,IAEd,SAAS,GACX,GACF,CAdA,CA2BF,CAEI,QAAQ,OAAS,QACnB,OAGF,OAAO,QAAU","file":"/npm/spotgen@1.0.28/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/spotgen@1.0.28/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","#!/usr/bin/env node\n/* global document:true, window:true */\n\nvar eol = require('eol')\nvar fs = require('fs')\nvar jsdom = require('jsdom').jsdom\ndocument = jsdom()\nwindow = document.defaultView\nvar clipboardy = require('clipboardy')\nvar git = require('git-rev')\nvar prompt = require('cli-input')\n\nvar Generator = require('./lib/generator')\nvar pkg = require('./package.json')\n\nvar help = 'Usage:\\n' +\n    '\\n' +\n    '    spotgen input.txt [output.txt]\\n' +\n    '\\n' +\n    'input.txt is a text file containing a generator string,\\n' +\n    'invoking any number of generator commands. output.txt\\n' +\n    'will contain the generator\\'s output, a list of Spotify URIs\\n' +\n    'which can be imported into Spotify. If an output file is not\\n' +\n    'specified, then the Spotify URIs are written to standard output,\\n' +\n    'with an option to copy them to the clipboard.\\n' +\n    '\\n' +\n    'Alternatively, you can pass a generator string as a single argument:\\n' +\n    '\\n' +\n    '    spotgen \"#artist Bowery Electric\"\\n' +\n    '    spotgen \"#similar Beach House\\\\n#similar Hooverphonic\"\\n' +\n    '    spotgen http://www.last.fm/user/username/library\\n' +\n    '\\n' +\n    'Make sure to surround the string with quotes (\") if it contains\\n' +\n    'spaces or special characters. Line breaks can be expressed as \\\\n.\\n' +\n    '\\n' +\n    'You can also run the generator with no arguments and enter commands\\n' +\n    'interactively. This saves you the trouble of quoting strings and\\n' +\n    'escaping newlines.\\n' +\n    '\\n' +\n    'To import the playlist into Spotify:\\n' +\n    '\\n' +\n    '1.  Copy the output of the generator:\\n' +\n    '    Choose Edit -> Copy (Ctrl + C).\\n' +\n    '2.  Create a new playlist in Spotify:\\n' +\n    '    Choose File -> New Playlist (Ctrl + N).\\n' +\n    '3.  Paste into the playlist:\\n' +\n    '    Select the playlist and choose Edit -> Paste (Ctrl + V).'\n\n/**\n * Generator function.\n * @param {string} str - Generator string.\n * @param {output} [output] - Output file.\n * @return {Promise} A promise.\n */\nfunction generate (str, output) {\n  output = output || 'STDOUT'\n  output = output.trim()\n  var generator = new Generator(str)\n  return generator.generate().then(function (result) {\n    if (!result) {\n      return\n    }\n    if (output === 'STDOUT') {\n      console.log('')\n      if (generator.format === 'uri') {\n        console.log(\n          '********************************************************\\n' +\n            '* COPY AND PASTE THE BELOW INTO A NEW SPOTIFY PLAYLIST *\\n' +\n            '********************************************************\\n')\n      }\n      console.log(result + '\\n')\n      var ps = prompt({format: 'Copy to clipboard? (Y/n) '})\n      ps.prompt(null, function (err, val) {\n        if (err) {\n          return\n        }\n        if (val[0].toLowerCase().trim() !== 'n') {\n          clipboardy.writeSync(result + '\\n')\n        }\n        ps.close()\n      })\n    } else {\n      result = eol.auto(result)\n      fs.writeFile(output, result, function (err) {\n        if (err) { return }\n        console.log('Wrote to ' + output)\n      })\n    }\n  })\n}\n\n/**\n * Main method.\n * Invoked when run from the command line.\n */\nfunction main () {\n  var input = process.argv[2]\n  var output = process.argv[3]\n  var str = input\n  if (typeof input === 'string' &&\n      input.match(/(^-*h(elp)?$)|(^\\/\\?$)/gi)) {\n    console.log(help)\n    return\n  } else if (typeof input === 'string' &&\n             input.match(/(^-*v(ersion)?$)|(^\\/\\?$)/gi)) {\n    process.chdir(__dirname)\n    git.short(function (sha) {\n      console.log(pkg.version + (sha ? ('+' + sha) : ''))\n    })\n    return\n  }\n  if (!input) {\n    console.log('Enter generator string (submit with Ctrl-D):')\n    var ps = prompt()\n    ps.multiline(function (err, lines, str) {\n      ps.close()\n      if (err) {\n        return\n      }\n      if (str !== '' && str.slice(-1) !== '\\n') {\n        console.log('')\n      }\n      generate(str)\n    })\n  } else {\n    try {\n      // is input a file name?\n      str = fs.readFileSync(input, 'utf8').toString()\n      str = eol.lf(str)\n      generate(str, output)\n    } catch (err) {\n      // input is generator string; help out primitive shells\n      // (e.g., Windows') with newlines\n      str = str.replace(/\\\\n/gi, '\\n')\n      generate(str, output)\n    }\n  }\n}\n\nif (require.main === module) {\n  main()\n}\n\nmodule.exports = Generator\n"]}