You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

server.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var fs = require("fs");
  2. var web = require("webstuff");
  3. var play = require("./js/play");
  4. var magnet = "magnet:?xt=urn:btih:13241fe16a2797b2a41b7822bde970274d6b687c&dn=Mad+Max%3A+Fury+Road+%282015%29+1080p+BrRip+x264+-+YIFY&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969";
  5. var conf = JSON.parse(fs.readFileSync("conf.json"));
  6. var app = web();
  7. play.init(app, conf);
  8. app.express.use((req, res, next) => {
  9. if (req.url === "/" && play.isPlaying())
  10. res.redirect(play.httpPath);
  11. else
  12. next();
  13. });
  14. app.static("web");
  15. app.post("/play/url", (req, res) => {
  16. req.parseBody((err, fields) => {
  17. if (!fields.url)
  18. return res.redirect("/");
  19. play.playUrl(fields.url, () => {
  20. res.redirect(play.httpPath);
  21. });
  22. });
  23. });
  24. app.post("/play/magnet", (req, res) => {
  25. req.parseBody((err, fields) => {
  26. if (!fields.magnet)
  27. return res.redirect("/");
  28. play.playTorrent(fields.magnet, () => {
  29. res.redirect(play.httpPath);
  30. });
  31. });
  32. });