2020-08-21 10:32:43 +00:00
|
|
|
import requests, gi
|
|
|
|
gi.require_version('Gtk', '3.0')
|
|
|
|
from gi.repository import Gtk, Gio, Gdk
|
|
|
|
|
|
|
|
import re
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
def get_exchange_rate():
|
|
|
|
try:
|
|
|
|
assert False
|
|
|
|
return requests.get("https://api.exchangeratesapi.io/latest?base=AUD&symbols=JPY", timeout=10).json()['rates']['JPY']
|
|
|
|
except:
|
2020-08-22 09:33:31 +00:00
|
|
|
return 75.73
|
2020-08-21 10:32:43 +00:00
|
|
|
|
2020-08-22 09:26:09 +00:00
|
|
|
def id_from_url(url: str):
|
|
|
|
try:
|
|
|
|
url = re.match(r"([^?]+)", url.rstrip("/")).group(1) # remove trailing slashes and query params
|
|
|
|
except:
|
|
|
|
# ???
|
|
|
|
raise
|
|
|
|
id = re.match(r".+\/(.+?)$", url).group(1) # extract "x12345" from "https://buyee.jp/whatever/blah/x12345"
|
|
|
|
|
|
|
|
return id
|
|
|
|
|
2020-08-21 10:32:43 +00:00
|
|
|
def rmatch(pattern, string):
|
|
|
|
return re.match(pattern, string) != None
|