added oed api handling for improved quality
This commit is contained in:
		
							
								
								
									
										22
									
								
								oxford_api/oed_get_json
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										22
									
								
								oxford_api/oed_get_json
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
#!/bin/python
 | 
			
		||||
import json
 | 
			
		||||
import requests
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
app_id  = sys.argv[2]
 | 
			
		||||
app_key  = sys.argv[3]
 | 
			
		||||
 | 
			
		||||
endpoint = "entries"
 | 
			
		||||
language_code = "en-gb"
 | 
			
		||||
word_id = "example"
 | 
			
		||||
word_id = sys.argv[1]
 | 
			
		||||
 | 
			
		||||
if not sys.argv[3]:
 | 
			
		||||
    print("Error: Provide all necessary arguments")
 | 
			
		||||
    sys.exit()
 | 
			
		||||
 | 
			
		||||
url = "https://od-api.oxforddictionaries.com/api/v2/" + endpoint + "/" + language_code + "/" + word_id.lower()
 | 
			
		||||
r = requests.get(url, headers = {"app_id": app_id, "app_key": app_key})
 | 
			
		||||
# print("code {}\n".format(r.status_code))
 | 
			
		||||
# print("text \n" + r.text)
 | 
			
		||||
print(json.dumps(r.json()))
 | 
			
		||||
							
								
								
									
										1880
									
								
								oxford_api/to_dl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1880
									
								
								oxford_api/to_dl
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										13
									
								
								oxford_api/wrapper
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								oxford_api/wrapper
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
file="$1"
 | 
			
		||||
oed_app_id="$(pass show GRE/oxforddictionary_api | grep -E '^app_id' | cut -d' ' -f2)"
 | 
			
		||||
oed_app_key="$(pass show GRE/oxforddictionary_api | grep -E '^app_key' | cut -d' ' -f2)"
 | 
			
		||||
 | 
			
		||||
while read -r line
 | 
			
		||||
do
 | 
			
		||||
	echo "word: $word"
 | 
			
		||||
	no="$(echo "$line" | cut -f1)"
 | 
			
		||||
	word="$(echo "$line" | cut -f2)"
 | 
			
		||||
	json="$(./oed_get_json "$word" "$oed_app_id" "$oed_app_key")"
 | 
			
		||||
	echo "$json" > json/"$no"_"$word".json
 | 
			
		||||
done < "$file"
 | 
			
		||||
		Reference in New Issue
	
	Block a user