Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion subselect/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "{}"
options.python = "python"

if package.config:sub(1,1) == "/" then
Expand Down Expand Up @@ -101,7 +102,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
Expand Down
10 changes: 6 additions & 4 deletions subselect/subselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from babelfish import Language
import sys, os
import tkinter.messagebox
import json

class subselect :

Expand All @@ -20,7 +21,6 @@ def __init__(self) :
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)
Expand Down Expand Up @@ -66,7 +66,7 @@ def search_(self, *args):
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 :
Expand All @@ -75,7 +75,7 @@ def search(self) :
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 :
Expand All @@ -91,7 +91,7 @@ def download_selected_subtitle(self) :
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) :
Expand All @@ -112,10 +112,12 @@ def show_message(self, title, msg) :

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()