Skip to content

Commit

Permalink
Merge pull request #14 from justinhartman/develop
Browse files Browse the repository at this point in the history
Merge Develop changes into main
  • Loading branch information
justinhartman committed Aug 11, 2024
2 parents ef1c48b + 4e6f9c1 commit c1e8a10
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 29 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ APP_SECRET=
## Get a free key by registering at https://omdbapi.com
OMDB_API_KEY=your_api_key_here

## If your video player is not loading try changing the domain below by using one of these domains:
## vidsrc.in, vidsrc.pm, vidsrc.xyz, vidsrc.net
VIDSRC_DOMAIN=vidsrc.in

## Uncomment and change these if you want authentication, profile and watchlist functionality to work.
## Be sure to setup a MongoDB first and add your connection string to the MONGO_URI below.
#MONGO_URI="mongodb://localhost:27017"
Expand Down
5 changes: 4 additions & 1 deletion config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ const appConfig = () => {
OMDB_API_KEY: process.env.OMDB_API_KEY,
// You should never change these unless OMDb change their API endpoints.
OMDB_API_URL: process.env.OMDB_API_URL || 'http://www.omdbapi.com',
OMDB_IMG_URL: process.env.OMDB_IMG_URL || 'http://img.omdbapi.com'
OMDB_IMG_URL: process.env.OMDB_IMG_URL || 'http://img.omdbapi.com',
// The vidsrc player domain has been prone to be taken down. Use one of the following domains if it's not working:
// vidsrc.in, vidsrc.pm, vidsrc.xyz, vidsrc.net
VIDSRC_DOMAIN: process.env.VIDSRC_DOMAIN || 'vidsrc.in'
};
}

Expand Down
23 changes: 11 additions & 12 deletions controllers/appController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const axios = require("axios");
const asyncHandler = require('express-async-handler');

