xvideos.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. console.log('bundle2!')
  2. printable = (platform) => {
  3. return platform === "WEB";
  4. }
  5. request = async (method, url, data = null, headers = {}, platform) => {
  6. if (platform === "WEB") {
  7. url = url.replace("https://www.xvideos.com/", "http://127.0.0.1:82/");
  8. }
  9. console.log(`request url:${url}`)
  10. console.log(`request data:${data}`)
  11. console.log(`request method:${method}`)
  12. console.log(`request headers:${JSON.stringify((headers))}`)
  13. if (platform === "WEB") {
  14. const res = await fetch(url, {
  15. 'mode': 'cors',
  16. 'method': method,
  17. 'headers': headers,
  18. 'body': data
  19. })
  20. const resData = await res.text()
  21. return Promise.resolve({
  22. 'data': resData,
  23. 'headers': res.headers
  24. });
  25. }
  26. return new Promise((resolve, reject) => {
  27. AF.request(url, method, data, headers, (data, headers, err) => {
  28. if (err) {
  29. reject(err);
  30. } else {
  31. console.log(`response headers: ${headers}`);
  32. resolve({
  33. 'data': data,
  34. 'headers': JSON.parse(headers)
  35. });
  36. }
  37. });
  38. })
  39. }
  40. detail = async (url, platform) => {
  41. try {
  42. const htmlResp = await request('GET', url, null, {}, platform);
  43. let {data: html, headers: htmlHeaders} = htmlResp;
  44. const formats = [];
  45. formats.push({
  46. "url": html.match(/html5player.setVideoUrlLow\('(.*)'\);/)[1],
  47. "quality": "240"
  48. })
  49. formats.push({
  50. "url": html.match(/html5player.setVideoUrlHigh\('(.*)'\);/)[1],
  51. "quality": "1080"
  52. })
  53. const videoDetails = {
  54. "title": html.match(/html5player.setVideoTitle\('(.*)'\);/)[1],
  55. "thumbnail": html.match(/html5player.setThumbUrl\('(.*)'\);/)[1],
  56. "videoId": html.match(/html5player.setEncodedIdVideo\('(.*)'\);/)[1],
  57. }
  58. const ret = {
  59. "code": 200,
  60. "msg": "",
  61. "data": {
  62. "videoDetails": videoDetails,
  63. "streamingData": {
  64. "formats": formats
  65. }
  66. },
  67. "id": "DetailViewModel_detail_url"
  68. }
  69. console.log(`detail result: ${JSON.stringify(ret)}`);
  70. return ret;
  71. } catch (e) {
  72. const ret = {
  73. "code": -1,
  74. "msg": e.toString()
  75. }
  76. console.log(`detail result error: ${JSON.stringify(ret)}`);
  77. console.log(e);
  78. return ret;
  79. }
  80. }