Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Using DeepL Translate API to translate titles and descriptions #140

Closed
ahcnguyen opened this issue Oct 19, 2020 · 3 comments · Fixed by #302 or #303
Closed

Feature Request: Using DeepL Translate API to translate titles and descriptions #140

ahcnguyen opened this issue Oct 19, 2020 · 3 comments · Fixed by #302 or #303
Labels
enhancement New feature or request

Comments

@ahcnguyen
Copy link

First of all, fantastic app, my collection has never looked better in Jellyfin!

I know that Javinizer uses Google Translate to machine-translate Japanese titles & descriptions, and the results can be quite...poetic. I've used DeepL Translator for quick translations of small bits of text and the results often make much more sense.

Wonder if there's a DeepL API that Javinizer can use...

@jvlflame jvlflame added the enhancement New feature or request label Oct 20, 2020
@jvlflame
Copy link
Collaborator

I did a bit of research into DeepL, and it seems like they do provide an API. But like most services, they require a paid subscription to use, which I'm assuming most people aren't willing to pay for.

I can do some poking around for other free tools, but in the free sphere there's probably a limited amount of options.

@Avatarthe
Copy link

I must agree, Deepl translations are far superior to Google. I have been using this program to translate Chinese subtitles into English
https://github.com/firebfm/deepl-srt
and the results are petty impressive compared to google, perhaps you could look at the technique the programmer used to access Deepl with Selenium and use a similar technique so we can get real descriptions.

Thanks again fro this program , it rocks!

@jvlflame
Copy link
Collaborator

DeepL support via the developer API (which now has a free tier) is tentatively available by replacing one of the existing translation scripts translate.py or translate_new.py and filling in the apikey = "YOUR-API-KEY" line. I don't think it's feasible to add DeepL scraping functionality via headless browser due to how the threading works in Javinizer. I will try to add the developer API natively next release.

# Written by toastyice
import sys
import requests
import tempfile
import os
import json
apikey = "YOUR-API-KEY"
lang = "EN-GB"

url = "https://api-free.deepl.com/v2/translate?auth_key={}&text={}&target_lang={}".format(apikey, sys.argv[1], lang)
r = requests.get(url)
j = json.loads(r.text)
n = j['translations'][0]['text']

text = n.encode('utf8')

# Write the translated text to a temporary file to bypass encoding issues when redirecting the text to PowerShell
new_file, filename = tempfile.mkstemp()
os.write(new_file, text)
os.close(new_file)

# Return the path to the temporary file to read it from PowerShell
print(filename)

@jvlflame jvlflame linked a pull request Sep 26, 2021 that will close this issue
@jvlflame jvlflame linked a pull request Sep 28, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants