Browse Source

[mod] add external_urls.json and wikidata_units.json

Alexandre Flament 4 years ago
parent
commit
ed6696e6bf

+ 4 - 1
searx/data/__init__.py

@@ -2,7 +2,8 @@ import json
 from pathlib import Path
 from pathlib import Path
 
 
 
 
-__init__ = ['ENGINES_LANGUGAGES', 'CURRENCIES', 'USER_AGENTS', 'bangs_loader', 'ahmia_blacklist_loader']
+__init__ = ['ENGINES_LANGUGAGES', 'CURRENCIES', 'USER_AGENTS', 'EXTERNAL_URLS', 'WIKIDATA_UNITS',
+            'bangs_loader', 'ahmia_blacklist_loader']
 data_dir = Path(__file__).parent
 data_dir = Path(__file__).parent
 
 
 
 
@@ -24,3 +25,5 @@ def ahmia_blacklist_loader():
 ENGINES_LANGUAGES = load('engines_languages.json')
 ENGINES_LANGUAGES = load('engines_languages.json')
 CURRENCIES = load('currencies.json')
 CURRENCIES = load('currencies.json')
 USER_AGENTS = load('useragents.json')
 USER_AGENTS = load('useragents.json')
+EXTERNAL_URLS = load('external_urls.json')
+WIKIDATA_UNITS = load('wikidata_units.json')

+ 156 - 0
searx/data/external_urls.json

@@ -0,0 +1,156 @@
+{
+    "facebook_profile": {
+        "category_name": "Facebook",
+        "url_name": "Facebook profile",
+        "urls": {
+            "default": "https://facebook.com/$1"
+        }
+    },
+    "youtube_channel": {
+        "category_name": "YouTube",
+        "url_name": "YouTube channel",
+        "urls": {
+            "default": "https://www.youtube.com/channel/$1"
+        }
+    },
+    "youtube_video": {
+        "category_name": "YouTube",
+        "url_name": "YouTube video",
+        "urls": {
+            "default": "https://www.youtube.com/watch?v=$1"
+        }
+    },
+    "twitter_profile": {
+        "category_name": "Twitter",
+        "url_name": "Twitter profile",
+        "urls": {
+            "default": "https://twitter.com/$1"
+        }
+    },
+    "instagram_profile": {
+        "category_name": "Instagram",
+        "url_name": "Instagram profile",
+        "urls": {
+            "default": "https://www.instagram.com/$1"
+        }
+    },
+    "imdb_title": {
+        "category_name": "IMDB",
+        "url_name": "IMDB title",
+        "urls": {
+            "default": "https://www.imdb.com/title/$1"
+        }
+    },
+    "imdb_name": {
+        "category_name": "IMDB",
+        "url_name": "IMDB name",
+        "urls": {
+            "default": "https://www.imdb.com/name/$1"
+        }
+    },
+    "imdb_character": {
+        "category_name": "IMDB",
+        "url_name": "IMDB character",
+        "urls": {
+            "default": "https://www.imdb.com/character/$1"
+        }
+    },
+    "imdb_company": {
+        "category_name": "IMDB",
+        "url_name": "IMDB company",
+        "urls": {
+            "default": "https://www.imdb.com/company/$1"
+        }
+    },
+    "imdb_event": {
+        "category_name": "IMDB",
+        "url_name": "IMDB event",
+        "urls": {
+            "default": "https://www.imdb.com/event/$1"
+        }
+    },
+    "rotten_tomatoes": {
+        "category_name": "Rotten tomatoes",
+        "url_name": "Rotten tomatoes title",
+        "urls": {
+            "default": "https://www.rottentomatoes.com/$1"
+        }
+    },
+    "spotify_artist_id": {
+        "category_name": "Spotify",
+        "url_name": "Spotify artist",
+        "urls": {
+            "default": "https://open.spotify.com/artist/$1"
+        }
+    },
+    "itunes_artist_id": {
+        "category_name": "iTunes",
+        "url_name": "iTunes artist",
+        "urls": {
+            "default": "https://music.apple.com/us/artist/$1"
+        }
+    },
+    "soundcloud_id": {
+        "category_name": "Soundcloud",
+        "url_name": "Soundcloud artist",
+        "urls": {
+            "default": "https://soundcloud.com/$1"
+        }
+    },
+    "netflix_id": {
+        "category_name": "Netflix",
+        "url_name": "Netflix movie",
+        "urls": {
+            "default": "https://www.netflix.com/watch/$1"
+        }
+    },
+    "github_profile": {
+        "category_name": "Github",
+        "url_name": "Github profile",
+        "urls": {
+            "default": "https://wwww.github.com/$1"
+        }
+    },
+    "musicbrainz_artist": {
+        "category_name": "Musicbrainz",
+        "url_name": "Musicbrainz artist",
+        "urls": {
+            "default": "http://musicbrainz.org/artist/$1"
+        }
+    },
+    "musicbrainz_work": {
+        "category_name": "Musicbrainz",
+        "url_name": "Musicbrainz work",
+        "urls": {
+            "default": "http://musicbrainz.org/work/$1"
+        }
+    },
+    "musicbrainz_release_group": {
+        "category_name": "Musicbrainz",
+        "url_name": "Musicbrainz release group",
+        "urls": {
+            "default": "http://musicbrainz.org/release-group/$1"
+        }
+    },
+    "musicbrainz_label": {
+        "category_name": "Musicbrainz",
+        "url_name": "Musicbrainz label",
+        "urls": {
+            "default": "http://musicbrainz.org/label/$1"
+        }
+    },
+    "wikimedia_image": {
+        "category_name": "Wikipedia",
+        "url_name": "Wikipedia image",
+        "urls": {
+            "default": "https://commons.wikimedia.org/wiki/Special:FilePath/$1?width=500&height=400"
+        }
+    },
+    "map": {
+        "category_name": "Map",
+        "url_name": "geo map",
+        "urls": {
+            "default": "https://www.openstreetmap.org/?lat=${latitude}&lon=${longitude}&zoom=${zoom}&layers=M"
+        }
+    }
+}