const appConfig = require('../config/app');
const {
fetchOmdbData,
fetchAndUpdatePosters
Expand All @@ -22,29 +23,27 @@ const appController = {
*/
getHome: asyncHandler(async (req, res) => {
const query = req.query.q || '';
const type = req.query.type || 'ovie';
const type = req.query.type || 'movie';
const canonical = res.locals.APP_URL;
let newMovies = [];
let newSeries = [];

/**
* Fetch new movies from VidSrc.
* You can switch to new movies instead of the default 'added' with 'https://vidsrc.to/vapi/movie/new'
* Fetch latest movies from VidSrc.
* @type {axios.AxiosResponse<any>}
* @docs https://vidsrc.to/#api
* @docs https://vidsrc.me/api/#list-item-ls-mov
*/
const axiosMovieResponse = await axios.get('https://vidsrc.to/vapi/movie/add');
newMovies = axiosMovieResponse.data.result.items || [];
const axiosMovieResponse = await axios.get(`https://${appConfig.VIDSRC_DOMAIN}/movies/latest/page-1.json`);
newMovies = axiosMovieResponse.data.result || [];
await fetchAndUpdatePosters(newMovies);

/**
* Fetch new TV shows from VidSrc.
* You can switch to new movies instead of the default 'added' with 'https://vidsrc.to/vapi/tv/new'
* Fetch latest TV shows from VidSrc.
* @type {axios.AxiosResponse<any>}
* @docs https://vidsrc.to/#api
* @docs https://vidsrc.me/api/#list-item-ls-tvshow
*/
const axiosSeriesResponse = await axios.get('https://vidsrc.to/vapi/tv/add');
newSeries = axiosSeriesResponse.data.result.items || [];
const axiosSeriesResponse = await axios.get(`https://${appConfig.VIDSRC_DOMAIN}/tvshows/latest/page-1.json`);
newSeries = axiosSeriesResponse.data.result || [];
await fetchAndUpdatePosters(newSeries);

res.render('index', { newMovies, newSeries, query, type, canonical, card: res.locals.CARD_TYPE, user: req.user });
Expand All @@ -66,7 +65,7 @@ const appController = {
let type = req.params.type;
let t = 'movie';
if (type === 'series') t = 'tv'
const iframeSrc = `https://vidsrc.to/embed/${t}/${id}`;
const iframeSrc = `https://${appConfig.VIDSRC_DOMAIN}/embed/${t}/${id}`;
const canonical = `${res.locals.APP_URL}/view/${id}/${type}`;
const data = await fetchOmdbData(id, false);
res.render('view', { data, iframeSrc, query, id, type, canonical, user: req.user });
Expand Down
2 changes: 1 addition & 1 deletion controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const authController = {
try {
await passport.authenticate('local', {
successRedirect: '/user/profile',
failureRedirect: '/user/postLogin',
failureRedirect: '/user/login',
failureFlash: true,
})(req, res);
} catch (error) {
Expand Down
12 changes: 7 additions & 5 deletions views/login.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@
<%- include('./partials/meta/base.ejs') -%>
</head>
<%- include('./partials/navigation.ejs') -%>
<div class="container">
<h1>Login</h1>
<div class="container text-white">
<h1 class="text-warning mt-4 mb-3">Log in to you <%= APP_NAME %> account</h1>
<p>Log in to access your <%= APP_NAME %> account and view your movie and TV show watchlist and history.</p>
<%- include('./partials/alerts.ejs') -%>
<form action="/user/login" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<label for="username" class="form-label text-info">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<label for="password" class="form-label text-info">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Login</button>
<button type="submit" class="btn btn-success">Login <i class="bi-lock"></i></button>
</form>
<p class="mt-4">Don't have an account? <a href="/user/register" class="text-warning">Register here <i class="bi-arrow-right"></i></a></p>
</div>
<%- include('./partials/footer.ejs') -%>
1 change: 1 addition & 0 deletions views/partials/meta/base.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<link rel="canonical" href="<%= canonical %>"/>
<meta name="referrer" content="origin" />
<link rel="apple-touch-icon" sizes="180x180" href="<%= APP_URL %>/images/favicons/apple-touch-icon.png"/>
<link rel="icon" type="image/png" sizes="32x32" href="<%= APP_URL %>/images/favicons/favicon-32x32.png"/>
<link rel="icon" type="image/png" sizes="16x16" href="<%= APP_URL %>/images/favicons/favicon-16x16.png"/>
Expand Down
13 changes: 7 additions & 6 deletions views/register.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
<%- include('./partials/meta/base.ejs') -%>
</head>
<%- include('./partials/navigation.ejs') -%>
<div class="container">
<h1>Register</h1>
<div class="container text-white">
<h1 class="text-warning mt-4 mb-3">Create a <%= APP_NAME %> account</h1>
<p>With a <%= APP_NAME %> account you can add or remove movies and shows to your wishlist. Create a new account with your email and password. </p>
<%- include('./partials/alerts.ejs') -%>
<form action="/user/register" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<label for="username" class="form-label text-info">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<label for="password" class="form-label text-info">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Register</button>
<button type="submit" class="btn btn-success">Register <i class="bi-lock"></i></button>
</form>
<p>Already have an account? <a href="/login">Login here</a></p>
<p class="mt-4">Already have an account? <a href="/user/login" class="text-warning">Login here <i class="bi-arrow-right"></i></a></p>
</div>
<%- include('./partials/footer.ejs') -%>
9 changes: 5 additions & 4 deletions views/view.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</div>
<% } %>
<div class="ratio ratio-16x9">
<iframe src="<%= iframeSrc %>" allow="autoplay; fullscreen" allowfullscreen="yes" class="w-100"></iframe>
<iframe src="<%= iframeSrc %>" referrerpolicy="origin" allow="autoplay; fullscreen" allowfullscreen="yes" class="w-100"></iframe>
</div>
<% if (data.Response !== 'False') { -%>
<div class="row text-white my-4">
Expand All @@ -54,12 +54,13 @@
</div>
</div>
<% } %>
<%- include('./partials/disqus.ejs') -%>
<div class="row mt-2">
<div class="text-center">
<a href="<%= APP_URL %>/" class="btn btn-outline-warning btn-md-lg">Home</a>
<a href="javascript:history.back()" class="btn btn-warning btn-md-lg">Back to Search</a>
<a href="<%= APP_URL %>/" class="btn btn-outline-info btn-md-lg"><i class="bi-house"></i> Home</a>
<a href="<%= APP_URL %>/watchlist" class="btn btn-outline-success btn-md-lg"><i class="bi-view-list"></i> Watchlist</a>
<a href="javascript:history.back()" class="btn btn-warning btn-md-lg"><i class="bi-search"></i> Back to Search</a>
</div>
</div>
<%- include('./partials/disqus.ejs') -%>
</div>
<%- include('./partials/footer.ejs') -%>

0 comments on commit c1e8a10

Please sign in to comment.