{"version":3,"sources":["jsdelivr-header.js","/npm/tpb-search@0.0.2/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACLA,MAAM,QAAU,QAAQ,WAClB,QAAU,QAAQ,WAGxB,IAAI,OAAS,2BAEb,OAAO,QAAU,CACf,OAAQ,SAAS,EAAS,GACxB,IAAI,EAAW,GAEf,QADa,OAAS,WAAa,EAAU,WAC7B,SAAS,EAAK,EAAK,GACjC,IAAI,EAAI,QAAQ,KAAK,GAYrB,OAXA,EAAE,yBAAyB,MAAK,SAAS,EAAO,GAC9C,IAAI,EAAU,CAAC,EACf,EAAQ,KAAO,EAAE,MAAM,KAAK,aAAa,OACzC,EAAQ,QAAU,EAAE,MAAM,KAAK,mBAAmB,OAClD,EAAQ,SAAW,EAAE,MAAM,KAAK,mBAAmB,OACnD,EAAQ,IAAM,OAAS,EAAE,MAAM,KAAK,aAAa,KAAK,QACtD,EAAQ,OAAS,EAAE,MAAM,KAAK,mBAAmB,KAAK,kBAAkB,KAAK,QACxD,KAAjB,EAAQ,MACV,EAAS,KAAK,EAElB,IACO,EAAG,KAAM,EAClB,GACF","file":"/npm/tpb-search@0.0.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/tpb-search@0.0.2/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","// Modules\nconst request = require('request')\nconst cheerio = require('cheerio')\n\n// 1337x.to base URL\nlet tpbURL = 'https://thepiratebay.org'\n\nmodule.exports = {\n  search: function(keyword, cb) {\n    let torrents = []\n    var reqURL = tpbURL + '/search/' + keyword + '/0/99/0'\n    request(reqURL, function(err, res, body) {\n      var $ = cheerio.load(body)\n      $('table#searchResult tr').each(function(index, el) {\n        var torrent = {}\n        torrent.name = $(this).find('a.detLink').text()\n        torrent.seeders = $(this).find('td:nth-child(3)').text()\n        torrent.leechers = $(this).find('td:nth-child(4)').text()\n        torrent.url = tpbURL + $(this).find('a.detLink').attr('href')\n        torrent.magnet = $(this).find('td:nth-child(2)').find('a:nth-child(2)').attr('href')\n        if (torrent.name !== '') {\n          torrents.push(torrent)\n        }\n      })\n      return cb(null, torrents)\n    })\n  }\n}\n"]}