integrate jq/parse/update functions
This commit is contained in:
parent
5580150e0b
commit
0e229d8c40
2
PKGBUILD
2
PKGBUILD
|
@ -25,5 +25,7 @@ package() {
|
||||||
cd "$srcdir/${pkgname:0:-4}"
|
cd "$srcdir/${pkgname:0:-4}"
|
||||||
install -Dm666 pokeData/* -t "$pkgdir/usr/share/$pkgname/pokeData"
|
install -Dm666 pokeData/* -t "$pkgdir/usr/share/$pkgname/pokeData"
|
||||||
install -Dm666 keybindings-preview -t "$pkgdir/usr/share/$pkgname"
|
install -Dm666 keybindings-preview -t "$pkgdir/usr/share/$pkgname"
|
||||||
|
install -Dm755 pokeParse -t "$pkgdir/usr/bin"
|
||||||
|
install -Dm755 pokeUpdate -t "$pkgdir/usr/bin"
|
||||||
install -Dm755 pokedex-dev -t "$pkgdir/usr/bin"
|
install -Dm755 pokedex-dev -t "$pkgdir/usr/bin"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
block() {
|
|
||||||
./jqPoke "$1" > "./pokeData/$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
export -f block
|
|
||||||
pokemon-colorscripts -l | sort | parallel --bar -j 200 block
|
|
124
pokeInfo
124
pokeInfo
|
@ -1,124 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
import re
|
|
||||||
|
|
||||||
######## Get Pokemon Name ########
|
|
||||||
if len(sys.argv) < 2:
|
|
||||||
pokemon = input("Enter the name of the pokemon to look up: ").title()
|
|
||||||
|
|
||||||
# Two Word Names Like Mime Jr.
|
|
||||||
elif len(sys.argv) == 3:
|
|
||||||
pokemon = (sys.argv[1] + " " + sys.argv[2]).title()
|
|
||||||
|
|
||||||
else:
|
|
||||||
pokemon = sys.argv[1].title()
|
|
||||||
|
|
||||||
if pokemon == "mr-mime":
|
|
||||||
pokemon = "Mr.Mime" #serebii listed this way
|
|
||||||
|
|
||||||
elif pokemon == "ho-oh":
|
|
||||||
pokemon = "Ho-oh" #serebii listed this way
|
|
||||||
|
|
||||||
######## Get Pokedex Entry Number ########
|
|
||||||
begin_url = ["http://serebii.net/pokedex-xy/",
|
|
||||||
"http://serebii.net/pokedex-sv/",
|
|
||||||
"http://serebii.net/pokedex-swsh/",
|
|
||||||
"http://serebii.net/pokedex-sm/",
|
|
||||||
"http://serebii.net/pokedex-bw/",
|
|
||||||
"http://serebii.net/pokedex-dp/",
|
|
||||||
"http://serebii.net/pokedex-rs/",
|
|
||||||
"http://serebii.net/pokedex-gs/",
|
|
||||||
"http://serebii.net/pokedex/"]
|
|
||||||
|
|
||||||
for i in begin_url:
|
|
||||||
try:
|
|
||||||
request1 = requests.get(i)
|
|
||||||
except OSError:
|
|
||||||
sys.exit(1)
|
|
||||||
html1 = request1.content
|
|
||||||
soup1 = BeautifulSoup(html1, "html.parser")
|
|
||||||
page_info1 = soup1.get_text()
|
|
||||||
# Pokedex Entries Start At Index 5000
|
|
||||||
pokemon_index = page_info1.find(pokemon, 5000)
|
|
||||||
if pokemon_index != -1:
|
|
||||||
break
|
|
||||||
|
|
||||||
if pokemon_index == -1:
|
|
||||||
print("You didn't enter a valid pokemon!")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
pokedex_number = page_info1[pokemon_index-4 : pokemon_index-1]
|
|
||||||
|
|
||||||
######## Get Pokemon Info ########
|
|
||||||
for i in begin_url:
|
|
||||||
try:
|
|
||||||
full_url = i + pokedex_number + ".shtml"
|
|
||||||
request2 = requests.get(full_url)
|
|
||||||
except OSError:
|
|
||||||
sys.exit(1)
|
|
||||||
html2 = request2.content
|
|
||||||
soup2 = BeautifulSoup(html2, "html.parser")
|
|
||||||
page_info2 = soup2.get_text()
|
|
||||||
page_not_found = bool(soup2.find(string=re.compile("Page Not Found")))
|
|
||||||
if page_not_found == False:
|
|
||||||
break
|
|
||||||
|
|
||||||
if page_not_found:
|
|
||||||
print(" Stats currently unavailable :( ")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
######## Get Stats ########
|
|
||||||
base_total = soup2.find(string=re.compile("Base Stats - Total:"))
|
|
||||||
# Only want everything after Total
|
|
||||||
base_total = str("Total Unavailable")
|
|
||||||
base_total = base_total[base_total.find("Total"):]
|
|
||||||
base_stats = soup2.find_all(class_="fooinfo")
|
|
||||||
|
|
||||||
hp = str(base_stats[len(base_stats)-21])
|
|
||||||
attack = str(base_stats[len(base_stats)-20])
|
|
||||||
defence = str(base_stats[len(base_stats)-19])
|
|
||||||
spec_attack = str(base_stats[len(base_stats)-18])
|
|
||||||
spec_defence = str(base_stats[len(base_stats)-17])
|
|
||||||
speed = str(base_stats[len(base_stats)-16])
|
|
||||||
|
|
||||||
hp = hp[hp.find(">")+1 : hp.find("/")-1]
|
|
||||||
attack = attack[attack.find(">")+1 : attack.find("/")-1]
|
|
||||||
defence = defence[defence.find(">")+1 : defence.find("/")-1]
|
|
||||||
spec_attack = spec_attack[spec_attack.find(">")+1 : spec_attack.find("/")-1]
|
|
||||||
spec_defence = spec_defence[spec_defence.find(">")+1 : spec_defence.find("/")-1]
|
|
||||||
speed = speed[speed.find(">")+1:speed.find("/")-1]
|
|
||||||
|
|
||||||
######## Get Abilities ########
|
|
||||||
abilities_index = page_info2.find("Abilities:")
|
|
||||||
abilities = page_info2[abilities_index:]
|
|
||||||
end_index = abilities.find("\n")
|
|
||||||
abilities = abilities[:end_index-1]
|
|
||||||
|
|
||||||
######## Get Gender ########
|
|
||||||
gender_index = page_info2.find("GenderType")
|
|
||||||
gender = page_info2[gender_index:]
|
|
||||||
end_index = gender.find("\n")
|
|
||||||
gender = gender[:end_index]
|
|
||||||
gender = gender[gender.find(" ")+1:]
|
|
||||||
if "is Genderless" in gender:
|
|
||||||
gender = "Genderless"
|
|
||||||
|
|
||||||
######## Print everything out ########
|
|
||||||
print("")
|
|
||||||
print("Name: ", pokemon)
|
|
||||||
print("Pokedex Number: ", pokedex_number)
|
|
||||||
print("Gender Ratio: ", str(gender))
|
|
||||||
print(abilities)
|
|
||||||
print("")
|
|
||||||
print("Base Stats")
|
|
||||||
print("----------------------")
|
|
||||||
print(base_total)
|
|
||||||
print("Hp: ", hp)
|
|
||||||
print("Attack: ", attack)
|
|
||||||
print("Defence: ", defence)
|
|
||||||
print("Special Attack: ", spec_attack)
|
|
||||||
print("Special Defence: ", spec_defence)
|
|
||||||
print("Speed: ", speed)
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
DATADIR="/usr/share/fuzzy-pokedex-dev"
|
||||||
|
|
||||||
declare -i WC
|
declare -i WC
|
||||||
WC=$(pokemon-colorscripts -l | wc | awk '{print $1}' )
|
WC=$(pokemon-colorscripts -l | wc | awk '{print $1}' )
|
||||||
|
|
||||||
|
@ -7,7 +9,7 @@ declare -i COUNT
|
||||||
COUNT="$WC"
|
COUNT="$WC"
|
||||||
|
|
||||||
for POKEMON in $(pokemon-colorscripts -l); do
|
for POKEMON in $(pokemon-colorscripts -l); do
|
||||||
./jqPoke "$POKEMON" > "./pokeData/$POKEMON"
|
pokeParse "$POKEMON" > "$DATADIR/$POKEMON"
|
||||||
((COUNT--))
|
((COUNT--))
|
||||||
PCTLEFT="$((COUNT*100/WC))"
|
PCTLEFT="$((COUNT*100/WC))"
|
||||||
PCTDONE="$((100-PCTLEFT))"
|
PCTDONE="$((100-PCTLEFT))"
|
Loading…
Reference in New Issue