ego's notebooks

  • cm api - /ego/cmmovie
    Last edited 10 months ago
    var Xray = require('x-ray'); var mongoose = require('mongoose') const bodyParser = require('body-parser') const express = require("@runkit/ego/express-app/1.0.0") const app = express(module.exports); const base = 'https://channelmyanmar.org/?s='; const baseUrl = 'https://channelmyanmar.org/movies/'; const pageUrl = 'https://channelmyanmar.org/movies/page/'; const thisUrl = 'https://cmmovie-d7a4ca7dqc5s.runkit.sh/'; const x = Xray({ filters: { regex: function(value) { return typeof value === 'string' ? value.replace(/(\(.*?\))/g, '') : value }, replace: function(value) { return typeof value === 'string' ? value.replace('https://channelmyanmar.org/', thisUrl+'api/movie/') : value }, movieid: function(value) { return typeof value === 'string' ? value.replace('https://channelmyanmar.org/', '') : value }, number: function(value) { return typeof value === 'string' ? Number(value.replace(/\D+/g,'')) : value }, runkitUrl: function(val){ if(typeof val ==='string'){ let _url = thisUrl+'movie/?url='+val; return _url; } }, category: function(value) { if (typeof value === 'string') { let refine = value.replace('https://channelmyanmar.org/category/', thisUrl); let refine2 = refine ; return refine; } }, catId: function(value) { if (typeof value === 'string') { let refine = value.replace('https://channelmyanmar.org/category/', ''); let refine2 = refine.replace('/','') ; return refine2; } }, fix2: function(value) { if (typeof value === 'string') { let refine = Number(value) + 1; let refine2 = thisUrl+"api/page/" +refine+"/?s"; return refine2; } }, yadi: function(value) { if (typeof value === 'string') { if (value.includes("https://yadi.sk")){ // var url = getUrl(value); return value; } return ; } }, yadiId: function(value) { return typeof value === 'string' ? value.replace('https://yadi.sk/i/', '') : value }, mega: function(value) { if (typeof value === 'string') { if (value.includes("https://mega.nz/")){ var url = value.replace("https://mega.nz/file", "https://mega.nz/embed"); return url; } return ; } }, host: function(value) { if (typeof value === 'string') { var url = value.replace("https://", "").trim(); //url = url.split(".")[0]; if (url.includes("Soliddrive.co")) { url = "SolidDrive"; } else if (url.includes("drive.google.com")) { url = "Myandrive"; } else if (url.includes("disk.yandex.com")) { url = "Yandex" ; } else if (url.includes("mirrorace")) { url = "Mirrorace"; } else if (url.includes("fastload")) { url = "Fastload"; } else if (url.includes("megaup")) { url = "MegaUp"; } else if (url.includes("mega")) { url = "MeGa"; }else if (url.includes("1fichier.com")) { url = "1Fichier"; }else if (url.includes("upstream.to")) { url = "Upstream"; }; return url; } } } });
  • livescore api - /ego/livescore-api
    Last edited 3 years ago
    const got = require('got'); const headers = { 'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpLm9rc3BvcnRzZXJ2LmNvbVwvYXBpXC9hdXRoXC9yZWdpc3RlciIsImlhdCI6MTYyMjcyNjE3MSwiZXhwIjoxNjIzMzMwOTcxLCJuYmYiOjE2MjI3MjYxNzEsImp0aSI6InVpVDNwNmNMSmx6YXB6VnoiLCJzdWIiOjE3NTMwMSwicHJ2IjoiNTQzOTU1NmFlY2E5M2M1YzJhYjI0OWU3YzY4NzQ1NDAyNGVkZjUzYiJ9.rzXxCUEw3SZhbagjFUIwVXTlb-kJSRREjN-CqaH6aT8', 'Accept': '*/*', 'oks-timezone': 'Asia/Rangoon', 'User-Agent': 'OKSports/1.4.1 (com.pt.OKSports; build:19; iOS 14.6.0) Alamofire/5.4.3', 'Host': 'api.oksportserv.com', 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'oks-country-code': 'MM', 'Accept-Language': 'en-MM;q=1.0, my-MM;q=0.9', 'Content-Length': '6', 'Accept-Encoding': 'br;q=1.0, gzip;q=0.9, deflate;q=0.8', 'Connection': 'keep-alive', 'oks-locale': 'mm' }; const dataString = 'page=1'; const options = { url: 'https://api.oksportserv.com/api/football/matches/ongoing', method: 'POST', headers: headers, body: dataString } exports.livescore = async () => { try { const results = await got.post(options, {responseType: 'json', resolveBodyOnly: true}); return results.data; } catch (err) { console.log(err.message); } };
  • express - /ego/soccerapi
    Last edited 3 years ago
    const express = require("@runkit/ego/express-app/1.0.0"); const live = require("@runkit/ego/livescore-api/2.0.0"); const app = express(module.exports); const bodyParser = require('body-parser'); var jwt = require('express-jwt'); var jwks = require('jwks-rsa'); app.set('json spaces', 4); app.use(require('compression')()) app.use(bodyParser.json()); var jwtCheck = jwt({ secret: jwks.expressJwtSecret({ cache: true, rateLimit: true, jwksRequestsPerMinute: 90, jwksUri: process.env.JWKS_URI }), audience: process.env.JWKS_AUDIENCE, issuer: process.env.JWKS_ISSUER, algorithms: ['RS256'] }); app.use(jwtCheck); app.use(function (err, req, res, next) { if (err.name === 'UnauthorizedError') { res.status(401).json({"result":{"type":"error","messages":"'Invalid token, or no token supplied!'"}}); } else { res.status(401).send(err); } });
  • ifttt - /ego/ifttt
    Last edited 3 years ago
    const axios = require("axios"); const cheerio = require('cheerio'); var bodyParser = require('body-parser'); const cors = require('cors'); const express = require("@runkit/ego/express-app/1.0.0") const app = express(module.exports); var syncRequest = require('sync-request'); const qs = require('qs'); var mongoose = require('mongoose') //var ress = syncRequest('GET', 'https://channelmyanmar.org/?p=39919').getBody('utf8'); //var xxx = syncRequest('GET', 'https://channelmyanmar.org/wp-json/wp/v2/posts', {json:true}).getBody('utf8') app.set('json spaces', 2); app.use(require('compression')()) app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); // add CORS headers, so the API is available anywhere app.use(function(req, res, next){ res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Expose-Headers", "runkit-rate-limit-remaining"); res.header("Access-Control-Expose-Headers", "tonic-rate-limit-remaining"); var reqHeaders = req.get("Access-Control-Request-Headers") if (reqHeaders) res.header("Access-Control-Allow-Headers", reqHeaders); var reqMethods = req.get("Access-Control-Request-Methods") if (reqMethods) res.header("Access-Control-Allow-Methods", reqMethods); next() }); var Schema = mongoose.Schema const noteSchema = new Schema({ title: String, post: String, type : [], image : String, youtube : String, rate: String, director: String, actors : [], info :[] }); const Note = mongoose.model('Note', noteSchema); var mongoUrl = 'mongodb://ego:password123@ds253017.mlab.com:53017/gcmovie'; mongoose.connect(mongoUrl , { useNewUrlParser: true , useUnifiedTopology: true}); // i hate console.log() so i use print() function print ( l ) { return console.log(l); }; function buildTitle(input) { return input.replace(/[^\w\s]|[0-9]/gi, ''); }; const fetchData = async () => { const result = await axios.get(siteUrl); return cheerio.load(result.data); }; // const fetchCm = async () => { const result = await axios.get('https://channelmyanmar.org/movies'); return cheerio.load(result.data); }; fetchCMM = async () => { const result = await axios.get('https://jsonplaceholder.typicode.com/posts/1'); return result; }; let fetchJson = await fetchCMM(); console.log(fetchJson); const fetchUrl = async (furl) => { const result = await axios.get(furl); return cheerio.load(result.data); };
  • bobotv - /ego/bobotv
    Last edited 3 years ago
    var request = require('request'); var moment = require('moment'); const got = require('got'); var _ = require('lodash'); var bodyParser = require('body-parser'); // let dayT = moment(1602669600).format('LT'); // log(dayT); var headers = { 'Host': 'api.bobo88.tv', 'Content-Type': 'application/json', 'Connection': 'keep-alive', 'Accept': '*/*', 'User-Agent': 'bobotv/1.1 (iPhone; iOS 14.0; Scale/3.00)', 'Accept-Language': 'en-MM;q=1, my-MM;q=0.9', 'Content-Length': '109', 'Accept-Encoding': 'gzip, deflate, br' }; var dataString = '{"league_id":0,"enc":"61461eeea24228a39cd20b1c729c58fc","lang":0,"time":1600601458,"category_id":1,"index":0}'; var options = { url: 'https://api.bobo88.tv/getLive', method: 'POST', headers: headers, body: dataString }; const response = await got.post(options, {responseType: 'json', resolveBodyOnly: true}); log(response.data.lives);
  • express-app - /ego/express-app
    Last edited 4 years ago
    https://runkit.io/runkit/json-endpoint-example-1/branches/master?url=http://google.com
  • JSON Endpoint Example 2 - /ego/x
    Last edited 4 years ago
    Send a request like ?url=http://google.com, get back the title of the page.
  • runkit - /ego/runkit
    Last edited 4 years ago
    Send a request to a URL like https://runkit.io/runkit/json-endpoint-example-1/branches/master?url=http://google.com, get back the title of the page in the url query parameter.
  • Drhmonegyi - /ego/drhmonegyi
    Last edited 5 years ago
    var request = require('sync-request'), cheerio = require('cheerio'), post = {}; var objs = {}; var tonicExpress = require("@runkit/runkit/express-endpoint/1.0.0") var bodyParser = require('body-parser'); var app = tonicExpress(module.exports) app.use(bodyParser.urlencoded({ extended: false })); app.use(function (req, res, next) { // Website you wish to allow to connect res.setHeader('Access-Control-Allow-Origin', 'https://cdpn.io'); // Request methods you wish to allow res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); // Request headers you wish to allow res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); // Set to true if you need the website to include cookies in the requests sent // to the API (e.g. in case you use sessions) res.setHeader('Access-Control-Allow-Credentials', true); // Pass to next layer of middleware next(); }); app.get("/", (req, res) => res.send(all()) ) app.get("/hmone/:name", (req, res) => { var link = req.params.name; var end = posts(link) // var end = "https://universal-bypass.org/before-navigate?target="+encodeURIComponent(link) res.send(end); }); const all = () => { var get = request('GET','https://drhmonegyi.net/wp-json/wp/v2/posts/').getBody('utf8'); var data = JSON.parse(get); // data.map(obj =>{ // // rObj[obj.key] = obj.value; // objs.id = obj.id; // objs.title = obj.title.rendered; // return obj; // }); return data; }; all(); const posts = (id) => { var get = request('GET','https://drhmonegyi.net/wp-json/wp/v2/posts/'+id).getBody('utf8'); var data = JSON.parse(get); var url = data.content.rendered; var $= cheerio.load(url); var init = $('a'); var link = []; var title = data.title.rendered; init.map(function(i, el) { var urls = $(this).prop('href'); var n = urls.includes("mm96channels"); if(n){ post.postTitle = title; post.downloadUrl = urls; post.postUrl= $('a').attr('href'); post.postImage= $('img').attr('src') } }) return post console.log(post) }
  • Untitled - /ego/soccer
    Last edited 5 years ago
    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>Soccer Betting API project</h1><p>All Soccer Matches <a href="https://soccer-jbfpjup0bgpc.runkit.sh/match" target="_blank">Matches</a>. </p><br><p>getMatchDetail <a href="https://soccer-jbfpjup0bgpc.runkit.sh/match/1732936" target="_blank">Matches exampleId :1732936</a>.</p>' res.send(text) }) app.get('/match/:id', (req, res) => { var ids = req.params.id; var getMatch = { id: ids, _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(getMatch), "method":"POST", "mode":"cors" }).then(response => JSON.parse(response)) .then(data => res.send(data.result)) .catch(error => console.error('Error:', error)); }); app.get('/match', (req, res) => { 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(data => res.send(data.result)) .catch(error => console.error('Error:', error)); }); /** LISTEN **/ app.listen(port) console.log(`Listening on: ${port}`)