Skip to content

Commit

Permalink
add option to upload non-audio-video-files to voctoweb
Browse files Browse the repository at this point in the history
this implements #103
  • Loading branch information
Kunsi committed Jan 7, 2024
1 parent 7b92cf1 commit 813eeb5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
38 changes: 24 additions & 14 deletions voctopublish/api_client/voctoweb_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,16 +534,31 @@ def create_recording(
if single_language:
recording_id = self.t.get_raw_property('Voctoweb.RecordingId.' + language)

# make sure we have the file size and length
ret = []
if not self._get_file_details(local_filename, ret):
raise VoctowebException('could not get file details')

# API code https://github.com/voc/voctoweb/blob/master/app/controllers/api/recordings_controller.rb
url = self.api_url + 'recordings'
if recording_id:
url += '/' + recording_id

if self.t.mime_type.startswith('application/'):
# this is probably a subtitle or something like that
recording = {
'state': 'completed',
}
else:
# make sure we have the file size and length
ret = []
if not self._get_file_details(local_filename, ret):
raise VoctowebException('could not get file details')

recording = {
'high_quality': hq,
'html5': html5,
'size': str(ret[0]),
'width': str(ret[2]),
'height': str(ret[3]),
'length': str(ret[1]),
}

headers = {'CONTENT-TYPE': 'application/json'}
payload = {
'api_key': self.api_key,
Expand All @@ -554,18 +569,13 @@ def create_recording(
'filename': filename,
'mime_type': self.t.mime_type,
'language': language,
'high_quality': hq,
'html5': html5,
'size': str(ret[0]),
'width': str(ret[2]),
'height': str(ret[3]),
'length': str(ret[1]),
**recording,
},
}

logging.debug(
"api url: " + url + ' header: ' + str(headers) + ' payload: ' + str(payload)
)
logging.debug(f"api url: {url}")
logging.debug(f"header: {repr(headers)}")
logging.debug(f"payload: {repr(payload)}")

try:
# todo ssl verify by config
Expand Down
6 changes: 3 additions & 3 deletions voctopublish/voctopublish.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ def _publish_to_voctoweb(self):
hq = False

# For multi language or slide recording we don't set the html5 flag
if len(self.ticket.languages) > 1 or 'slides' in self.ticket.profile_slug:
html5 = False
else:
if len(self.ticket.languages) == 1 and 'slides' not in self.ticket.profile_slug:
html5 = True
else:
html5 = False

# if we have the language index the tracker wants to tell us about an encoding that does not contain all
# audio tracks of the master we need to reflect that in the target filename
Expand Down

0 comments on commit 813eeb5

Please sign in to comment.