apkmirror-client
Advanced tools
Comparing version 0.0.1 to 0.1.0
{ | ||
"name": "apkmirror-client", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Client to download APKs from Apkmirror", | ||
@@ -35,3 +35,17 @@ "main": "index.js", | ||
"dirty-chai": "^2.0.1" | ||
} | ||
}, | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/mkg20001/apkmirror-client.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/mkg20001/apkmirror-client/issues" | ||
}, | ||
"homepage": "https://github.com/mkg20001/apkmirror-client#readme", | ||
"contributors": [ | ||
"mkg20001 <mkg20001@gmail.com>" | ||
] | ||
} |
@@ -9,2 +9,3 @@ 'use strict' | ||
const log = debug('apkmirror-client:get') | ||
const PARSER = require('./parser') | ||
@@ -25,19 +26,11 @@ let q = global.APKMIRROR_QUEUE | ||
JSDOM.fromURL(url, { | ||
scripts: [], | ||
// userAgent:"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)", | ||
resourceLoader: function (resource, callback) { | ||
// var pathname = resource.url.pathname; | ||
console.log('[%s] => %s', url, resource.url) | ||
return resource.defaultFetch(callback) | ||
} | ||
scripts: [] | ||
// userAgent:"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" | ||
}).then(dom => { | ||
const {window} = dom | ||
var $ = jquery(window) | ||
if (!PARSER[opt.parser]) return cb(new Error('Parser ' + opt.parser + ' is unknown!')) | ||
try { | ||
require('./parser/' + opt.parser)($, window, cb, (err, res) => { | ||
if (err) console.error('Crawler Error: %s', err.toString()) | ||
return cb(err, res) | ||
}) | ||
PARSER[opt.parser]($, window, (...a) => setImmediate(() => cb(...a))) // eslint-disable-line standard/no-callback-literal | ||
} catch (err) { | ||
console.error('Crawler Error: %s', err.toString()) | ||
return cb(err) | ||
@@ -44,0 +37,0 @@ } |
'use strict' | ||
const get = require('./get') | ||
const request = require('request') | ||
const debug = require('debug') | ||
const log = debug('apkmirror-client') | ||
module.exports = { | ||
searchForApps: (query, cb) => | ||
get('https://www.apkmirror.com/?post_type=app_release&searchtype=app&s=' + encodeURI(query), {parser: 'app-search'}, cb) | ||
get('https://www.apkmirror.com/?post_type=app_release&searchtype=app&s=' + encodeURI(query), {parser: 'appSearch'}, cb), | ||
getAppPage: (app, cb) => | ||
get(app.app ? app.app.url : app, {parser: 'appPage'}, cb), | ||
getReleasePage: (app, cb) => | ||
get(app, {parser: 'appReleasePage'}, cb), | ||
appVariantPage: (app, cb) => | ||
get(app, {parser: 'appVariantPage'}, cb), | ||
estimateBestCandidate: (list, arch) => { | ||
const orig = list | ||
if (arch === 'x86_64') arch = ['x64'] | ||
if (arch === 'arm64') arch = ['arm64', 'arm'] | ||
if (!Array.isArray(arch)) arch = [arch] | ||
list = list.filter(r => arch.indexOf(r.arch) !== -1) // only ones that have the right arch | ||
list = list.map(r => Object.assign({}, r)).map(r => { | ||
r.date = new Date(r.date) | ||
r.arch_i = arch.indexOf(r.arch) | ||
return r | ||
}) | ||
/* | ||
Rating: | ||
- Arch index: Lower => Better | ||
- Date: Higher => Better | ||
- Id: Higher => Better | ||
- Target Android Version: Lower => Better | ||
- DPI: Highest DPI => Better, nodpi => Best | ||
*/ | ||
function comp (a, b, r) { | ||
if (r) { | ||
if (a > b) return -1 | ||
if (a < b) return 1 | ||
} | ||
if (a < b) return -1 | ||
if (a > b) return 1 | ||
return 0 | ||
} | ||
list.sort((a, b) => { | ||
if (comp(a.arch_i, b.arch_i, true)) return comp(a.arch_i, b.arch_i, true) // first get the fastest arch | ||
if (comp(a.androidVer, b.androidVer, true)) return comp(a.androidVer, b.androidVer, true) // get the apk with lowest required version | ||
if (comp(a.date, b.date)) return comp(a.date, b.date) // newest apk | ||
return 0 | ||
}) | ||
const res = list.pop() | ||
return res ? orig.filter(i => i.id === res.id)[0] : false | ||
}, | ||
downloadAPK: (url, cb) => { | ||
get(url, {parser: 'appDownloadPage'}, (err, url) => { | ||
if (err) return cb(err) | ||
log('download apk from %s', url) | ||
cb(null, request.get(url)) | ||
}) | ||
} | ||
} | ||
const get = require('./get') |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
15174
15
368
1
1
1
1