mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-08-02 13:00:14 -04:00
chore(deps): update dependency ruff to v0.16.0 (#7983)
This commit is contained in:
@@ -51,43 +51,37 @@ See <a href="https://github.com/Jleagle/mealie-importer" target="_blank">Jleagle
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def authentication(mail, password, mealie_url):
|
||||
headers = {
|
||||
'accept': 'application/json',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
data = {
|
||||
'grant_type': '',
|
||||
'username': mail,
|
||||
'password': password,
|
||||
'scope': '',
|
||||
'client_id': '',
|
||||
'client_secret': ''
|
||||
}
|
||||
auth = requests.post(mealie_url + "/api/auth/token", headers=headers, data=data)
|
||||
token = re.sub(r'.*token":"(.*)",.*', r'\1', auth.text)
|
||||
return token
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
}
|
||||
data = {"grant_type": "", "username": mail, "password": password, "scope": "", "client_id": "", "client_secret": ""}
|
||||
auth = requests.post(mealie_url + "/api/auth/token", headers=headers, data=data)
|
||||
token = re.sub(r'.*token":"(.*)",.*', r"\1", auth.text)
|
||||
return token
|
||||
|
||||
|
||||
def import_from_file(input_file, token, mealie_url):
|
||||
with open(input_file) as fp:
|
||||
for l in fp:
|
||||
line = re.sub(r'(.*)\n', r'\1', l)
|
||||
print(line)
|
||||
headers = {
|
||||
'Authorization': "Bearer " + token,
|
||||
'accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
data = {
|
||||
'url': line
|
||||
}
|
||||
response = requests.post(mealie_url + "/api/recipes/create/url", headers=headers, json=data)
|
||||
print(response.text)
|
||||
with open(input_file) as fp:
|
||||
for l in fp:
|
||||
line = re.sub(r"(.*)\n", r"\1", l)
|
||||
print(line)
|
||||
headers = {
|
||||
"Authorization": "Bearer " + token,
|
||||
"accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
data = {"url": line}
|
||||
response = requests.post(mealie_url + "/api/recipes/create/url", headers=headers, json=data)
|
||||
print(response.text)
|
||||
|
||||
input_file="list"
|
||||
mail="changeme@example.com"
|
||||
password="MyPassword"
|
||||
mealie_url="http://localhost:9000"
|
||||
|
||||
input_file = "list"
|
||||
mail = "changeme@example.com"
|
||||
password = "MyPassword"
|
||||
mealie_url = "http://localhost:9000"
|
||||
|
||||
|
||||
token = authentication(mail, password, mealie_url)
|
||||
|
||||
Reference in New Issue
Block a user