+ 1006 - 0
searx/data/wikidata_units.json

@@ -0,0 +1,1006 @@
+{
+    "Q199": "1",
+    "Q100149279": "°We",
+    "Q100995": "lb",
+    "Q1022113": "cm³",
+    "Q102573": "Bq",
+    "Q103246": "Sv",
+    "Q103510": "bar",
+    "Q10380431": "TJ",
+    "Q1040401": "das",
+    "Q1040427": "hs",
+    "Q1042866": "Zibit",
+    "Q1050958": "inHg",
+    "Q1051665": "m/s²",
+    "Q1052397": "rad",
+    "Q1054140": "Mm",
+    "Q10543042": "Ym",
+    "Q1057069": "hg",
+    "Q1063756": "rad/s",
+    "Q1063786": "in²",
+    "Q1065153": "mrad",
+    "Q1066138": "Ps",
+    "Q1067722": "Fg",
+    "Q1069725": "p.",
+    "Q1084321": "Tb/s",
+    "Q1086691": "fg",
+    "Q1091257": "tex",
+    "Q1092296": "a",
+    "Q1104069": "CAD$",
+    "Q11061003": "μm²",
+    "Q11061005": "nm²",
+    "Q1131660": "st",
+    "Q1137675": "cr",
+    "Q1140444": "Zbit",
+    "Q1140577": "Ybit",
+    "Q1152074": "Pbit",
+    "Q1152323": "Tbit",
+    "Q1165799": "mil",
+    "Q11776930": "Mg",
+    "Q11830636": "psf",
+    "Q11929860": "kpc",
+    "Q1194225": "lbf",
+    "Q1194580": "Mibit",
+    "Q1195111": "Ebit",
+    "Q1196837": "ω_P",
+    "Q1197459": "Ms",
+    "Q11982285": "Em³",
+    "Q11982288": "Zm³",
+    "Q11982289": "Tm³",
+    "Q12011178": "Zs",
+    "Q1204894": "Gibit",
+    "Q12257695": "Eb/s",
+    "Q12257696": "EB/s",
+    "Q12261466": "kB/s",
+    "Q12265780": "Pb/s",
+    "Q12265783": "PB/s",
+    "Q12269121": "Yb/s",
+    "Q12269122": "YB/s",
+    "Q12269308": "Zb/s",
+    "Q12269309": "ZB/s",
+    "Q1247300": "cm H₂O",
+    "Q12714022": "sh cwt",
+    "Q12789864": "GeV",
+    "Q12874593": "W h",
+    "Q128822": "kn",
+    "Q13035094": "J/mol",
+    "Q130964": "cal",
+    "Q131255": "F",
+    "Q13147228": "g/cm³",
+    "Q1322380": "Ts",
+    "Q1323615": "oz t",
+    "Q132643": "kr",
+    "Q13400897": "g",
+    "Q13479685": "mm wg",
+    "Q1351253": "Eibit",
+    "Q1351334": "Pibit",
+    "Q13542672": "Ry",
+    "Q13548586": "THz",
+    "Q13582667": "kgf/cm²",
+    "Q1361854": "dwt",
+    "Q1363007": "slug",
+    "Q1374438": "ks",
+    "Q13753469": "MB/s",
+    "Q1377051": "Gs",
+    "Q1394540": "bm",
+    "Q1396128": "F",
+    "Q1413142": "Gb",
+    "Q14158377": "A_P",
+    "Q14623803": "MDa",
+    "Q14623804": "kDa",
+    "Q1472674": "Sv",
+    "Q14754979": "Zg",
+    "Q14786969": "MJ",
+    "Q14913554": "Ys",
+    "Q14914907": "th",
+    "Q14916719": "Gpc",
+    "Q14923662": "Pm³",
+    "Q1511773": "LSd",
+    "Q15120301": "l atm",
+    "Q1542309": "xu",
+    "Q1545979": "ft³",
+    "Q1550511": "yd²",
+    "Q15551713": "Sh",
+    "Q1569733": "St",
+    "Q15784325": "apc",
+    "Q160680": "Br",
+    "Q160857": "hp",
+    "Q1628990": "hph",
+    "Q163343": "T",
+    "Q163354": "H",
+    "Q1640501": "hyl",
+    "Q1645498": "μg",
+    "Q16859309": "lb·ft",
+    "Q169893": "S",
+    "Q170804": "Wb",
+    "Q17093295": "m/h",
+    "Q17255465": "v_P",
+    "Q173117": "R$",
+    "Q1741429": "kpm",
+    "Q174467": "Lm",
+    "Q174728": "cm",
+    "Q174789": "mm",
+    "Q175821": "μm",
+    "Q1768929": "p",
+    "Q1770733": "Tg",
+    "Q1772386": "dg",
+    "Q177493": "Gs",
+    "Q177612": "sr",
+    "Q1777507": "fs",
+    "Q177974": "atm",
+    "Q178506": "bbl",
+    "Q178674": "nm",
+    "Q1793863": "sn",
+    "Q179836": "lx",
+    "Q180154": "km/h",
+    "Q180892": "M☉",
+    "Q1815100": "cl",
+    "Q182098": "kWh",
+    "Q1823150": "μW",
+    "Q182429": "m/s",
+    "Q1826195": "dl",
+    "Q18413919": "cm/s",
+    "Q184172": "FF",
+    "Q185078": "a",
+    "Q185153": "erg",
+    "Q185648": "Torr",
+    "Q185759": "span",
+    "Q1872619": "zs",
+    "Q189097": "₧",
+    "Q190095": "Gy",
+    "Q190951": "S$",
+    "Q191118": "t",
+    "Q1913097": "fg",
+    "Q1916026": "μV",
+    "Q192027": "Bd",
+    "Q192274": "pm",
+    "Q193098": "KD",
+    "Q1935515": "mA s",
+    "Q19392152": "TL",
+    "Q193933": "dpt",
+    "Q194339": "B$",
+    "Q1970718": "mam",
+    "Q1972579": "pdl",
+    "Q199462": "LE",
+    "Q199471": "Afs",
+    "Q200323": "dm",
+    "Q200337": "Kz",
+    "Q201880": "LL",
+    "Q201933": "dyn",
+    "Q2029156": "quad",
+    "Q2029519": "hl",
+    "Q203567": "₦",
+    "Q2042279": "m H₂O",
+    "Q204737": "៛",
+    "Q2051195": "GWh",
+    "Q2055118": "ppb",
+    "Q2064166": "fc",
+    "Q206600": "ރ",
+    "Q20706220": "cmm",
+    "Q20706221": "dmm",
+    "Q2080811": "vol%",
+    "Q208526": "NT$",
+    "Q208528": "gon",
+    "Q208634": "kat",
+    "Q208788": "fm",
+    "Q209351": "b",
+    "Q209426": "′",
+    "Q21006887": "ppm",
+    "Q2100949": "P",
+    "Q21014455": "m/min",
+    "Q210472": "B/.",
+    "Q21061369": "g/kg",
+    "Q21062777": "MPa",
+    "Q21064807": "kPa",
+    "Q21064845": "mol/L",
+    "Q21075844": "ml/l",
+    "Q21077820": "mg/m³",
+    "Q21091747": "mg/kg",
+    "Q211256": "mph",
+    "Q211580": "BTU (th)",
+    "Q212120": "A h",
+    "Q2140397": "in³",
+    "Q214377": "ell",
+    "Q2143992": "kHz",
+    "Q21489891": "nm³",
+    "Q21489892": "Gm³",
+    "Q21489893": "Mm³",
+    "Q21489894": "μm³",
+    "Q21500224": "mas",
+    "Q2151240": "mag",
+    "Q215571": "N m",
+    "Q21604951": "g/m³",
+    "Q2165290": "yd³",
+    "Q216880": "kp",
+    "Q217208": "a",
+    "Q2175964": "dm³",
+    "Q218593": "in",
+    "Q2199357": "dec",
+    "Q22137107": "mas/y",
+    "Q2215478": "ppt",
+    "Q2221356": "mW h",
+    "Q22350885": "da",
+    "Q2243141": "Gb/s",
+    "Q2254856": "ca",
+    "Q22673229": "ft/min",
+    "Q2269250": "kb/s",
+    "Q2282891": "μl",
+    "Q2282906": "ng",
+    "Q229354": "Ci",
+    "Q232291": "mi²",
+    "Q2332346": "ml",
+    "Q23823681": "TW",
+    "Q23925410": "gal (UK)",
+    "Q23925413": "gal (US)",
+    "Q23931040": "dam²",
+    "Q23931103": "nmi²",
+    "Q2414435": "$b.",
+    "Q242988": "Lib$",
+    "Q2438073": "ag",
+    "Q2448803": "mV",
+    "Q2451296": "μF",
+    "Q246868": "lot",
+    "Q2474258": "mSv",
+    "Q2483628": "as",
+    "Q2489298": "cm²",
+    "Q249439": "q_P",
+    "Q2518569": "nSv",
+    "Q253276": "mi",
+    "Q25472681": "GB/s",
+    "Q25472693": "TB/s",
+    "Q25499149": "oct",
+    "Q25511288": "mb",
+    "Q2553708": "MV",
+    "Q2554092": "kV",
+    "Q259502": "AU$",
+    "Q260126": "rem",
+    "Q2612219": "Pg",
+    "Q261247": "ct",
+    "Q2619500": "foe",
+    "Q2636421": "nH",
+    "Q2637946": "dal",
+    "Q2642547": "ha",
+    "Q2652700": "Osm",
+    "Q2655272": "Eg",
+    "Q2659078": "TW h",
+    "Q2670039": "₶",
+    "Q26708069": "kcal",
+    "Q267391": "K",
+    "Q2679083": "μH",
+    "Q2682463": "nF",
+    "Q2691798": "cg",
+    "Q271206": "sud£",
+    "Q2737347": "mm²",
+    "Q2739114": "μSv",
+    "Q275112": "Bz$",
+    "Q2756030": "pF",
+    "Q2757753": "PW h",
+    "Q2762458": "ys",
+    "Q27864215": "μW h",
+    "Q2793566": "GV",
+    "Q27949241": "R",
+    "Q2799294": "Gg",
+    "Q281096": "cd/m²",
+    "Q28719934": "keV",
+    "Q28924752": "g/mol",
+    "Q28924753": "kg/mol",
+    "Q2924137": "mH",
+    "Q296936": "toe",
+    "Q29924639": "kVA",
+    "Q30001811": "aBq",
+    "Q30001813": "aC",
+    "Q30001814": "aHz",
+    "Q30001815": "aJ",
+    "Q30001816": "akat",
+    "Q30001818": "aL",
+    "Q30001819": "alm",
+    "Q30001820": "alx",
+    "Q30001822": "aN",
+    "Q30001823": "aΩ",
+    "Q30001825": "aPa",
+    "Q30001826": "arad",
+    "Q30001827": "aS",
+    "Q30001828": "aSv",
+    "Q30001829": "asr",
+    "Q30001830": "aT",
+    "Q30001831": "aV",
+    "Q30001832": "aW",
+    "Q30001833": "aWb",
+    "Q3013059": "kyr",
+    "Q3194304": "kbit",
+    "Q3207456": "mW",
+    "Q321017": "R",
+    "Q3221356": "ym",
+    "Q3239557": "pg",
+    "Q3241121": "mg",
+    "Q324923": "Hart",
+    "Q3249364": "cs",
+    "Q3251645": "ds",
+    "Q3267417": "Tm",
+    "Q3270676": "zm",
+    "Q32750621": "liq pt (US)",
+    "Q32750759": "fl oz (US)",
+    "Q32750816": "bu (US)",
+    "Q32751272": "dry pt (US)",
+    "Q32751296": "bbl (US)",
+    "Q3276763": "GHz",
+    "Q3277907": "Em",
+    "Q3277915": "Zm",
+    "Q3277919": "Pm",
+    "Q3312063": "fL",
+    "Q3320608": "kW",
+    "Q3331719": "dm²",
+    "Q3332689": "ToR",
+    "Q3332814": "Mbit",
+    "Q3396758": "daa",
+    "Q3414243": "rps",
+    "Q3421309": "R_J",
+    "Q3495543": "mbar",
+    "Q355198": "px",
+    "Q3674704": "km/s",
+    "Q3675550": "mm³",
+    "Q3712659": "$",
+    "Q376660": "nat",
+    "Q37732658": "°R",
+    "Q3773454": "Mpc",
+    "Q3815076": "Kibit",
+    "Q3833309": "£",
+    "Q3858002": "mA h",
+    "Q3867152": "ft/s²",
+    "Q389062": "Tibit",
+    "Q3902688": "pl",
+    "Q3902709": "ps",
+    "Q39360235": "US lea",
+    "Q39360471": "nl",
+    "Q39362962": "µin",
+    "Q39363132": "UK lg",
+    "Q39363209": "UK nl",
+    "Q39380159": "US nmi",
+    "Q39462789": "µin²",
+    "Q39467934": "kgf/m²",
+    "Q39469927": "N/m²",
+    "Q39617688": "cwt long",
+    "Q39617818": "t lb",
+    "Q39628023": "y",
+    "Q39699418": "cm/s²",
+    "Q39708248": "S",
+    "Q39709980": "bd",
+    "Q39710113": "bhp EDR",
+    "Q3972226": "kL",
+    "Q4041686": "iwg",
+    "Q4068266": "Ʒ",
+    "Q4176683": "aC",
+    "Q420266": "oz. fl.",
+    "Q42319606": "people/m²",
+    "Q4243638": "km³",
+    "Q4456994": "mF",
+    "Q469356": "tn. sh.",
+    "Q476572": "Ha",
+    "Q482798": "yd",
+    "Q483261": "Da",
+    "Q483725": "A.M.",
+    "Q484092": "lm",
+    "Q4861171": "H",
+    "Q494083": "fur",
+    "Q4989854": "kJ",
+    "Q500515": "Gal",
+    "Q5042194": "£",
+    "Q50808017": "kg m²",
+    "Q5139563": "hPa",
+    "Q514845": "pz",
+    "Q5195628": "hm³",
+    "Q5198770": "dam³",
+    "Q524410": "byr",
+    "Q53393488": "PHz",
+    "Q53393490": "EHz",
+    "Q53393494": "ZHz",
+    "Q53393498": "YHz",
+    "Q53393659": "ML",
+    "Q53393664": "GL",
+    "Q53393674": "ZL",
+    "Q53393678": "YL",
+    "Q53393771": "yL",
+    "Q53393868": "GJ",
+    "Q53393886": "PJ",
+    "Q53393890": "EJ",
+    "Q53448786": "yHz",
+    "Q53448790": "zHz",
+    "Q53448794": "fHz",
+    "Q53448797": "pHz",
+    "Q53448801": "nHz",
+    "Q53448806": "μHz",
+    "Q53448808": "mHz",
+    "Q53448813": "cHz",
+    "Q53448817": "dHz",
+    "Q53448820": "daHz",
+    "Q53448826": "hHz",
+    "Q53448828": "yJ",
+    "Q53448832": "zJ",
+    "Q53448842": "pJ",
+    "Q53448844": "nJ",
+    "Q53448847": "μJ",
+    "Q53448851": "mJ",
+    "Q53448856": "cJ",
+    "Q53448860": "dJ",
+    "Q53448864": "daJ",
+    "Q53448875": "hJ",
+    "Q53448879": "yPa",
+    "Q53448883": "zPa",
+    "Q53448886": "fPa",
+    "Q53448892": "pPa",
+    "Q53448897": "nPa",
+    "Q53448900": "μPa",
+    "Q53448906": "mPa",
+    "Q53448909": "cPa",
+    "Q53448914": "dPa",
+    "Q53448918": "daPa",
+    "Q53448922": "GPa",
+    "Q53448927": "TPa",
+    "Q53448931": "PPa",
+    "Q53448936": "EPa",
+    "Q53448939": "ZPa",
+    "Q53448943": "YPa",
+    "Q53448949": "yV",
+    "Q53448952": "zV",
+    "Q53448957": "fV",
+    "Q53448960": "pV",
+    "Q53448965": "nV",
+    "Q53448969": "cV",
+    "Q53448973": "dV",
+    "Q53448977": "daV",
+    "Q53448981": "hV",
+    "Q53448985": "TV",
+    "Q53448990": "PV",
+    "Q53448994": "EV",
+    "Q53448996": "ZV",
+    "Q53449001": "YV",
+    "Q53449006": "yW",
+    "Q53449008": "zW",
+    "Q53449013": "fW",
+    "Q53449018": "pW",
+    "Q53449021": "nW",
+    "Q53449025": "cW",
+    "Q53449029": "dW",
+    "Q53449033": "daW",
+    "Q53449036": "hW",
+    "Q53449040": "PW",
+    "Q53449045": "EW",
+    "Q53449049": "ZW",
+    "Q53449054": "YW",
+    "Q53561461": "wf",
+    "Q53561822": "wf",
+    "Q53651160": "zm³",
+    "Q53651201": "Ym³",
+    "Q53651356": "ym³",
+    "Q53651512": "pm³",
+    "Q53651713": "fm³",
+    "Q536785": "ρ_P",
+    "Q53951982": "Mt",
+    "Q53952048": "kt",
+    "Q54006645": "ZWb",
+    "Q54081925": "ZSv",
+    "Q54082468": "ZS",
+    "Q54083144": "ZΩ",
+    "Q54083318": "ZN",
+    "Q54083566": "Zlm",
+    "Q54083579": "Zlx",
+    "Q54083712": "ZBq",
+    "Q54083746": "ZC",
+    "Q54083766": "ZF",
+    "Q54083779": "ZGy",
+    "Q54083795": "ZH",
+    "Q54083813": "Zkat",
+    "Q5409016": "MVA",
+    "Q5465723": "ft-pdl",
+    "Q549389": "bit/s",
+    "Q550341": "V A",
+    "Q552299": "ch",
+    "Q55442349": "U/L",
+    "Q55726194": "mg/L",
+    "Q56156859": "mmol",
+    "Q56156949": "μmol",
+    "Q56157046": "nmol",
+    "Q56157048": "pmol",
+    "Q56160603": "fmol",
+    "Q56302633": "UM",
+    "Q56317116": "mgal",
+    "Q56317622": "Q_P",
+    "Q56318907": "kbar",
+    "Q56349362": "Bs.S",
+    "Q56402798": "kN",
+    "Q5711261": "am³",
+    "Q581432": "‴",
+    "Q5879479": "GW",
+    "Q6003257": "am",
+    "Q6009164": "MW h",
+    "Q6014364": "in/s",
+    "Q603071": "E°",
+    "Q605704": "doz",
+    "Q60742631": "AU/yr",
+    "Q608697": "Mx",
+    "Q610135": "G",
+    "Q613726": "Yg",
+    "Q6170164": "yg",
+    "Q6171168": "zg",
+    "Q61756607": "yd",
+    "Q61793198": "rd",
+    "Q61794766": "ch (US survey)",
+    "Q61994988": "Wth",
+    "Q61995006": "KWth",
+    "Q626299": "psi",
+    "Q630369": "var",
+    "Q636200": "U",
+    "Q640907": "sb",
+    "Q6414556": "kip",
+    "Q648908": "bya",
+    "Q64996135": "gal (US)/min",
+    "Q65028392": "mm/yr",
+    "Q651336": "M_J",
+    "Q6517513": "dag",
+    "Q667419": "UK t",
+    "Q681996": "M⊕",
+    "Q685662": "p_P",
+    "Q6859652": "mm Hg",
+    "Q686163": "$",
+    "Q68725821": "°Rø",
+    "Q68726230": "°De",
+    "Q68726625": "°N",
+    "Q69362731": "°C",
+    "Q69363953": "K",
+    "Q693944": "gr",
+    "Q6982035": "MW",
+    "Q69878540": "fl oz (UK)",
+    "Q70378044": "dmol",
+    "Q70378549": "dK",
+    "Q70393458": "kmol",
+    "Q70395375": "Tmol",
+    "Q70395643": "Mmol",
+    "Q70395830": "kK",
+    "Q70396179": "mK",
+    "Q70397275": "μK",
+    "Q70397725": "cmol",
+    "Q70397932": "cK",
+    "Q70398457": "nK",
+    "Q70398619": "MK",
+    "Q70398813": "Gmol",
+    "Q70398991": "GK",
+    "Q70440025": "daK",
+    "Q70440438": "hK",
+    "Q70440620": "damol",
+    "Q70440823": "hmol",
+    "Q70443020": "EK",
+    "Q70443154": "yK",
+    "Q70443282": "zK",
+    "Q70443367": "fK",
+    "Q70443453": "TK",
+    "Q70443757": "pK",
+    "Q70443901": "YK",
+    "Q70444029": "PK",
+    "Q70444141": "Emol",
+    "Q70444284": "ymol",
+    "Q70444386": "zmol",
+    "Q70444514": "Ymol",
+    "Q70444609": "Pmol",
+    "Q712226": "km²",
+    "Q72081071": "MeV",
+    "Q723733": "ms",
+    "Q730251": "ft·lbf",
+    "Q732707": "MHz",
+    "Q73408": "K",
+    "Q7350781": "Mb/s",
+    "Q743895": "bpm",
+    "Q748716": "ft/s",
+    "Q750178": "‱",
+    "Q752197": "kJ/mol",
+    "Q7672057": "TU",
+    "Q777017": "dBm",
+    "Q78754556": "rot",
+    "Q78756901": "rev",
+    "Q78757683": "windings",
+    "Q79726": "kB",
+    "Q79735": "MB",
+    "Q79738": "GB",
+    "Q79741": "TB",
+    "Q79744": "PB",
+    "Q79745": "EB",
+    "Q79747": "ZB",
+    "Q7974920": "W s",
+    "Q79752": "YB",
+    "Q79756": "KiB",
+    "Q79758": "MiB",
+    "Q79765": "GiB",
+    "Q79769": "TiB",
+    "Q79774": "PiB",
+    "Q79777": "EiB",
+    "Q79779": "ZiB",
+    "Q79781": "YiB",
+    "Q80237579": "J/nm",
+    "Q809678": "Ba",
+    "Q81062869": "W/nm",
+    "Q81073100": "W/(sr nm)",
+    "Q81292": "acre",
+    "Q81454": "Å",
+    "Q8229770": "B/s",
+    "Q828224": "km",
+    "Q829073": "\"",
+    "Q83216": "cd",
+    "Q83327": "eV",
+    "Q834105": "g/L",
+    "Q835916": "IU",
+    "Q838801": "ns",
+    "Q842015": "μs",
+    "Q842981": "thm (US)",
+    "Q844211": "kg/m³",
+    "Q844338": "hm",
+    "Q844976": "Oe",
+    "Q845958": "¥",
+    "Q848856": "dam",
+    "Q851872": "o",
+    "Q854546": "Gm",
+    "Q855161": "Yibit",
+    "Q856240": "ft³/min",
+    "Q857027": "ft²",
+    "Q85854198": "MN",
+    "Q864818": "abA",
+    "Q87262709": "kΩ",
+    "Q87416053": "MΩ",
+    "Q88296091": "tsp",
+    "Q9026416": "MWth",
+    "Q9048643": "nl",
+    "Q905912": "L",
+    "Q906223": "Es",
+    "Q909066": "at",
+    "Q911730": "nx",
+    "Q914151": "P_P",
+    "Q915169": "F_P",
+    "Q93318": "nmi",
+    "Q940052": "q",
+    "Q94076025": "dalm",
+    "Q94076717": "dakat",
+    "Q942092": "BWI$",
+    "Q94414053": "Prad",
+    "Q94414499": "PC",
+    "Q94415026": "Grad",
+    "Q94415255": "GC",
+    "Q94415438": "Yrad",
+    "Q94415526": "YC",
+    "Q94415782": "Mrad",
+    "Q94416260": "GN",
+    "Q94416535": "cN",
+    "Q94416879": "YN",
+    "Q94417138": "PN",
+    "Q94417481": "μGy",
+    "Q94417583": "μS",
+    "Q94417598": "μT",
+    "Q94417933": "μlm",
+    "Q94418102": "μN",
+    "Q94418220": "μsr",
+    "Q94418481": "μBq",
+    "Q94479580": "GΩ",
+    "Q94480021": "PΩ",
+    "Q94480081": "YΩ",
+    "Q94480128": "cΩ",
+    "Q94480131": "TΩ",
+    "Q94480136": "pΩ",
+    "Q94480254": "nΩ",
+    "Q94480476": "dΩ",
+    "Q94480633": "EΩ",
+    "Q94480967": "daΩ",
+    "Q94481176": "hΩ",
+    "Q94481339": "fΩ",
+    "Q94481646": "yΩ",
+    "Q94487174": "zΩ",
+    "Q94487366": "mΩ",
+    "Q94487561": "μΩ",
+    "Q94487750": "kGy",
+    "Q94488007": "klx",
+    "Q94488361": "MF",
+    "Q94488759": "GBq",
+    "Q94489041": "PBq",
+    "Q94489223": "YBq",
+    "Q94489429": "MBq",
+    "Q94489465": "kBq",
+    "Q94489476": "TBq",
+    "Q94489494": "kWb",
+    "Q94489520": "kS",
+    "Q94490951": "klm",
+    "Q94491129": "kkat",
+    "Q94634634": "cC",
+    "Q94634655": "MC",
+    "Q94634666": "kC",
+    "Q94634677": "TC",
+    "Q94634684": "μC",
+    "Q94634699": "mC",
+    "Q94693759": "csr",
+    "Q94693773": "msr",
+    "Q94693786": "mWb",
+    "Q94693805": "μWb",
+    "Q94693819": "GS",
+    "Q94693849": "cS",
+    "Q94693918": "MS",
+    "Q94694019": "TS",
+    "Q94694096": "pS",
+    "Q94694154": "nS",
+    "Q94694206": "mS",
+    "Q94731530": "mlm",
+    "Q94731808": "mkat",
+    "Q94731887": "μkat",
+    "Q94732218": "nkat",
+    "Q94732627": "pkat",
+    "Q94733432": "fkat",
+    "Q94733760": "cGy",
+    "Q94734107": "dGy",
+    "Q94734232": "mGy",
+    "Q94734359": "daGy",
+    "Q94734468": "aGy",
+    "Q94734527": "pGy",
+    "Q94734593": "nGy",
+    "Q94734689": "kT",
+    "Q94734788": "mT",
+    "Q94939947": "Gkat",
+    "Q94940018": "Pkat",
+    "Q94940081": "ykat",
+    "Q94940160": "dkat",
+    "Q94940232": "Ekat",
+    "Q94940295": "Ykat",
+    "Q94940582": "Tkat",
+    "Q94940892": "hkat",
+    "Q94941461": "zkat",
+    "Q94942602": "MGy",
+    "Q94942863": "GGy",
+    "Q94986863": "YWb",
+    "Q94986889": "PWb",
+    "Q94986906": "cWb",
+    "Q94986920": "GWb",
+    "Q94986942": "MWb",
+    "Q94986962": "TWb",
+    "Q95178536": "Mlm",
+    "Q95178777": "Tlm",
+    "Q95178881": "clm",
+    "Q95179024": "plm",
+    "Q95179137": "nlm",
+    "Q95179382": "hlm",
+    "Q95179467": "flm",
+    "Q95179608": "zlm",
+    "Q95179695": "Mkat",
+    "Q95179788": "ckat",
+    "Q95179882": "PGy",
+    "Q95377836": "PF",
+    "Q95377853": "YF",
+    "Q95378017": "kF",
+    "Q95378296": "TF",
+    "Q95379145": "cF",
+    "Q95379382": "GF",
+    "Q95379491": "daC",
+    "Q95379580": "hC",
+    "Q95379588": "dC",
+    "Q95379596": "EC",
+    "Q95445986": "nC",
+    "Q95446327": "pC",
+    "Q95446670": "fC",
+    "Q95447079": "zC",
+    "Q95447237": "yC",
+    "Q95447253": "fF",
+    "Q95447263": "zF",
+    "Q95447276": "aF",
+    "Q95447555": "dF",
+    "Q95447863": "EF",
+    "Q95448262": "yF",
+    "Q95448479": "hF",
+    "Q95448689": "daF",
+    "Q95448950": "kSv",
+    "Q95559229": "GSv",
+    "Q95559368": "YSv",
+    "Q95559441": "MSv",
+    "Q95559576": "TSv",
+    "Q95559603": "PSv",
+    "Q95609154": "nWb",
+    "Q95609210": "fWb",
+    "Q95609261": "zWb",
+    "Q95609291": "dWb",
+    "Q95609317": "EWb",
+    "Q95676212": "pWb",
+    "Q95676232": "yWb",
+    "Q95676243": "hWb",
+    "Q95676250": "daWb",
+    "Q95676257": "PS",
+    "Q95676260": "YS",
+    "Q95676273": "zS",
+    "Q95676275": "fS",
+    "Q95676279": "yS",
+    "Q95676287": "hS",
+    "Q95676291": "daS",
+    "Q95676297": "dS",
+    "Q95676298": "ES",
+    "Q95720731": "YGy",
+    "Q95720734": "TGy",
+    "Q95720736": "fGy",
+    "Q95720739": "yGy",
+    "Q95720741": "zGy",
+    "Q95720742": "EGy",
+    "Q95720746": "hGy",
+    "Q95720749": "mlx",
+    "Q95720758": "μlx",
+    "Q95720773": "dalx",
+    "Q95720777": "hlx",
+    "Q95720781": "dlx",
+    "Q95720786": "clx",
+    "Q95857671": "zSv",
+    "Q95859071": "fSv",
+    "Q95860960": "daSv",
+    "Q95861107": "hSv",
+    "Q95861296": "dSv",
+    "Q95862182": "ESv",
+    "Q95863358": "cSv",
+    "Q95863591": "ySv",
+    "Q95863894": "pSv",
+    "Q95864194": "zBq",
+    "Q95864378": "fBq",
+    "Q95864695": "daBq",
+    "Q95864940": "hBq",
+    "Q95865286": "dBq",
+    "Q95865530": "EBq",
+    "Q95865716": "cBq",
+    "Q95865877": "yBq",
+    "Q95866173": "pBq",
+    "Q95866344": "nBq",
+    "Q95866767": "mBq",
+    "Q95867993": "mN",
+    "Q95948345": "crad",
+    "Q95948364": "drad",
+    "Q95948734": "daN",
+    "Q95948739": "hN",
+    "Q95948747": "dN",
+    "Q95976839": "Plm",
+    "Q95976853": "Glm",
+    "Q95976869": "Ylm",
+    "Q95976889": "ylm",
+    "Q95976917": "dlm",
+    "Q95976919": "Elm",
+    "Q95976921": "nT",
+    "Q95993516": "TN",
+    "Q95993522": "nN",
+    "Q95993524": "fN",
+    "Q95993526": "yN",
+    "Q95993528": "zN",
+    "Q95993530": "EN",
+    "Q95993532": "pN",
+    "Q95993537": "μrad",
+    "Q95993542": "nrad",
+    "Q95993547": "frad",
+    "Q95993553": "prad",
+    "Q95993554": "darad",
+    "Q95993557": "hrad",
+    "Q95993619": "pT",
+    "Q96025401": "daT",
+    "Q96025405": "Trad",
+    "Q96025407": "Zrad",
+    "Q96025409": "zrad",
+    "Q96025413": "yrad",
+    "Q96025414": "Erad",
+    "Q96025419": "Ylx",
+    "Q96025422": "Glx",
+    "Q96025427": "Plx",
+    "Q96025431": "Mlx",
+    "Q96025433": "Tlx",
+    "Q96025435": "nlx",
+    "Q96025441": "flx",
+    "Q96050953": "GH",
+    "Q96051010": "PH",
+    "Q96051029": "YH",
+    "Q96051052": "cH",
+    "Q96051074": "TH",
+    "Q96051106": "MH",
+    "Q96051123": "kH",
+    "Q96051126": "fH",
+    "Q96051133": "yH",
+    "Q96051139": "hH",
+    "Q96051142": "dH",
+    "Q96051144": "EH",
+    "Q96051150": "pH",
+    "Q96051160": "daH",
+    "Q96051186": "zH",
+    "Q96051199": "aH",
+    "Q96051245": "ylx",
+    "Q96051267": "Elx",
+    "Q96051282": "plx",
+    "Q96051312": "zlx",
+    "Q96070067": "PT",
+    "Q96070074": "YT",
+    "Q96070076": "GT",
+    "Q96070087": "cT",
+    "Q96070103": "MT",
+    "Q96070125": "hT",
+    "Q96070145": "fT",
+    "Q96070174": "TT",
+    "Q96070195": "zT",
+    "Q96070247": "yT",
+    "Q96070254": "dT",
+    "Q96070264": "ET",
+    "Q96070276": "m°C",
+    "Q96070318": "dsr",
+    "Q96070329": "nsr",
+    "Q96070341": "psr",
+    "Q96095866": "fsr",
+    "Q96095897": "zsr",
+    "Q96095917": "ysr",
+    "Q96095927": "dasr",
+    "Q96095928": "hsr",
+    "Q96095931": "ksr",
+    "Q96095933": "Msr",
+    "Q96095939": "Gsr",
+    "Q96095941": "μ°C",
+    "Q96095955": "n°C",
+    "Q96095960": "k°C",
+    "Q96106290": "Tsr",
+    "Q96106298": "Psr",
+    "Q96106311": "Esr",
+    "Q96106319": "Zsr",
+    "Q96106332": "Ysr",
+    "Q96106346": "c°C",
+    "Q96106360": "d°C",
+    "Q96106368": "da°C",
+    "Q96106385": "h°C",
+    "Q96106393": "M°C",
+    "Q96236286": "G°C",
+    "Q97059641": "p°C",
+    "Q97059652": "T°C",
+    "Q97143826": "P°C",
+    "Q97143831": "y°C",
+    "Q97143835": "f°C",
+    "Q97143838": "Z°C",
+    "Q97143842": "E°C",
+    "Q97143843": "z°C",
+    "Q97143849": "Y°C",
+    "Q97143851": "a°C",
+    "Q98538634": "eV/m²",
+    "Q98635536": "eV/m",
+    "Q98642859": "eV m²/kg",
+    "Q11229": "%",
+    "Q11570": "kg",
+    "Q11573": "m",
+    "Q11574": "s",
+    "Q11579": "K",
+    "Q11582": "L",
+    "Q12129": "pc",
+    "Q12438": "N",
+    "Q16068": "DM",
+    "Q1811": "ua",
+    "Q20764": "Myr",
+    "Q2101": "e",
+    "Q25235": "h",
+    "Q25236": "W",
+    "Q25250": "V",
+    "Q25267": "°C",
+    "Q25269": "J",
+    "Q25272": "A",
+    "Q25343": "m²",
+    "Q25406": "C",
+    "Q25517": "m³",
+    "Q33680": "rad",
+    "Q35852": "ha",
+    "Q36384": "equiv",
+    "Q3710": "ft",
+    "Q39274": "Sv",
+    "Q39369": "Hz",
+    "Q41509": "mol",
+    "Q41803": "g",
+    "Q42289": "°F",
+    "Q4406": "TV$",
+    "Q44395": "Pa",
+    "Q4587": "Le",
+    "Q4588": "WS$",
+    "Q4592": "F$",
+    "Q4596": "Rs",
+    "Q4597": "$",
+    "Q47083": "Ω",
+    "Q48013": "oz",
+    "Q50094": "Np",
+    "Q50098": "B",
+    "Q531": "ly",
+    "Q5329": "dB",
+    "Q573": "d",
+    "Q577": "a",
+    "Q7727": "min",
+    "Q8799": "B"
+}

