NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

'use strict';
var httpUtils = require('../utils/httpUtils');
var storageUtils = require('../utils/storageUtils');
var replaceUtils = require('../utils/replaceUtils');
var cfg = require('../config/config');
var logger = require('../config/logger');
var stbbe = require('./stbbe');

exports.variantplaylist = function(req, res, next) {
var ip = httpUtils.getIPAddressFromReq(req);
console.log('----- variantplaylist ------');
console.log('ip:' + ip);
// var allowFlag =
// if (storageUtils.findInFile(cfg.whitelist.path, ip)) {
// console.log('in whitelist ip:' + ip);
// getPlaylistIndex(req, res, next);
// } else {
// console.log('not! in whitelist ip:' + ip);
// stbbe.verifyToken(req, res, next, function(resObj) {
// console.log(JSON.stringify(resObj));
// if (resObj.statusCode == 200) {
// var bodeObj = JSON.parse(resObj.body);
// if (bodeObj.resultCode == '20000') {
// storageUtils.insertToFile(cfg.whitelist.path, ip);
// getPlaylistIndex(req, res, next);
// } else {
// res.status(401);
// res.end();
// }
// } else {
// res.status(503);
// res.end();
// }
// });
// }
getVariantplaylist(req, res, next);
};


function getVariantplaylist(req, res, next) {
var startTime = new Date().getTime();
var stopTime = '';
var ip = httpUtils.getIPAddressFromReq(req);
var type = req.params.type;
var path = req.params.path;
var index = req.params.index;
// var token = req.query.t;
var servEndPoint;

console.log('-- incoming type' + type);
console.log('-- incoming path' + path);
var urlPath = '';
switch (type) {
case 'VOD':
index = 'index.m3u8';
urlPath = '/NonDRM/' + path + '/' + index;
servEndPoint = cfg.servEndPoint.origin;
break;
case 'LIVE':
index = 'indexSTB.m3u8';
servEndPoint = cfg.servEndPoint.scorpio;
urlPath = '/' + path + '/' + index;
break;
default:
break;
}
//var urlPath = '/NonDRM/' + path + '/' + index;
var hostOutGoing = servEndPoint.host + urlPath;
var options = {
hostname: servEndPoint.host,

method: cfg.httpMethod.GET,
path: urlPath,
headers: {
'Cache-control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache'
}
};
console.log('options' + JSON.stringify(options));
var callbackFunc = function(resObj) {
console.log('resObj' + JSON.stringify(resObj));
stopTime = new Date().getTime();
var urlApp = cfg.app.url;
var headers = resObj.headers;
var statusCode = resObj.statusCode;
var replaceUrl = urlApp + 'api/v1/playlist/' + type + '/' + path + '/';
var body = resObj.body;
var data = '';
var msg = 'success';
if (statusCode == 200) {
if (body) {
data = replaceUtils.replaceLeafIndex(body, replaceUrl);
}

} else {
msg = 'fail';
}
//hostname|name|income ip|income api name|type|path|fileName|20000(resultcode)|success(msg)|host/path(out)
logger.info(cfg.app.hostname + '|' + cfg.app.name + '|' + ip + '|' + req.headers.url + '|' + type + '|' + path + '|' + index + '|' + statusCode + '|' + msg + '|' + hostOutGoing + '|' + (stopTime - startTime));
res.writeHead(statusCode, headers);
console.log('response : n' + data);
res.end(data);
};

httpUtils.request(options, callbackFunc);
}

exports.playlist = function(req, res, next) {
var startTime = new Date().getTime();
var stopTime = '';
var ip = httpUtils.getIPAddressFromReq(req);
// if (storageUtils.findInFile(cfg.whitelist.path, ip)) {
console.log('----- playlist ------');
console.log('ip:' + ip);


var type = req.params.type;
var path = req.params.path;
var index = req.params.index;
// var mediaType = req.params.mediaType;
// var fileName = req.params.fileName;
// var contentName = req.params.contentName;
var servEndPoint;
var urlPath = '';
switch (type) {
case 'VOD':
servEndPoint = cfg.servEndPoint.origin;
urlPath = '/NonDRM/' + path + '/' + index;
break;
case 'LIVE':

servEndPoint = cfg.servEndPoint.scorpio;
urlPath = '/' + path + '/' + index;
break;
default:
break;
}

//var urlPath = '/NonDRM/' + path + '/' + index;
var hostOutGoing = servEndPoint.host + urlPath;
var options = {
hostname: servEndPoint.host,

method: cfg.httpMethod.GET,
path: urlPath,
headers: {
'Cache-control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache'
}
};

var callbackFunc = function(resObj) {
stopTime = new Date().getTime();
var urlApp = cfg.app.url;
var headers = resObj.headers;
var statusCode = resObj.statusCode;
var body = resObj.body;
var replaceUrl = urlApp + 'api/v1/key/' + type + '/' + path + '/';
var replaceCdnUrl = servEndPoint.cdnUrl + path + '/';
var data = '';
var msg = 'success';
if (statusCode == 200) {
if (body) {
data = replaceUtils.replaceKey(body, replaceUrl);
data = replaceUtils.replaceTsFile(data, replaceCdnUrl);
}
} else {
msg = 'fail';
}
logger.info(cfg.app.hostname + '|' + cfg.app.name + '|' + ip + '|' + req.headers.url + '|' + type + '|' + path + '|' + index + '|' + statusCode + '|' + msg + '|' + hostOutGoing + '|' + (stopTime - startTime));
res.writeHead(statusCode, headers);
console.log('response : n' + data);
res.end(data);
};

httpUtils.request(options, callbackFunc);

// } else {
// console.log('not! in whitelist ip:' + ip);
// res.status(401);
// res.end();
// }
};

exports.key = function(req, res, next) {
var startTime = new Date().getTime();
var stopTime = '';
var ip = httpUtils.getIPAddressFromReq(req);
// if (storageUtils.findInFile(cfg.whitelist.path, ip)) {
console.log('----- key ------');
console.log('ip:' + ip);

var type = req.params.type;
var path = req.params.path;
var key = req.params.key;
var urlPath = '';
switch (type) {
case 'VOD':
urlPath = '/NonDRM/' + path + '/' + key;
//servEndPoint = cfg.servEndPoint.origin;
break;
case 'LIVE':
urlPath = '/' + path + '/' + key;
//servEndPoint = cfg.servEndPoint.scorpio;
break;
default:
break;
}
//var urlPath = '/' + path + '/' + key;
var hostOutGoing = cfg.servEndPoint.key.host + urlPath;
var options = {
hostname: cfg.servEndPoint.key.host,
method: cfg.httpMethod.GET,
path: urlPath,
headers: {
'Cache-control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache'
}
};

var callbackFunc = function(resObj) {
stopTime = new Date().getTime();
var headers = resObj.headers;
var statusCode = resObj.statusCode;
var body = resObj.body;
var data = '';
var msg = 'success';
if (statusCode == 200) {
if (body) {
data = body;
}
} else {
msg = 'fail';
}
logger.info(cfg.app.hostname + '|' + cfg.app.name + '|' + ip + '|' + req.headers.url + '|' + type + '|' + path + '|' + key + '|' + statusCode + '|' + msg + '|' + hostOutGoing + '|' + (stopTime - startTime));
// res.headers = headers;
res.writeHead(statusCode, headers);
res.end(data);
};

httpUtils.request(options, callbackFunc);
// } else {
// console.log('not! in whitelist ip:' + ip);
// res.status(401);
// res.end();
// }

};
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.