Providing Auth configuration via subselect.conf (#37)

I have no way to test, but works I hope
This commit is contained in:
RaXorX 2024-01-20 01:37:15 +05:30 committed by GitHub
parent 19ea069abc
commit 3ad7502fe2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -5,6 +5,7 @@ options = {}
options.down_dir = ""
options.sub_language = "eng"
options.subselect_path = utils.join_path(mp.get_script_directory(), "subselect.py")
options.providers_auth = "{}"
if package.config:sub(1,1) == "/" then
ops = "unix"
@ -100,7 +101,7 @@ function search_subs()
if python ~= nil then
ret = mp.command_native({
name = "subprocess",
args = { python, options.subselect_path, video, options.down_dir, options.sub_language },
args = { python, options.subselect_path, video, options.down_dir, options.sub_language, options.providers_auth },
capture_stdout = true
})
else

View File

@ -3,6 +3,7 @@ from subliminal import *
from babelfish import Language
import sys, os
import tkinter.messagebox
import json
class subselect :
@ -20,7 +21,6 @@ class subselect :
self.best_button = Button(frame, text="Best", command=self.download_best_subtitle)
self.best_button.grid(row=0, column=2, sticky=E+W)
self.result_listbox = Listbox(self.root)
self.providers_auth = {'provider': {'username': 'user', 'password': 'pass'}}
def show_subtitles(self, subtitles) :
self.result_listbox.delete(0, END)
@ -66,7 +66,7 @@ class subselect :
def search(self) :
try :
self.video = self.get_video_from_title()
subtitles = list_subtitles([self.video], {Language(self.language)}, providers=None, provider_configs=self.providers_auth)
subtitles = list_subtitles([self.video], {Language(self.language)}, providers=None, provider_configs=providers_auth)
except ValueError as exc :
self.show_message("Error", str(exc))
else :
@ -75,7 +75,7 @@ class subselect :
def download_best_subtitle(self) :
try :
self.video = self.get_video_from_title()
best_subtitles = download_best_subtitles([self.video], {Language(self.language)}, provider_configs=self.providers_auth)
best_subtitles = download_best_subtitles([self.video], {Language(self.language)}, provider_configs=providers_auth)
except ValueError as exc :
self.show_message("Error", str(exc))
else :
@ -91,7 +91,7 @@ class subselect :
self.show_message("Download failed", "Please select a subtitle")
else :
selected_subtitle = self.subtitles_in_list[i[0]]
download_subtitles([selected_subtitle], provider_configs=self.providers_auth)
download_subtitles([selected_subtitle], provider_configs=providers_auth)
self.save_subtitle(self.video, True, selected_subtitle)
def save_subtitle(self, video, change_filename, subtitle) :
@ -112,10 +112,12 @@ class subselect :
videotitle = save_dir = ""
sub_language = "eng"
providers_auth = {}
if len(sys.argv) > 1 :
videotitle = sys.argv[1]
save_dir = sys.argv[2]
sub_language = sys.argv[3]
providers_auth = json.loads(sys.argv[4])
subselect().root.mainloop()