untitled notebook

node v10.24.1
version: 1.0.0
endpointsharetweet
require("request/package.json"); var express = require("@runkit/runkit/express-endpoint/1.0.0"); var requestPromise = require("request-promise"), youtubedl = require('youtube-dl'), mcache = require( 'memory-cache'), app = express(module.exports) // const app = express() /** CONFIG **/ const port = process.env.PORT || 4000 const requestCache = (duration) => { return (req, res, next) => { let key = `__express__${req.originalUrl}` || req.url let cachedBody = mcache.get(key) if (cachedBody) { res.send(cachedBody) } else { res.sendResponse = res.send res.send = (body) => { mcache.put(key, body, duration) res.sendResponse(body) } next() } } } /** ROUTES **/ /* home */ app.get('/', (req, res) => { const text = '<h1>OpenLoad.CO API project</h1><p>This is just a scraper, if you have content you wish to be removed, please contact them (openload.co), not me, at their email: <a href="mailto:dmca@openload.co">dmca@openload.co</a>.</p><p>Full source code available on Github: <a href="https://www.github.com/milankragujevic/openload-api/" target="_blank">openload-api.git</a>. </p><hr><p>Copyright &copy; 2018 Milan Kragujević. Some rights reserved. By using this API you may be committing copyright infringement. I am not responsible for the contents of the API. </p>' res.send(text) }) /* popular items, with pagination */ app.get('/:videoId', requestCache(60 * 60 * 12), (req, res) => { if (req.params.videoId === '' || req.params.videoId === 'favicon.ico') { return } let url = `https://openload.co/embed/${req.params.videoId}/` youtubedl.getInfo(url, (err, info) => { if (err) { res.send({ status: false, error: 'Unknown error occurred!' }) } res.send({ success: true, data: { id: info.id, title: info.title, stream: info.url, thumbnail: info.thumbnail } }) }) }) app.get('/match', (req, res) => { var data = "hello"; res.send(data) }); /** LISTEN **/ app.listen(port) console.log(`Listening on: ${port}`)
require("request/package.json"); var requestPromise = require("request-promise") var getMatch = { bookmaker_id: "3", _ApplicationId: "d93305fc-b7fb-4b4f-9b36-23f8319a9588", _ClientVersion: "js2.2.1", _InstallationId: "bcb2536c-2f30-05cb-9b90-36f4863b872b" } requestPromise("https://www.bhawlone.com/parse/functions/getMatches", { "credentials":"include", "headers": { "accept":"*/*","accept-language":"en-GB,en;q=0.9,en-US;q=0.8,my;q=0.7", "content-type":"application/json" }, "referrer":"https://www.bhawlone.com/", "referrerPolicy":"no-referrer-when-downgrade", "body":JSON.stringify(getMatch), "method":"POST", "mode":"cors" }).then(response => JSON.parse(response)) .then(res => console.log(res.result)) .catch(error => console.error('Error:', error));
var getMatchDetail = { id: "1763141", _ApplicationId: "d93305fc-b7fb-4b4f-9b36-23f8319a9588", _ClientVersion: "js2.2.1", _InstallationId: "bcb2536c-2f30-05cb-9b90-36f4863b872b" } requestPromise("https://www.bhawlone.com/parse/functions/getMatchDetail", { "credentials":"include", "headers": { "accept":"*/*","accept-language":"en-GB,en;q=0.9,en-US;q=0.8,my;q=0.7", "content-type":"application/json" }, "referrer":"https://www.bhawlone.com/", "referrerPolicy":"no-referrer-when-downgrade", "body":JSON.stringify(getMatchDetail), "method":"POST", "mode":"cors" }).then(response => JSON.parse(response)) .then(res => console.log(res.result)) .catch(error => console.error('Error:', error));
Loading…

no comments

    sign in to comment