diff --git a/service.subtitles.opensubtitles-com/README.md b/service.subtitles.opensubtitles-com/README.md index 6bb34e3480..7ed32c3ebd 100644 --- a/service.subtitles.opensubtitles-com/README.md +++ b/service.subtitles.opensubtitles-com/README.md @@ -1,9 +1,13 @@ OpenSubtitles.com KODI add-on ============================= -Search and download subtitles for movies and TV-Series from OpenSubtitles.com. Search in 75 languages, 4.000.000+ subtitles, daily updates. +Search and download subtitles for movies and TV-Series from OpenSubtitles.com. Search in 75 languages, 8.000.000+ subtitles, daily updates. REST API implementation based on tomburke25 [python-opensubtitles-rest-api](https://github.com/tomburke25/python-opensubtitles-rest-api) +v1.0.5 (2024-07-30) +- fixed issue with portuguese file names +- added AI translated filter (thanks Kate6) + v1.0.4 (2024-01-15) - Sanitize language query - Improved sorting diff --git a/service.subtitles.opensubtitles-com/addon.xml b/service.subtitles.opensubtitles-com/addon.xml index c1fefe2988..c97626d734 100644 --- a/service.subtitles.opensubtitles-com/addon.xml +++ b/service.subtitles.opensubtitles-com/addon.xml @@ -1,7 +1,7 @@ @@ -11,7 +11,7 @@ library="service.py" /> OpenSubtitles.com - Search and download subtitles for movies and TV-Series from OpenSubtitles.com. Search in 75 languages, 6.000.000+ subtitles, daily updates. Register/Import your account on OpenSubtitles.com before use. + Search and download subtitles for movies and TV-Series from OpenSubtitles.com. Search in 75 languages, 8.000.000+ subtitles, daily updates. Register/Import your account on OpenSubtitles.com before use. Pelis and Subtítulos TV en munches llingües, milenta de subtítulos traducíos y xubíos caldía. Descarga llibre dende la fonte, sofitu API, millones d'usuarios. Istitloù Filmoù ha TV e meur a yezh, miliadoù a istitloù troet hag uskarget bemdez. Pellgargadenn digoust diouzh ar vammenn, skoazell an API, millionoù a implijerien. Subtítols de films i televisió en múltiples idiomes, milers de subtítols traduïts carregats diàriament. Descàrrega gratuïta des de la font, suport de l'API, amb milions d'usuaris. @@ -52,6 +52,10 @@ 多语种的电影及剧集字幕,每日更新千余条翻译好的字幕。免费下载,提供API接口,已拥有上百万的用户。 Users need to provide OpenSubtitles.com username and password in add-on configuration. This is our new extension, old opensubtitles.org will not work on this, but the account can be easily imported on opensubtitles.com. +v1.0.5 (2024-07-30) +- fixed issue with portuguese file names +- added AI translated filter (thanks Kate6) + v1.0.4 (2024-01-15) - Sanitize language query - Improved sorting diff --git a/service.subtitles.opensubtitles-com/changelog.txt b/service.subtitles.opensubtitles-com/changelog.txt index 6d2aaf77a3..491e6efc1b 100644 --- a/service.subtitles.opensubtitles-com/changelog.txt +++ b/service.subtitles.opensubtitles-com/changelog.txt @@ -1,3 +1,7 @@ +v1.0.5 (2024-07-30) +- fixed issue with portuguese file names +- added AI translated filter (thanks Kate6) + v1.0.4 (2024-01-17) - Sanitize language query - Improved sorting diff --git a/service.subtitles.opensubtitles-com/resources/language/resource.language.en_GB/strings.po b/service.subtitles.opensubtitles-com/resources/language/resource.language.en_GB/strings.po index 9b45099fb0..333c2218a8 100644 --- a/service.subtitles.opensubtitles-com/resources/language/resource.language.en_GB/strings.po +++ b/service.subtitles.opensubtitles-com/resources/language/resource.language.en_GB/strings.po @@ -66,4 +66,8 @@ msgstr "" msgctxt "#32214" msgid "Bad username. Make sure you have entered your username and not your email in the username field." +msgstr "" + +msgctxt "#32215" +msgid "AI Translated" msgstr "" \ No newline at end of file diff --git a/service.subtitles.opensubtitles-com/resources/language/resource.language.fr_FR/strings.po b/service.subtitles.opensubtitles-com/resources/language/resource.language.fr_FR/strings.po index e466ef61c7..720bf6760f 100644 --- a/service.subtitles.opensubtitles-com/resources/language/resource.language.fr_FR/strings.po +++ b/service.subtitles.opensubtitles-com/resources/language/resource.language.fr_FR/strings.po @@ -65,4 +65,8 @@ msgstr "Traduction automatique" msgctxt "#32214" msgid "Bad username. Make sure you have entered your username and not your email in the username field" -msgstr "Mauvais nom d'utilisateur. Assurez-vous d'avoir saisi votre nom d'utilisateur et non votre adresse email dans le champ du nom d'utilisateur." \ No newline at end of file +msgstr "Mauvais nom d'utilisateur. Assurez-vous d'avoir saisi votre nom d'utilisateur et non votre adresse email dans le champ du nom d'utilisateur." + +msgctxt "#32215" +msgid "Traductions AI" +msgstr "" \ No newline at end of file diff --git a/service.subtitles.opensubtitles-com/resources/lib/data_collector.py b/service.subtitles.opensubtitles-com/resources/lib/data_collector.py index 405377f792..6cc0b70006 100644 --- a/service.subtitles.opensubtitles-com/resources/lib/data_collector.py +++ b/service.subtitles.opensubtitles-com/resources/lib/data_collector.py @@ -108,6 +108,7 @@ def get_language_data(params): "hearing_impaired": __addon__.getSetting("hearing_impaired"), "foreign_parts_only": __addon__.getSetting("foreign_parts_only"), "machine_translated": __addon__.getSetting("machine_translated"), + "ai_translated": __addon__.getSetting("ai_translated"), "languages": search_languages_str} # for language in search_languages: @@ -123,12 +124,19 @@ def get_language_data(params): def convert_language(language, reverse=False): + # language_list = { + # "English": "en", + # "Portuguese (Brazil)": "pt-br", + # "Portuguese": "pt-pt", + # "Chinese (simplified)": "zh-cn", + # "Chinese (traditional)": "zh-tw"} language_list = { "English": "en", "Portuguese (Brazil)": "pt-br", "Portuguese": "pt-pt", "Chinese (simplified)": "zh-cn", "Chinese (traditional)": "zh-tw"} + reverse_language_list = {v: k for k, v in list(language_list.items())} if reverse: @@ -146,7 +154,9 @@ def convert_language(language, reverse=False): def get_flag(language_code): language_list = { "pt-pt": "pt", - "pt-br": "pb" + "pt-br": "pb", + "zh-cn": "zh", + "zh-tw": "-" } return language_list.get(language_code.lower(), language_code) diff --git a/service.subtitles.opensubtitles-com/resources/lib/file_operations.py b/service.subtitles.opensubtitles-com/resources/lib/file_operations.py index e23409c180..6075e62da9 100644 --- a/service.subtitles.opensubtitles-com/resources/lib/file_operations.py +++ b/service.subtitles.opensubtitles-com/resources/lib/file_operations.py @@ -9,6 +9,7 @@ def get_file_data(file_original_path): item = {"temp": False, "rar": False, "file_original_path": file_original_path} + log(__name__, f"Processing item: {item}") if file_original_path.find("http") > -1: @@ -30,8 +31,11 @@ def get_file_data(file_original_path): item["temp"] = True elif file_original_path.find("rar://") > -1: + # item["rar"] = True + # item["file_original_path"] = os.path.dirname(file_original_path[6:]) item["rar"] = True item["file_original_path"] = os.path.dirname(file_original_path[6:]) + item["basename"] = os.path.basename(file_original_path) elif file_original_path.find("stack://") > -1: stack_path = file_original_path.split(" , ") @@ -46,6 +50,8 @@ def get_file_data(file_original_path): def hash_file(file_path, rar): + log(__name__, f"Processing file: {file_path} - Is RAR: {rar}") + if rar: return hash_rar(file_path) @@ -73,8 +79,43 @@ def hash_file(file_path, rar): return_hash = "%016x" % hash_ return file_size, return_hash - def hash_rar(first_rar_file): + log(__name__, "Hash Rar file") + f = xbmcvfs.File(first_rar_file) + a = f.readBytes(4) + log(__name__, "Hash Rar a: %s" % a) + # Ensure comparison is done with a byte string + if a != b"Rar!": + raise Exception("ERROR: This is not rar file.") + + seek = 0 + for i in range(4): + f.seek(max(0, seek), 0) + a = f.readBytes(100) + type_, flag, size = struct.unpack(" k19 + dir_path = xbmcvfs.translatePath('special://temp/oss') + except: # kodi < k19 + dir_path = xbmc.translatePath('special://temp/oss') + + # Kodi lang-code difference vs OS.com API langcodes return + if self.params["language"].lower() == 'pt-pt': self.params["language"] = 'pt' + elif self.params["language"].lower() == 'pt-pb': self.params["language"] = 'pb' + + if xbmcvfs.exists(dir_path): # lets clean files from last usage + dirs, files = xbmcvfs.listdir(dir_path) + for file in files: + xbmcvfs.delete(os.path.join(dir_path, file)) + + if not xbmcvfs.exists(dir_path): # lets create custom OSS sub directory if not exists + xbmcvfs.mkdir(dir_path) + + subtitle_path = os.path.join(dir_path, "{0}.{1}.{2}".format('TempSubtitle', self.params["language"], self.sub_format)) + + log(__name__, "XYXYXX download subtitle_path: {}".format(subtitle_path)) + + if (valid==1): tmp_file = open(subtitle_path, "w" + "b") tmp_file.write(self.file["content"]) @@ -151,10 +174,19 @@ def list_subtitles(self): list_item.setArt({ "icon": str(int(round(float(attributes["ratings"]) / 2))), "thumb": get_flag(attributes["language"])}) + # list_item.setArt({ + # "icon": str(int(round(float(attributes["ratings"]) / 2))), + # "thumb": get_flag(language)}) + + log(__name__, "XYXYXX download get_flag: language in url {}".format(get_flag(attributes["language"]))) + + list_item.setProperty("sync", "true" if ("moviehash_match" in attributes and attributes["moviehash_match"]) else "false") list_item.setProperty("hearing_imp", "true" if attributes["hearing_impaired"] else "false") """TODO take care of multiple cds id&id or something""" - url = f"plugin://{__scriptid__}/?action=download&id={attributes['files'][0]['file_id']}" + #url = f"plugin://{__scriptid__}/?action=download&id={attributes['files'][0]['file_id']}" + url = f"plugin://{__scriptid__}/?action=download&id={attributes['files'][0]['file_id']}&language={language}" + log(__name__, "XYXYXX download list_subtitles: language in url {url}") xbmcplugin.addDirectoryItem(handle=self.handle, url=url, listitem=list_item, isFolder=False) xbmcplugin.endOfDirectory(self.handle) diff --git a/service.subtitles.opensubtitles-com/resources/settings.xml b/service.subtitles.opensubtitles-com/resources/settings.xml index 68ccfc8582..b20fade559 100644 --- a/service.subtitles.opensubtitles-com/resources/settings.xml +++ b/service.subtitles.opensubtitles-com/resources/settings.xml @@ -74,6 +74,20 @@ 32213 + + 0 + include + + + + + + + + + 32215 + +