def showMissingApks(dAllApks, maxVerEachApk): """ showMissingApks(dAllApks): """ appsneeded = [] for k in dAllApks.keys(): thisappsneeded = [] for a in dAllApks[k]: maxApk = ApkVersionInfo(ver = maxVerEachApk[k]) if '2280749' in maxApk.ver: # This excludes 'from factor image' apks maxApk.ver = '0' thisappsneeded = [] if a.ver < maxApk.ver: logging.debug('{0}: {1} < maxApk.ver: {2}'.format(k, a.ver, maxApk.ver)) thisappsneeded.append(a.fullString(maxVerEachApk[k])) if len(thisappsneeded) != 0: appsneeded.extend(thisappsneeded) # END: for k in for a in sorted(appsneeded): logging.info(a)
def getAppVersions(apkInfo): """ getAppVersions(apkInfo): Collect all versions for an applicaiton """ logging.info('Fetching Information for: {0}'.format(apkInfo.apkmirror_name)) html_name = '{0}.html'.format(apkInfo.opengapps_name) url = APKMIRRORBASEURL + APKMIRRORGOOGLEURL2 + apkInfo.url html = Debug.readFromFile(html_name) if html == '': session = requests.Session() logging.debug('Requesting2: ' + url) resp = session.get(url) html = resp.text Debug.writeToFile(html_name, html, resp.encoding) try: dom = BeautifulSoup(html, 'html5lib') latest = dom.findAll('div', {'class': 'latestWidget'})[1] versions = latest.findAll('a', {'class': 'fontBlack'}) dVersions = {} for version in versions: # Ignore duplicate entries (one 'hidden' is shown, # and the other 'visible', is not shown) if 'visible-xs-block' in version.parent['class']: continue verText = '"{0}"'.format(version.get_text().encode('ascii', 'ignore')) if 'beta' in verText.lower() or 'preview' in verText.lower(): logging.info('!!! Beta or Preview Found: ' + verText) else: dVersions[verText] = version['href'] m = apkInfo.reVersion.search(verText) if m: avi = ApkVersionInfo(name=m.group('VERSIONNAME').rstrip('-.'), scrape_url=version['href']) avi.ver = avi.name avi.ver = avi.ver.replace(apkInfo.opengapps_name, '').strip() avi.ver = avi.ver.split(' ')[0] apkInfo.versions.append(avi) else: logging.info('!!! No Matchy: ' + verText) # END: for v in versions: Debug.printDictionary(dVersions) # Determine which versions to download if len(apkInfo.versions) > 0: maxVersionByName = sorted(apkInfo.versions)[-1] logging.debug('Max Version By Name: "{0}"'.format(maxVersionByName.name)) for v in apkInfo.versions: if v.name == maxVersionByName.name: logging.info('Getting Info for: "{0}" ({1})'.format(v.name, v.scrape_url)) getVersionInfo(v) logging.info('Downloading: "{0}"'.format(v.apk_name)) downloadApkFromVersionInfo(v) else: logging.debug('Skipping: "{0}" ({1})'.format(v.name, v.scrape_url)) # END: for v in apkInfo.versions: else: logging.info('No matching APKs found for: {0}'.format(apkInfo.apkmirror_name)) except: logging.exception('!!! Error parsing html from: "{0}"'.format(url)) logging.debug('-'*80)