Socket
Socket
Sign inDemoInstall

apkmirror-client

Package Overview
Dependencies
96
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.1.0

CHANGELOG.md

18

package.json
{
"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>"
]
}

17

src/get.js

@@ -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')
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc