Skip to content

Commit

Permalink
Send language in header for new API auth system
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederik Haarslev committed Sep 20, 2023
1 parent 6953839 commit 45f90a0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/mediacatch_s2t/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import json
from typing import NamedTuple

from langcodes import standardize_tag

from mediacatch_s2t import (
URL,
SINGLE_UPLOAD_ENDPOINT, TRANSCRIPT_ENDPOINT, UPDATE_STATUS_ENDPOINT,
Expand Down Expand Up @@ -41,7 +43,7 @@ class UploaderBase(metaclass=abc.ABCMeta):
def __init__(self, file, api_key, language='da'):
self.file = file
self.api_key = api_key
self.language = language
self.language = standardize_tag(language)
self.file_id = None

def _is_file_exist(self):
Expand Down Expand Up @@ -146,7 +148,8 @@ def _get_transcript_link(self):
json={"id": self.file_id},
headers={
"Content-type": 'application/json',
"X-API-KEY": self.api_key
"X-API-KEY": self.api_key,
"X-LANG": self.language
}
)
return self._transcript_link
Expand Down Expand Up @@ -176,7 +179,8 @@ def _get_upload_url(self, mime_file):
json=mime_file,
headers={
"Content-type": 'application/json',
"X-API-KEY": self.api_key
"X-API-KEY": self.api_key,
"X-LANG": self.language
}
)
response_data = json.loads(response.text)
Expand Down Expand Up @@ -272,7 +276,8 @@ def __init__(self, *args, **kwargs):
def _get_headers(self) -> dict:
return {
"Content-type": "application/json",
"X-API-KEY": self.api_key
"X-API-KEY": self.api_key,
"X-LANG": self.language
}

def _set_result_error_message(self, msg) -> None:
Expand Down

0 comments on commit 45f90a0

Please sign in to comment.