Skip to content

Commit

Permalink
Merge pull request #53 from MarcWeberFS:11-frontend-integration-for-u…
Browse files Browse the repository at this point in the history
…ser-input

11-frontend-integration-for-user-input
  • Loading branch information
MarcWeberFS authored Nov 16, 2024
2 parents f2181ea + d452318 commit dbbebf9
Show file tree
Hide file tree
Showing 9 changed files with 438 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ public class VideoDownloadController {
private RuntimeService runtimeService;

@PostMapping("/start-download")
public ResponseEntity<Map<String, String>> startDownloadProcess(@RequestParam("url") String url) {
public ResponseEntity<Map<String, String>> startDownloadProcess(
@RequestParam("url") String url,
@RequestParam("advanced") boolean advanced,
@RequestParam("sourceLanguage") String sourceLanguage,
@RequestParam("targetLanguage") String targetLanguage) {
Map<String, Object> variables = new HashMap<>();
variables.put("url", url);
variables.put("advanced", true);
variables.put("sourceLanguage", "en");
variables.put("targetLanguage", "de");
variables.put("advanced", advanced);
variables.put("sourceLanguage", sourceLanguage);
variables.put("targetLanguage", targetLanguage);

System.out.println("URL: " + url + " Advanced: " + advanced + " Source Language: " + sourceLanguage + " Target Language: " + targetLanguage);

ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process_1ua4l8j", variables);
Map<String, String> response = new HashMap<>();
Expand All @@ -40,6 +46,7 @@ public ResponseEntity<Map<String, String>> startDownloadProcess(@RequestParam("u
return ResponseEntity.ok(response);
}


@Autowired
private HistoryService historyService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;

import org.camunda.bpm.engine.delegate.DelegateExecution;
Expand Down Expand Up @@ -37,25 +38,27 @@ public void execute(DelegateExecution execution) throws Exception {
.build();

try (ResponseInputStream s3ObjectStream = s3Client.getObject(getObjectRequest);
BufferedReader reader = new BufferedReader(new InputStreamReader(s3ObjectStream))) {
BufferedReader reader = new BufferedReader(new InputStreamReader(s3ObjectStream, StandardCharsets.UTF_8))) {


String srtContent = reader.lines().collect(Collectors.joining("\n"));
//System.out.println("Original SRT content:" + srtContent);
System.out.println("Original SRT content:" + srtContent);

TranslateTextRequest translateTextRequest = TranslateTextRequest.builder()
TranslateTextRequest translateTextRequest = TranslateTextRequest.builder()
.sourceLanguageCode(sourceLanguage)
.targetLanguageCode(targetLanguage)
.text(srtContent)
.build();

TranslateTextResponse translateTextResponse = translateClient.translateText(translateTextRequest);
System.out.println("Translated Response Object: " + translateTextResponse);
String translatedText = translateTextResponse.translatedText();

//System.out.println("Translated SRT content:\n" + translatedText);

Translate translate = new Translate();
// Text fields inside of h2 database are limitted to 4000 characters. Store the object (blob) instead.
translate.setText(translatedText);
translate.setText(translatedText.toString());

execution.setVariable("translatedText", translate);

Expand Down
199 changes: 199 additions & 0 deletions video-downloader-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions video-downloader-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@headlessui/react": "^2.2.0",
"@heroicons/react": "^2.1.5",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand Down
1 change: 1 addition & 0 deletions video-downloader-frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
name="description"
content="Web site created using create-react-app"
/>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand Down
Loading

0 comments on commit dbbebf9

Please sign in to comment.