async function processAndRecur (html, opts, savedApps, mappings) { if (R.is(String, html)) { html = scriptData.parse(html); } const processedApps = appList.extract(mappings.apps, html); const apps = opts.fullDetail ? await processFullDetailApps(processedApps, opts) : processedApps; const token = R.path(mappings.token, html); return checkFinished(opts, [...savedApps, ...apps], token); }
function getParsedCluster (developerObject) { const clusterUrl = R.path(INITIAL_MAPPINGS.cluster, developerObject); return clusterUrl; }
/** * This method looks for the mapping inside the serviceRequestData object * The serviceRequestData object is mapped from the AF_dataServiceRequests html var * * @param {object} parsedData The response mapped object * @param {object} spec The mappings spec */ function extractDataWithServiceRequestId (parsedData, spec) { const serviceRequestMapping = Object.keys(parsedData.serviceRequestData); const filteredDsRootPath = serviceRequestMapping.filter(serviceRequest => { const dsValues = parsedData.serviceRequestData[serviceRequest]; return dsValues.id === spec.useServiceRequestId; }); const formattedPath = (filteredDsRootPath.length) ? [filteredDsRootPath[0], ...spec.path] : spec.path; return R.path(formattedPath, parsedData); }
async function processReviewsAndGetNextPage (html, opts, savedReviews) { const processAndRecurOptions = Object.assign({}, opts, { requestType: REQUEST_TYPE.paginated }); const { appId, paginate, num } = processAndRecurOptions; const parsedHtml = R.is(String, html) ? scriptData.parse(html) : html; if (parsedHtml.length === 0) { return formatReviewsResponse({ reviews: savedReviews, token: null, num }); } // PROCESS REVIEWS EXTRACTION const reviews = reviewsList.extract(REQUEST_MAPPINGS.reviews, parsedHtml, appId); const token = R.path(REQUEST_MAPPINGS.token, parsedHtml); const reviewsAccumulator = [...savedReviews, ...reviews]; return (!paginate && token && reviewsAccumulator.length < num) ? makeReviewsRequest(processAndRecurOptions, reviewsAccumulator, token) : formatReviewsResponse({ reviews: reviewsAccumulator, token, num }); }
/* * Apply MAPPINGS for each application in list from root path */ function extract (root, data, appId) { const input = R.path(root, data); const MAPPINGS = getReviewsMappings(appId); return R.map(scriptData.extractor(MAPPINGS), input); }
/* * Extract navigation tokens for next pages, parse results and call * `checkFinished` to repeat the process with next page if necessary. */ function processAndRecur (html, opts, savedApps, mappings) { if (R.is(String, html)) { html = scriptData.parse(html); } const apps = appList.extract(mappings.apps, html); const token = R.path(mappings.token, html); return checkFinished(opts, [...savedApps, ...apps], token); }
/** * Map the MAPPINGS object, applying each field spec to the parsed data. * If the mapping value is an array, use it as the path to the extract the * field's value. If it's an object, extract the value in object.path and pass * it to the function in object.fun * * @param {array} mappings The mappings object */ function extractor (mappings) { return function extractFields (parsedData) { debug('parsedData: %o', parsedData); return R.map((spec) => { if (R.is(Array, spec)) { return R.path(spec, parsedData); } // extractDataWithServiceRequestId explanation: // https://github.com/facundoolano/google-play-scraper/pull/412 // assume spec object const input = (spec.useServiceRequestId) ? extractDataWithServiceRequestId(parsedData, spec) : R.path(spec.path, parsedData); return spec.fun(input, parsedData); }, mappings); }; }
const allCollections = R.path(INITIAL_MAPPINGS.collections, categoryObject); debug('allCollections: %o', allCollections); if (!allCollections) { const selectedCollection = R.path([allCollections.length, collection], collectionMapping); debug('selectedCollection: %o', selectedCollection); const categoryClusterURL = R.path(COLLECTION_CLUSTER_URL_MAPPINGS, allCollections);
/* * Apply MAPPINGS for each application in list from root path */ function extract (root, data) { const input = R.path(root, data); if (input === undefined) return []; return R.map(scriptData.extractor(MAPPINGS), input); }
function extract (root, data, type) { const input = R.path(root, data); if (typeof input === 'undefined') { return []; } const MAPPINGS = getPermissionMappings(type); return R.map(scriptData.extractor(MAPPINGS), input); }
R.prop('transactions'), R.map(R.pipe( R.path(['data', 'inputs']), R.contains({ transaction: txInput.transaction, index: txInput.index }) ))
pipe( path(['data', 'result']), (result) => formStore.set('value', {...result}) )
curry(useWith( (newValue, target) => checkValueThenSetToResult('categoryCode')(newValue, target), [ path(['category', 'key']) ] ))
function handleError (error) { const amioErrors = path(['response', 'data', 'errors'], error); if(is(Array, amioErrors)) throw new AmioApiError(error.response.data) throw error }
async function processAndRecur (html, opts, savedApps, mappings) { if (R.is(String, html)) { html = scriptData.parse(html); } const processedApps = appList.extract(mappings.apps, html); const apps = opts.fullDetail ? await processFullDetailApps(processedApps, opts) : processedApps; const token = R.path(mappings.token, html); return checkFinished(opts, [...savedApps, ...apps], token); }