+ 77 - 0
searx/external_urls.py

@@ -0,0 +1,77 @@
+import math
+
+from searx.data import EXTERNAL_URLS
+
+
+IMDB_PREFIX_TO_URL_ID = {
+    'tt': 'imdb_title',
+    'mn': 'imdb_name',
+    'ch': 'imdb_character',
+    'co': 'imdb_company',
+    'ev': 'imdb_event'
+}
+
+
+def get_imdb_url_id(imdb_item_id):
+    id_prefix = imdb_item_id[:2]
+    return IMDB_PREFIX_TO_URL_ID.get(id_prefix)
+
+
+def get_external_url(url_id, item_id, alternative="default"):
+    """Return an external URL or None if url_id is not found.
+
+    url_id can take value from data/external_urls.json
+    The "imdb_id" value is automaticaly converted according to the item_id value.
+
+    If item_id is None, the raw URL with the $1 is returned.
+    """
+    if url_id == 'imdb_id' and item_id is not None:
+        url_id = get_imdb_url_id(item_id)
+
+    url_description = EXTERNAL_URLS.get(url_id)
+    if url_description:
+        url_template = url_description["urls"].get(alternative)
+        if url_template is not None:
+            if item_id is not None:
+                return url_template.replace('$1', item_id)
+            else:
+                return url_template
+    return None
+
+
+def get_earth_coordinates_url(latitude, longitude, osm_zoom, alternative='default'):
+    url = get_external_url('map', None, alternative)\
+        .replace('${latitude}', str(latitude))\
+        .replace('${longitude}', str(longitude))\
+        .replace('${zoom}', str(osm_zoom))
+    return url
+
+
+def area_to_osm_zoom(area):
+    """Convert an area in km² into an OSM zoom. Less reliable if the shape is not round.
+
+    logarithm regression using these data:
+     * 9596961 -> 4 (China)
+     * 3287263 -> 5 (India)
+     * 643801 -> 6 (France)
+     * 6028 -> 9
+     * 1214 -> 10
+     * 891 -> 12
+     * 12 -> 13
+
+    In WolframAlpha:
+        >>> log fit {9596961,15},{3287263, 14},{643801,13},{6028,10},{1214,9},{891,7},{12,6}
+
+    with 15 = 19-4 (China); 14 = 19-5 (India) and so on
+
+    Args:
+        area (int,float,str): area in km²
+
+    Returns:
+        int: OSM zoom or 19 in area is not a number
+    """
+    try:
+        amount = float(area)
+        return max(0, min(19, round(19 - 0.688297 * math.log(226.878 * amount))))
+    except ValueError:
+        return 19

