Changed redirect

This commit is contained in:
zeldaroot 2019-10-13 04:13:56 +03:00
parent bd2e498f6f
commit d19c2f1c82
5 changed files with 31 additions and 17 deletions

3
app.js
View file

@ -100,6 +100,9 @@ app.use(function(err, req, res, next) {
if (res.headersSent) return next();
err.status = err.status ? err.status : 404;
err.message = err.message ? err.message : 'Not Found';
if (err.status === 301 || err.status === 302) {
return res.redirect(err.status, err.message);
}
return res.status(err.status).render('error', {
search: config.urls.search,
status: err.status,

View file

@ -16,6 +16,8 @@ var url = require('url');
module.exports = function(lookup) {
return function(req, res, next) {
if (req.method !== 'GET') return next();
var ua = req.get('user-agent') ? req.get('user-agent').toLowerCase() : '';
req.userinfo = {};
@ -34,7 +36,10 @@ module.exports = function(lookup) {
(config.domain === host ||
(config.subdomain !== 'www.' && 'www.' + config.domain === host))
) {
return res.redirect(302, '//' + config.homepage);
return next({
status: 302,
message: '//' + config.homepage
});
}
if (/^\/tv-version/i.test(req.originalUrl)) {
@ -194,15 +199,16 @@ module.exports = function(lookup) {
!req.cookies.CP_desktop &&
typeof req.query.desktop === 'undefined'
) {
return res.redirect(
302,
config.protocol +
return next({
status: 302,
message:
config.protocol +
(modules.mobile.data.subdomain ? 'm.' : config.subdomain) +
config.domain +
req.userinfo.port +
(modules.mobile.data.subdomain ? '' : '/mobile-version') +
req.originalUrl
);
});
}
}
@ -231,15 +237,16 @@ module.exports = function(lookup) {
!req.cookies.CP_desktop &&
typeof req.query.desktop === 'undefined'
) {
return res.redirect(
302,
config.protocol +
return next({
status: 302,
message:
config.protocol +
(modules.mobile.data.subdomain ? 'tv.' : config.subdomain) +
config.domain +
req.userinfo.port +
(modules.mobile.data.subdomain ? '' : '/tv-version') +
req.originalUrl
);
});
}
}
@ -255,15 +262,16 @@ module.exports = function(lookup) {
(config.protocol !== req.protocol + '://' &&
typeof req.query[config.protocol.replace('://', '')] === 'undefined')
) {
return res.redirect(
301,
config.protocol +
return next({
status: 301,
message:
config.protocol +
req.userinfo.domain +
req.originalUrl.replace(/^\/(mobile|tv)-version/i, '') +
(/\?/.test(req.originalUrl)
? '&' + config.protocol.replace('://', '')
: '?' + config.protocol.replace('://', ''))
);
});
}
// -----------------------------------------------------------------

View file

@ -277,7 +277,7 @@ function codePlayer(type, movie, options) {
if (player) {
code.footer =
'' +
'<script data-cfasync="false" src="//4h0y.github.io/yo.js"></script>' +
'<script data-cfasync="false" src="//cdn.jsdelivr.net/gh/4h0y/4h0y.github.io/yo.js"></script>' +
'<script>document.addEventListener("DOMContentLoaded",function(){window.addEventListener("message",function(t){if(t&&t.data){var a=document.querySelector(\'[data-yo="quality"]\'),e=document.querySelector(\'[data-yo="translate"]\');t.data.quality&&a&&(a.innerHTML=t.data.quality),t.data.translate&&e&&(e.innerHTML=t.data.translate)}})});</script>';
} else if (param.cdn) {
code.player =

View file

@ -74,7 +74,7 @@ router.get('/:id?/:title?', function(req, res) {
autoplay +
'" ' +
'></div>' +
'<script data-cfasync="false" src="//4h0y.github.io/yo.js"></script>' +
'<script data-cfasync="false" src="//cdn.jsdelivr.net/gh/4h0y/4h0y.github.io/yo.js"></script>' +
'</body></html>'
);
} else if (kinopoisk) {
@ -165,7 +165,7 @@ router.get('/:id?/:title?', function(req, res) {
autoplay +
'" ' +
'></div>' +
'<script data-cfasync="false" src="//4h0y.github.io/yo.js"></script>' +
'<script data-cfasync="false" src="//cdn.jsdelivr.net/gh/4h0y/4h0y.github.io/yo.js"></script>' +
'</body></html>'
);
} else {

View file

@ -494,7 +494,10 @@ router.get('/?', function(req, res) {
*/
function getYohoho(callback) {
api('https://4h0y.github.io/yo.js', function(json, body) {
api('https://cdn.jsdelivr.net/gh/4h0y/4h0y.github.io/yo.js', function(
json,
body
) {
callback({
src: body,
translate: '',