Server Installation Guide

Follow these steps to host your own server for PNT Player.

Clone the Repository

git clone https://github.com/projectninjatech/PNT-Player-API.git

Navigate to the Project Directory

cd PNT-Player-API

Create Media Directories

Pick a directory to store your media and create three subdirectories inside it with the following names:

For Example if you select /opt/medias DIR:

/opt/medias

Create movies DIR for storing movies:

/opt/medias/movies

Create shows DIR for storing TV Shows:

/opt/medias/shows

Create posters DIR for storing movies & shows posters for offline viewing [Optional]:

/opt/medias/posters

Environment Variable Configuration

Create a .env file in the root directory of the project and add the following environment variables:


TMDB_AUTH_KEY = "YOUR TMDB AUTH KEY"
MONGO_DB_URL = "YOUR MONGODB URL"
ADMIN_REGISTER_SECRET_CODE = "YOUR SECRET CODE TO ALLOW ADMIN REGISTER e.g. abcd1234"
HTTP_SERVER_ADDR = "YOUR HTTP SERVER ADDRESS e.g. http://192.168.0.148:8080"
HTTP_SERVER_MEDIA_DIR = "YOUR MEDIA SERVER MAIN DIRECTORY e.g. C:/Users/imran/Downloads/Video"
MOVIE_DIR = "YOUR MOVIE DIRECTORY e.g. C:/Users/imran/Downloads/Video/movies (dir name should be movies)"
SHOWS_DIR = "YOUR SHOWS DIRECTORY e.g. C:/Users/imran/Downloads/Video/shows (dir name should be shows)"
PORT = 5000
            

Install Dependencies

npm install

Install NodeJS


curl -fsSL https://deb.nodesource.com/setup_21.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
            

Check NodeJS and npm Version

node --version && npm --version

Install PM2

Install PM2 so that the app will run in the background:

sudo npm i pm2 -g
pm2 start npm --name "app" -- run dev

Generate a Startup Script:

pm2 startup

Copy the command that it generates and execute it. The command will something like this:

sudo env PATH=$PATH:/home/yourusername/.nvm/versions/node/v14.16.0/bin /home/yourusername/.nvm/versions/node/v14.16.0/lib/node_modules/pm2/bin/pm2 startup systemd -u yourusername --hp /home/yourusername
            

Save the startup script

pm2 save

Reboot or Poweroff from Admin Dashboard

To enable reboot or poweroff from the admin dashboard, open the Ubuntu Server terminal and type:

sudo visudo

Add the following lines at the end of the file, replacing <username> with your actual username:


<username> ALL=(ALL) NOPASSWD: /sbin/poweroff
<username> ALL=(ALL) NOPASSWD: /sbin/reboot