Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Outputs: the JSON object
### LEX
| code | Website | Note
| --- | --- | --- |
| `dsd` | https://denstoredanske.lex.dk/ |
| `lex` | https://lex.dk/ | is Den Store Danske/Danmarks Nationalleksikon
| `dlh` | https://dansklitteraturshistorie.lex.dk/ |
| `dbl` | https://biografiskleksikon.lex.dk/ |
| `gtl` | https://teaterleksikon.lex.dk/ |
Expand Down Expand Up @@ -125,10 +125,10 @@ Outputs: `Spellemannprisen`
import snldata

R = snldata.SnlSession()
R.search(zone='dsd', query="Python", best=True) #Pick the one with the best rank
R.search(zone='lex', query="Python", best=True) #Pick the one with the best rank
print(R.url)
```
Outputs: `https://denstoredanske.lex.dk/Python`
Outputs: `https://lex.dk/Python`

### Advance Query (best for prototyping api)
- Main documentation (SNL): [API-dokumentasjon - prototyping](https://meta.snl.no/API-dokumentasjon_-_prototyping)
Expand All @@ -141,7 +141,7 @@ If the API returns no results, `.json` will be given a empty list.
import snldata

R = snldata.SnlSession()
R.search(zone='dsd', query="asdadasdasdad", best=True) #Pick the one with the best rank
R.search(zone='lex', query="asdadasdasdad", best=True) #Pick the one with the best rank
print(R.json)
```
Outputs: `{}`
Expand All @@ -150,7 +150,7 @@ Outputs: `{}`
import snldata

R = snldata.SnlSession()
R.search(zone='dsd', query="jdfhdskjfhsjkdfhksdfh") #Pick the three best results, but there are none
R.search(zone='lex', query="jdfhdskjfhsjkdfhksdfh") #Pick the three best results, but there are none
R._get(0)
print(R.json)
```
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_long_description() -> str:

setuptools.setup(
name="SnlData",
version="1.1.3",
version="1.1.4",
description="A lightweight Python library for Store Norske Leksikon and Lex.dk/Den Store Danske APIs.",
long_description=get_long_description(),
long_description_content_type="text/markdown",
Expand Down
2 changes: 2 additions & 0 deletions snldata/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SnlSession:
'nkl': 'https://nkl.snl.no/api/' + api_version + '/search', # Norsk kunstnerleksikon
# 'prototyping': 'https://snl.no/.api/prototyping/search', # UNSTABLE SNL - Broken
'dsd': 'https://denstoredanske.lex.dk/api/' + api_version + '/search', # Den store danske
'lex': 'https://lex.dk/api/' + api_version + '/search', # Den store danske/Lex
'dlh': 'https://dansklitteraturshistorie.lex.dk/api/' + api_version + '/search', # Dansk litteratur historie
'dbl': 'https://biografiskleksikon.lex.dk/api/' + api_version + '/search', # Dansk biografisk leksikon
'gtl': 'https://teaterleksikon.lex.dk/api' + api_version + '/search', # Gyldendals Teaterleksikon
Expand All @@ -44,6 +45,7 @@ class SnlSession:

SHORT_TO_LONG = {
'dsd': 'denstoredanske',
'lex': 'lex',
'dlh': 'dansklitteraturshistorie',
'dbl': 'biografiskleksikon',
'gtl': 'teaterleksikon',
Expand Down
20 changes: 10 additions & 10 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ def test_simplereq(self):
self.test = self.G.get("https://snl.no/api/v1/search?query=")
self.assertEqual(self.test.status_code, 200)

def test_simplereq_dsd(self):
def test_simplereq_lex(self):
self.G = requests.Session()
self.test = self.G.get("https://denstoredanske.lex.dk/api/v1/search?query=")
self.test = self.G.get("https://lex.dk/api/v1/search?query=")
self.assertEqual(self.test.status_code, 200)

def test_query(self):
self.service.search(query="TCP", best=True)
self.assertEqual(self.service.title, "TCP")

def test_query_dsd(self):
self.service.search(zone='dsd', query="februar", best=True)
def test_query_lex(self):
self.service.search(zone='lex', query="februar", best=True)
self.assertEqual(self.service.title, "februar")

def test_query_lille(self):
Expand All @@ -45,8 +45,8 @@ def test_query_zero_result(self):
self.service.search(query="asdasdadadsasdasdasd", best=True)
self.assertEqual(self.service.json, {})

def test_query_zero_result_dsd(self):
self.service.search(zone='dsd', query="asdasdadadsasdasdasd", best=True)
def test_query_zero_result_lex(self):
self.service.search(zone='lex', query="asdasdadadsasdasdasd", best=True)
self.assertEqual(self.service.json, {})

# API endpoint removed
Expand All @@ -57,9 +57,9 @@ def test_query_zero_result_dsd(self):
# self.assertEqual(self.service.title, "TCP")

# API endpoint removed
# def test_query2_dsd(self):
# def test_query2_lex(self):
# self.service.searchV2(
# {"encyclopedia": "dsd", "query": "februar", "limit": 3, "offset": 0},
# {"encyclopedia": "lex", "query": "februar", "limit": 3, "offset": 0},
# zone="prototyping", best=True)
# self.assertEqual(self.service.title, "februar")

Expand Down Expand Up @@ -97,9 +97,9 @@ def test_search_fail(self):

self.assertTrue("Something went wrong with the parameters!" in str(context.exception))

def test_search_fail_dsd(self):
def test_search_fail_lex(self):
with self.assertRaises(Exception) as context:
self.service.search(zone='dsd2', query="NTNU", limit=11)
self.service.search(zone='lex2', query="NTNU", limit=11)

self.assertTrue("Something went wrong with the parameters!" in str(context.exception))

Expand Down
Loading