Skip to content

Instantly share code, notes, and snippets.

@lazka
Created April 5, 2019 06:06
Show Gist options
  • Save lazka/0c8fe9616aeb861de5f930d12dae024d to your computer and use it in GitHub Desktop.
Save lazka/0c8fe9616aeb861de5f930d12dae024d to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
from concurrent.futures import ThreadPoolExecutor
URL = "https://stats.lineageos.org/"
mapping = {}
r = requests.get("https://wiki.lineageos.org/devices/")
soup = BeautifulSoup(r.text, 'html.parser')
for link in soup.select("th a", href=True):
if link["href"].startswith("/devices/"):
name = link["href"].rsplit("/")[-1]
company = link.parent.parent.parent.previous.previous
mapping[name] = (company, link.get_text())
r = requests.get(URL)
soup = BeautifulSoup(r.text, 'html.parser')
top_devices = soup.find(id="top-devices")
devices = {}
for row in top_devices.find_all("div", class_="leaderboard-row"):
name = row.find_all(class_="leaderboard-left")[0].get_text().split(" ", 1)[-1]
count = int(row.find_all(class_="leaderboard-right")[0].get_text())
devices[name] = count
def get_version(device_name):
dev_url = "https://stats.lineageos.org/model/%s" % device_name
r = requests.get(dev_url)
soup = BeautifulSoup(r.text, 'html.parser')
versions = {}
for row in soup.find_all(class_="leaderboard-row"):
tag = row.find_all(class_="leaderboard-left")[0]
count = int(row.find_all(class_="leaderboard-right")[0].get_text())
temp = tag.get_text().split(" ", 1)[-1]
official = True
if "NIGHTLY" not in temp:
official = False
try:
if "." not in temp:
raise ValueError
version = int(temp.split(".")[0])
if version < 7:
raise ValueError
except ValueError:
continue
if not official:
version = "(%2d)" % version
else:
version = " %2d " % version
if version not in versions:
versions[version] = count
else:
versions[version] += count
TOP_NUM = 7
temp = sorted(versions.items(), key=lambda i: i[1], reverse=True)[:TOP_NUM]
return (device_name, " ".join([i[0] for i in temp]))
with ThreadPoolExecutor(max_workers=5) as executor:
for device, version in executor.map(get_version, devices.keys()):
if not version:
continue
if device in mapping:
company, name = mapping[device]
else:
company, name = ("???", device)
print("%-6d | %-15s | %-35s | %-35s | %s" % (devices[device], company[:15], name[:35], version, "https://wiki.lineageos.org/devices/" + device))
118642 | Xiaomi | Mi 3 / Mi 4 | (14) 14 (16) (15) (13) 13 | https://wiki.lineageos.org/devices/cancro
54418 | OnePlus | OnePlus One | 15 14 (14) 16 (16) (15) (13) | https://wiki.lineageos.org/devices/bacon
49800 | ??? | riva | (14) (16) (15) 15 | https://wiki.lineageos.org/devices/riva
42759 | Samsung | Galaxy S5 LTE (G900AZ/F/M/R4/R7/T/V | 15 14 (16) 16 (14) (15) (13) | https://wiki.lineageos.org/devices/klte
40690 | Samsung | Galaxy S III (International) | 14 (15) (16) (14) (13) (17) | https://wiki.lineageos.org/devices/i9300
33960 | Google | Nexus 5 | 14 (14) (15) 15 (16) (13) | https://wiki.lineageos.org/devices/hammerhead
33530 | Xiaomi | Redmi Note 4 | 15 (16) (15) 14 (14) (13) 13 | https://wiki.lineageos.org/devices/mido
29845 | Motorola | Moto G 2015 | 14 (15) (16) (14) (13) | https://wiki.lineageos.org/devices/osprey
24954 | ??? | x620 | (13) | https://wiki.lineageos.org/devices/x620
22889 | Motorola | Moto G 2014 | 14 (16) (15) (14) (13) 15 | https://wiki.lineageos.org/devices/titan
20845 | Motorola | Moto G | 14 (16) (14) (15) (13) 7 | https://wiki.lineageos.org/devices/falcon
18999 | Samsung | Galaxy Note 2 (LTE) | (14) 14 | https://wiki.lineageos.org/devices/t0lte
18237 | Xiaomi | Redmi 4(X) | 15 (14) (16) (15) (13) 7 | https://wiki.lineageos.org/devices/santoni
18164 | Xiaomi | Poco F1 | (16) 16 (15) | https://wiki.lineageos.org/devices/beryllium
17454 | ??? | santos10wifi | (14) | https://wiki.lineageos.org/devices/santos10wifi
17351 | Samsung | Galaxy S4 (GT-I9505/G, SGH-M919) | 14 (15) (14) (13) (16) | https://wiki.lineageos.org/devices/jfltexx
16412 | Samsung | Galaxy Note 3 LTE (N9005/P) | 14 (15) (16) (14) | https://wiki.lineageos.org/devices/hlte
16141 | Samsung | Galaxy S6 | (16) (15) 14 (14) (13) | https://wiki.lineageos.org/devices/zerofltexx
15892 | ??? | rpi3 | (15) (14) (16) | https://wiki.lineageos.org/devices/rpi3
15741 | Motorola | Moto G4 | 14 (15) (14) (16) (13) ( 7) | https://wiki.lineageos.org/devices/athene
14858 | Wingtech | Redmi 2 | 14 15 (14) (13) (15) (16) | https://wiki.lineageos.org/devices/wt88047
14510 | HTC | One (M8) | 14 (16) (15) (14) | https://wiki.lineageos.org/devices/m8
14164 | OnePlus | OnePlus 3 / 3T | 15 (16) (14) 16 (15) 14 (13) | https://wiki.lineageos.org/devices/oneplus3
14160 | ??? | j7eltexx | (14) (15) (16) (13) | https://wiki.lineageos.org/devices/j7eltexx
14038 | Google | Nexus 7 (Wi-Fi, 2013 version) | 14 (15) (16) (14) (13) | https://wiki.lineageos.org/devices/flo
13663 | OnePlus | OnePlus 2 | 15 14 (16) 16 (15) (14) (13) | https://wiki.lineageos.org/devices/oneplus2
13303 | Samsung | Galaxy S7 | (16) (15) 14 (14) | https://wiki.lineageos.org/devices/herolte
12869 | Samsung | Galaxy S4 Mini (International LTE) | 14 (16) (15) (14) 13 | https://wiki.lineageos.org/devices/serranoltexx
12733 | Samsung | Galaxy Tab 2 7.0 / Tab 2 10.1 (Wi-F | 13 (13) (14) | https://wiki.lineageos.org/devices/espressowifi
12680 | LeEco | Le Max2 | 15 14 (16) 16 (15) (14) 13 | https://wiki.lineageos.org/devices/x2
12318 | Xiaomi | Mi 4c | 14 (14) (15) (16) 15 ( 7) (13) | https://wiki.lineageos.org/devices/libra
12125 | Xiaomi | Redmi Note 3 | 14 (14) (13) (16) (15) 15 7 | https://wiki.lineageos.org/devices/kenzo
11329 | Samsung | Galaxy S II | 14 (15) (16) (14) (13) | https://wiki.lineageos.org/devices/i9100
11278 | Xiaomi | Redmi 3/Prime | 14 (15) (14) (16) (13) 7 | https://wiki.lineageos.org/devices/ido
10699 | Samsung | Galaxy S7 Edge | (16) (15) 14 (14) | https://wiki.lineageos.org/devices/hero2lte
10644 | LeEco | Le 2 | 15 14 (16) (13) (15) (14) 13 | https://wiki.lineageos.org/devices/s2
10400 | Motorola | Moto Z2 Force | (15) 15 (16) 16 | https://wiki.lineageos.org/devices/nash
9831 | Google | Nexus 6 | 15 16 14 (14) (15) (16) (13) | https://wiki.lineageos.org/devices/shamu
8906 | Xiaomi | Mi 5 | 15 (16) 14 (15) (14) (13) 13 | https://wiki.lineageos.org/devices/gemini
8815 | Motorola | Photon Q 4G LTE | (14) 14 13 (13) | https://wiki.lineageos.org/devices/xt897
8774 | Google | Nexus 4 | 15 14 (15) (13) (16) (14) | https://wiki.lineageos.org/devices/mako
8453 | Huawei | Honor 5X | 14 15 (16) (15) (14) (13) 16 | https://wiki.lineageos.org/devices/kiwi
8149 | Motorola | Moto G4 Play | 14 (15) (16) (14) (13) | https://wiki.lineageos.org/devices/harpia
8127 | LeEco | Le Pro3 / Le Pro3 Elite | 15 (16) 14 16 (15) (13) (14) | https://wiki.lineageos.org/devices/zl1
7825 | Samsung | Galaxy Tab 2 7.0 / Tab 2 10.1 (GSM) | 13 (14) (13) | https://wiki.lineageos.org/devices/espresso3g
7746 | Xiaomi | Redmi 3S/3X | 15 14 (14) (16) (15) (13) | https://wiki.lineageos.org/devices/land
7659 | Lenovo | Vibe K5 / K5 Plus | (14) (16) 14 (15) (13) 15 | https://wiki.lineageos.org/devices/A6020
7657 | ??? | android_x86 | (14) | https://wiki.lineageos.org/devices/android_x86
7599 | Xiaomi | Mi A1 | 15 (16) (15) (14) (17) | https://wiki.lineageos.org/devices/tissot
7577 | ??? | n7100 | (14) (15) (16) | https://wiki.lineageos.org/devices/n7100
7369 | ??? | trlte | (15) (16) (14) | https://wiki.lineageos.org/devices/trlte
7335 | ??? | hermes | (13) (14) (15) | https://wiki.lineageos.org/devices/hermes
7317 | ??? | santos103g | (14) (13) | https://wiki.lineageos.org/devices/santos103g
7205 | ??? | i9082 | (14) (13) | https://wiki.lineageos.org/devices/i9082
7203 | ??? | mocha | (14) (15) (13) | https://wiki.lineageos.org/devices/mocha
7139 | Xiaomi | Redmi Note 5 Pro | 15 (16) (15) (14) | https://wiki.lineageos.org/devices/whyred
7098 | OnePlus | OnePlus X | 14 (16) (15) (14) (13) | https://wiki.lineageos.org/devices/onyx
6962 | Google | Nexus 5X | 15 (15) 14 (14) (13) (16) | https://wiki.lineageos.org/devices/bullhead
6861 | ??? | grouper | (14) | https://wiki.lineageos.org/devices/grouper
6655 | ??? | grandprimeve3g | (14) (15) (13) | https://wiki.lineageos.org/devices/grandprimeve3g
6592 | LG | G3 (International) | 14 (16) 15 (15) (14) (13) | https://wiki.lineageos.org/devices/d855
6502 | ??? | j3xnlte | (14) (13) | https://wiki.lineageos.org/devices/j3xnlte
6436 | Motorola | Moto E | 14 (15) (14) (13) | https://wiki.lineageos.org/devices/condor
6345 | Motorola | Moto E 2015 LTE | 14 (16) (15) (14) (13) | https://wiki.lineageos.org/devices/surnia
6339 | ??? | jflte | (15) | https://wiki.lineageos.org/devices/jflte
6268 | LG | G2 (International) | 15 14 (16) (15) (14) (13) | https://wiki.lineageos.org/devices/d802
6265 | ZUK | Z1 | 15 14 (16) 16 (13) (15) (14) | https://wiki.lineageos.org/devices/ham
6004 | ??? | rolex | (14) (15) (16) (13) | https://wiki.lineageos.org/devices/rolex
5977 | ??? | golden | (14) (13) (15) (12) | https://wiki.lineageos.org/devices/golden
5957 | ??? | android_x86_64 | (14) | https://wiki.lineageos.org/devices/android_x86_64
5936 | ??? | fortuna3g | (14) (13) 16 15 (15) ( 7) | https://wiki.lineageos.org/devices/fortuna3g
5832 | Motorola | Moto X 2014 | 14 (15) (14) (13) ( 7) | https://wiki.lineageos.org/devices/victara
5783 | Motorola | Moto X Play | 14 (15) (14) (16) | https://wiki.lineageos.org/devices/lux
5717 | ??? | fortunave3g | (15) (13) (14) 16 15 14 | https://wiki.lineageos.org/devices/fortunave3g
5680 | Samsung | Galaxy Note 3 (International 3G) | 14 (14) (13) (15) | https://wiki.lineageos.org/devices/ha3g
5680 | Xiaomi | Mi 5s | 15 (16) 14 (14) (15) (13) 16 | https://wiki.lineageos.org/devices/capricorn
5656 | ??? | n7000 | (14) (15) (13) | https://wiki.lineageos.org/devices/n7000
5639 | Google | Nexus 6P | 15 (16) 14 (15) (14) (13) | https://wiki.lineageos.org/devices/angler
5544 | ??? | on5xelte | (14) | https://wiki.lineageos.org/devices/on5xelte
5532 | ??? | n8000 | (14) 14 | https://wiki.lineageos.org/devices/n8000
5494 | ??? | j5lte | 15 16 14 13 | https://wiki.lineageos.org/devices/j5lte
5361 | ??? | thor | (14) (13) (12) | https://wiki.lineageos.org/devices/thor
5087 | ??? | vince | (16) (15) (14) | https://wiki.lineageos.org/devices/vince
4957 | Samsung | Galaxy Tab Pro 8.4 | (14) 13 (13) | https://wiki.lineageos.org/devices/mondrianwifi
4882 | ??? | a3y17lte | (14) (15) (16) | https://wiki.lineageos.org/devices/a3y17lte
4780 | ??? | z2_plus | (14) (15) (16) (13) | https://wiki.lineageos.org/devices/z2_plus
4675 | ??? | rosy | (15) (16) (14) | https://wiki.lineageos.org/devices/rosy
4552 | ZTE | AT&T Trek 2 HD | (14) 14 (16) (15) | https://wiki.lineageos.org/devices/jasmine
4546 | Motorola | Moto G 4G | 14 (16) (14) (13) | https://wiki.lineageos.org/devices/peregrine
4519 | ??? | j5xnlte | (14) (15) 16 15 14 | https://wiki.lineageos.org/devices/j5xnlte
4516 | Samsung | Galaxy Tab PRO 10.1 | 14 (14) (13) | https://wiki.lineageos.org/devices/n2awifi
4383 | ??? | karate | (15) (14) (16) (13) | https://wiki.lineageos.org/devices/karate
4288 | ??? | kminilte | (14) (16) (15) (13) (12) | https://wiki.lineageos.org/devices/kminilte
4254 | Xiaomi | Mi 6 | 15 (16) (14) (15) (13) | https://wiki.lineageos.org/devices/sagit
4173 | HTC | 10 | (16) 14 (15) (14) | https://wiki.lineageos.org/devices/pme
4070 | Google | Nexus 9 (Wi-Fi) | 14 (15) (14) (16) (13) | https://wiki.lineageos.org/devices/flounder
4033 | ??? | j3xlte | (14) | https://wiki.lineageos.org/devices/j3xlte
4011 | Motorola | Moto G 2014 LTE | 14 (15) (13) (14) | https://wiki.lineageos.org/devices/thea
3923 | Samsung | Galaxy Tab S 10.5 Wi-Fi | 14 (14) (15) | https://wiki.lineageos.org/devices/chagallwifi
3880 | Nvidia | Shield Tablet | 14 (14) (15) 13 (13) | https://wiki.lineageos.org/devices/shieldtablet
3861 | Samsung | Galaxy S4 Mini (International Dual | 14 (16) (15) (14) (13) | https://wiki.lineageos.org/devices/serranodsdd
3823 | ??? | ja3gxx | (14) | https://wiki.lineageos.org/devices/ja3gxx
3734 | OnePlus | OnePlus 5T | 15 (16) 16 (15) (14) | https://wiki.lineageos.org/devices/dumpling
3719 | Asus | Zenfone 2 (1080p) | 14 (14) (15) (13) | https://wiki.lineageos.org/devices/Z00A
3706 | ??? | cedric | (14) (15) (16) | https://wiki.lineageos.org/devices/cedric
3655 | ??? | gtel3g | (14) | https://wiki.lineageos.org/devices/gtel3g
3634 | ??? | n8013 | (14) 14 | https://wiki.lineageos.org/devices/n8013
3601 | ZTE | Axon 7 | 15 (16) (15) 14 (14) | https://wiki.lineageos.org/devices/axon7
3590 | ??? | on7xelte | (15) (16) (14) | https://wiki.lineageos.org/devices/on7xelte
3578 | ??? | ugglite | (14) (15) 14 | https://wiki.lineageos.org/devices/ugglite
3538 | Lenovo | P2 | 15 (16) (14) 14 (15) | https://wiki.lineageos.org/devices/kuntao
3451 | ??? | jfvelte | (14) (15) (13) | https://wiki.lineageos.org/devices/jfvelte
3436 | Asus | Zenfone 2 Laser (720p) | 14 (16) 15 (15) (13) (14) | https://wiki.lineageos.org/devices/Z00L
3413 | Xiaomi | Redmi 1S | 14 (15) (13) (14) (16) 7 | https://wiki.lineageos.org/devices/armani
3405 | ??? | ks01ltexx | (15) (16) (14) (13) 14 | https://wiki.lineageos.org/devices/ks01ltexx
3362 | Google | Nexus 10 | (15) 13 (16) (14) (13) | https://wiki.lineageos.org/devices/manta
3328 | Samsung | Galaxy S5 LTE (G900I/P) | 15 14 (16) 16 (14) (15) (13) | https://wiki.lineageos.org/devices/kltedv
3322 | ??? | j7velte | (14) (15) (16) | https://wiki.lineageos.org/devices/j7velte
3302 | ??? | potter | (16) (15) (14) | https://wiki.lineageos.org/devices/potter
3300 | Samsung | Galaxy Note 3 LTE (N900T/V/W8) | 14 (15) (16) (14) | https://wiki.lineageos.org/devices/hltetmo
3277 | ??? | s3ve3g | (14) (15) (13) | https://wiki.lineageos.org/devices/s3ve3g
3257 | Xiaomi | Mi MIX 2 | 15 (16) (15) (14) | https://wiki.lineageos.org/devices/chiron
3240 | LG | G Pad 8.3 | 14 (14) | https://wiki.lineageos.org/devices/v500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment