|
|
@@ -10,6 +10,7 @@ import requests |
|
|
|
import re |
|
|
|
import urllib |
|
|
|
import random |
|
|
|
import pycountry |
|
|
|
from . import ops |
|
|
|
|
|
|
|
# get config variables from OS environment variables: set in env file passed through Docker Compose |
|
|
@@ -93,6 +94,15 @@ def parse_result(id, input): |
|
|
|
year = re.search('=D[^\s]*\s[^\s]*\s[^\s]*\s[^\s]*\s(\d{4})', input) |
|
|
|
if year is not None: |
|
|
|
output['year'] = year.group(1) |
|
|
|
|
|
|
|
# search for the country in the content element and display it |
|
|
|
country_code = re.search('FT=D[^\s]*\s(\w{2})', input) |
|
|
|
country = pycountry.countries.get(alpha_2=country_code.group(1)) |
|
|
|
if country is None: |
|
|
|
country = pycountry.historic_countries.get(alpha_2=country_code.group(1)) |
|
|
|
if country is not None: |
|
|
|
output['country'] = country |
|
|
|
|
|
|
|
return output |
|
|
|
|
|
|
|
def get_random_record(core): |