Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.startReview = function (config, first_run) {
var appInformation = {};
//scrape Google Play for app information first
playScraper.app({appId: config.appId})
.then(function (appData, error) {
if (error) {
return console.error("ERROR: [" + config.appId + "] Could not scrape Google Play, " + error);
}
appInformation.appName = appData.title;
appInformation.appIcon = appData.icon;
exports.fetchGooglePlayReviews(config, appInformation, function (reviews) {
// If we don't have any published reviews, then treat this as a baseline fetch, we won't post any
// reviews to slack, but new ones from now will be posted
if (first_run) {
var reviewLength = reviews.length;
for (var i = 0; i < reviewLength; i++) {
var initialReview = reviews[i];
itunes.app({
appId: opt.appId,
country: opt.country, // TODO: Support more countries
})
.then((data) => {
setMetrics(store, opt.country, data) // TODO: Support more countries
.then(resolve)
.catch(reject);
})
.catch((err) => {
reject(new Error(`Itunes Scraper error for the app "${opt.appId}" (${opt.country}): ${err.message}`));
});
}
if (store === 'gplay') {
gplay.app({
appId: opt.appId,
country: opt.country, // TODO: Support more countries
})
.then((data) => {
setMetrics(store, opt.country, data) // TODO: Support more countries
.then(resolve)
.catch(reject);
})
.catch((err) => {
reject(new Error(`Google Play Scraper error for the app "${opt.appId}"" (${opt.country}): ${err.message}`));
});
}
});
}
'use strict';
// FIXME don't force memoization
const gplay = require('google-play-scraper').memoized();
const R = require('ramda');
const calc = require('../calc');
const debug = require('debug')('aso');
/*
* An object that holds all store-specific parts of the algorithms exposed by
* the library. This is not the most elegant solution ever, but beats introducing
* hierarchies and inheritance. If these objects grow too big it's probably better
* to break them into more cohessive components, maybe with defaults for the
* common stuff.
*/
const MAX_KEYWORD_LENGTH = 25;
const getCollection = (app) => app.free ? gplay.collection.TOP_FREE : gplay.collection.TOP_PAID;
const getGenre = (app) => app.genreId;
async run ({t, author, channel, language}, country, term) {
channel.startTyping()
console.log(term)
const embed = new SwitchbladeEmbed(author)
const response = await gplay.search({term, country, num: 1, lang: language.substring(0, 1)})
if (response.length > 0) {
const app = response[0]
embed
.setColor(0x518FF5)
.setThumbnail('http://' + app.icon)
.setAuthor('Google Play Store', 'https://i.imgur.com/tkTq2bi.png')
.setDescription([
`**[${app.title}](${app.url})**`,
app.summary,
'',
MiscUtils.ratingToStarEmoji(app.score),
app.priceText
].join('\n'))
} else {
embed
.setColor(Constants.ERROR_COLOR)
router.get('/apps/:appId', function (req, res, next) {
const opts = Object.assign({appId: req.params.appId}, req.query);
gplay.app(opts)
.then(cleanUrls(req))
.then(res.json.bind(res))
.catch(next);
});
const fetchApp = (i, cb) => {
if (i >= apps.length) {
return cb();
} else {
gplay.search({
term: apps[i],
num: 1,
}).then((data, err) => {
if (!err && data && data.length > 0) {
results.push({
color: 0x00FF00,
author: {
name: `By ${data[0].developer}`,
},
thumbnail: {
url: data[0].icon ? `http:${data[0].icon}` : "",
},
title: `__${data[0].title}__`,
url: `${data[0].url}`,
description: `A quick summary: \`\`\`\n${data[0].summary}\`\`\``,
footer: {
router.get('/apps/', function (req, res, next) {
if (!req.query.q) {
return next();
}
const opts = Object.assign({term: req.query.q}, req.query);
gplay.search(opts)
.then((apps) => apps.map(cleanUrls(req)))
.then(toList)
.then(res.json.bind(res))
.catch(next);
});
function reviews() {
var app = APPS[currentIndex];
incrementIndex(APPS.length);
var request = gplay.reviews({
appId: app.package,
page: 0,
sort: gplay.sort.NEWEST
});
return request.then(toRuleResult(app));
}
const subpath = '/apps/' + req.params.appId + '/reviews/';
if (page > 0) {
req.query.page = page - 1;
apps.prev = buildUrl(req, subpath) + '?' + qs.stringify(req.query);
}
if (apps.results.length) {
req.query.page = page + 1;
apps.next = buildUrl(req, subpath) + '?' + qs.stringify(req.query);
}
return apps;
}
const opts = Object.assign({appId: req.params.appId}, req.query);
gplay.reviews(opts)
.then(toList)
.then(paginate)
.then(res.json.bind(res))
.catch(next);
});
router.get('/developers/:devId/', function (req, res, next) {
const opts = Object.assign({devId: req.params.devId}, req.query);
gplay.developer(opts)
.then((apps) => apps.map(cleanUrls(req)))
.then((apps) => ({
devId: req.params.devId,
apps
}))
.then(res.json.bind(res))
.catch(next);
});