import requests, io, sys, json
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
H = {'User-Agent': 'Mozilla/5.0'}
pks = ['com.vinfast.companion.app', 'com.vinfast.club', 'vn.vinfast.ecosystem']
# API get theo package
for p in pks:
    try:
        r = requests.get(f'https://ws75.aptoide.com/api/7/app/get/package_name/{p}', headers=H, timeout=20)
        j = r.json()
        node = (j.get('nodes') or {}).get('meta') or {}
        if j.get('isPossible') or node:
            app = node.get('data', {}).get('file', {})
            print(f'[{p}] v{app.get("vername")} size={app.get("filesize")}')
            print('    path:', app.get('path'))
        else:
            print(f'[{p}] not found ({r.status_code})')
    except Exception as e:
        print(f'[{p}] EXC', type(e).__name__, e)
# apkcombo qua DoH resolving
try:
    rd = requests.get('https://cloudflare-dns.com/dns-query?name=apkcombo.com&type=A', headers={'accept': 'application/dns-json'}, timeout=15)
    ans = [a['data'] for a in rd.json().get('Answer', []) if a.get('type') == 1]
    print('[doh] apkcombo.com A:', ans)
except Exception as e:
    print('[doh] EXC', e)
