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.

52 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. var file="";
  17. if(!videoManager.isPublicVideo(videoID))
  18. {
  19. if(utils.checkPrivilege(request) >= utils.PRIVILEGE.MEMBER)
  20. {
  21. file = fs.readFileSync("./icon/private/" + name);
  22. }
  23. else
  24. {
  25. utils.printError(result, "You need to be logged in");
  26. throw "Not logged in";
  27. }
  28. }
  29. else
  30. {
  31. file = fs.readFileSync("./icon/public/" + name);
  32. }
  33. result.writeHead(200, {'Content-Type': 'image/png',
  34. 'Vary': 'Accept-Encoding'});
  35. result.write(file);
  36. result.end();
  37. }
  38. catch(error)
  39. {
  40. utils.printError(result, "Invalid Icon");
  41. }
  42. });
  43. module.exports = routes;