+ 47 - 0
utils/fetch_wikidata_units.py

@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+import json
+import collections
+
+# set path
+from sys import path
+from os.path import realpath, dirname, join
+path.append(realpath(dirname(realpath(__file__)) + '/../'))
+
+from searx import searx_dir
+from searx.engines.wikidata import send_wikidata_query
+
+
+SARQL_REQUEST = """
+SELECT DISTINCT ?item ?symbol ?P2370 ?P2370Unit ?P2442 ?P2442Unit
+WHERE
+{
+?item wdt:P31/wdt:P279 wd:Q47574.
+?item wdt:P5061 ?symbol.
+FILTER(LANG(?symbol) = "en").
+}
+ORDER BY ?item
+"""
+
+
+def get_data():
+    def get_key(unit):
+        return unit['item']['value'].replace('http://www.wikidata.org/entity/', '')
+
+    def get_value(unit):
+        return unit['symbol']['value']
+
+    result = send_wikidata_query(SARQL_REQUEST)
+    if result is not None:
+        # sort the unit by entity name
+        # so different fetchs keep the file unchanged.
+        list(result['results']['bindings']).sort(key=get_key)
+        return collections.OrderedDict([(get_key(unit), get_value(unit)) for unit in result['results']['bindings']])
+
+
+def get_wikidata_units_filename():
+    return join(join(searx_dir, "data"), "wikidata_units.json")
+
+
+with open(get_wikidata_units_filename(), 'w') as f:
+    json.dump(get_data(), f, indent=4, ensure_ascii=False)