Just some stuff about me.
Here's my dotfiles repository.
What links here:
I want to figure out which phone to get that’s supported by LineageOS, depending on its features.
Retrieve data:
printf '' > /tmp/devicelist.html
curl -sL https://wiki.lineageos.org/devices/ \
| pup 'div.devices a attr{href}' \
| sed 's!^!https://wiki.lineageos.org!' \
| sort -u \
| while read -r device; do
printf "Processing: %s\n" "$device"
curl -sL "$device" | pup 'table.deviceinfo' >> /tmp/devicelist.html
done
Parse:
require 'nokogiri'
doc = Nokogiri::HTML(File.read('/tmp/devicelist.html'))
def filter_phones doc, release_year
devs = doc.css("table:has(td:contains(' #{release_year}'))")
# I want a minimum of 128 gb
enough_storage = devs.select { |dev| dev.css('th:contains("Storage")+td:contains("128")').length > 0 }
# I also want a card slot
has_card = enough_storage.select { |dev| dev.css('th:contains("SD ")').length > 0 }
models = has_card.map { |dev| dev.css('tbody tr:first-child').text.strip }.map {|s| "- #{s}"}
return models
end
# Latest releases
puts "<details>\n<summary>Current output</summary>"
in2022 = filter_phones doc, 2022
puts "2022:\n#{in2022.join("\n")}" unless in2022.empty?
in2021 = filter_phones doc, 2021
puts "2021:\n#{in2021.join("\n")}" unless in2021.empty?
in2020 = filter_phones doc, 2020
puts "2020:\n#{in2020.join("\n")}" unless in2020.empty?
in2019 = filter_phones doc, 2019
puts "2019:\n#{in2019.join("\n")}" unless in2019.empty?
puts "</details>"
2020:
2019: