Lightweight node app to use in place of plex to self host your video and movie collections. Running on just under 50MB of ram this is ideal for people looking to host videos on minimal hardware.
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.

55 lines
1.2 KiB

  1. const routes = require('express').Router();
  2. const utils = require("../utils");
  3. const fs = require('fs');
  4. const videoManager = require('../videoManager');
  5. function isPublicVideo(videoURL)
  6. {
  7. return false;
  8. }
  9. routes.get('/', (request, result) =>
  10. {
  11. try
  12. {
  13. const videoID = request.query.v;
  14. const splitArray = videoID.split('/');
  15. const name = splitArray[splitArray.length -1] + ".png";
  16. console.log(name);
  17. var file="";
  18. if(!videoManager.isPublicVideo(videoID))
  19. {
  20. if(utils.checkPrivilege(request) >= utils.PRIVILEGE.MEMBER)
  21. {
  22. file = fs.readFileSync("./icon/private/" + name);
  23. }
  24. else
  25. {
  26. utils.printError(result, "You need to be logged in");
  27. throw "Not logged in";
  28. }
  29. }
  30. else
  31. {
  32. file = fs.readFileSync("./icon/public/" + name);
  33. }
  34. result.writeHead(200, {'Content-Type': 'image/png',
  35. 'Vary': 'Accept-Encoding'});
  36. result.write(file);
  37. result.end();
  38. }
  39. catch(error)
  40. {
  41. utils.printError(result, "Invalid Icon");
  42. console.log(error);
  43. }
  44. });
  45. module.exports = routes;