added an option to suppress SSL verification for youtube-dl

master
Jaka Perovšek 2021-11-14 18:10:20 +01:00
parent 8f6ad9b7ee
commit f5a04100bc
2 changed files with 24 additions and 5 deletions

View File

@ -94,7 +94,7 @@ def get_ffmpeg_version():
return ffmpeg_version
def fetch_and_cut_song(tape, ffmpeg_version):
def fetch_and_cut_song(tape, ffmpeg_version, suppress_ssl_verify=False):
python_executable = "./utils/python-3.9.7-embed-amd64/python.exe"
script = "./fetch_song.py"
@ -104,6 +104,9 @@ def fetch_and_cut_song(tape, ffmpeg_version):
fetch = [python_executable, script, tape["source"]["url"], "-x", "--audio-format", "vorbis",
"--audio-quality", "0", "-o", f"./build/tmp_music/{tape['identifier']}.ogg"]
if suppress_ssl_verify:
fetch += ["--no-check-certificate"]
# this is done in a separate python script because subprocess.call makes sure that the
# download process is finished before trying to cut the song
@ -155,7 +158,7 @@ def assemble_png_image(tapes, icons=False):
new_im.save("./build/covers.png")
def prepare_music(data):
def prepare_music(data, config):
try:
os.mkdir('./build/music/')
except FileExistsError:
@ -169,7 +172,7 @@ def prepare_music(data):
for tape in data:
if not os.path.exists(f"./build/music/{tape['identifier']}.ogg"):
logging.info(f"Downloading {tape['name']}")
fetch_and_cut_song(tape, ffmpeg_version)
fetch_and_cut_song(tape, ffmpeg_version, suppress_ssl_verify=config["suppress_ssl_verify"])
else:
logging.info(f"Skipping {tape['name']}")
@ -248,7 +251,7 @@ def deploy(config):
with data_file.open(encoding='utf-8') as fr:
data = yaml.load(fr, Loader=yaml.SafeLoader)
prepare_music(data)
prepare_music(data, config)
prepare_images(data, config)
build_xml_code(data, config)

18
main.py
View File

@ -207,7 +207,8 @@ def create_deploy_frame(container, config):
"name": config["name"].get(),
"slug": config["slug"].get(),
"resolution_x": int(config["resolution_x"].get()),
"resolution_y": int(config["resolution_y"].get())}
"resolution_y": int(config["resolution_y"].get()),
"suppress_ssl_verify": suppress_ssl_verify.get() == "1"}
logging.info(f"deploying with config: {config_values}")
deploy(config_values)
@ -298,6 +299,21 @@ def create_deploy_frame(container, config):
frame_3.pack(side="top", fill="x")
suppress_ssl_verify = tk.StringVar()
suppress_ssl_verify.set("0")
suppress_ssl_verify_check = ttk.Checkbutton(
frame,
variable=suppress_ssl_verify,
text='Use --no-check-certificate option. (Not recommended!)',
command=lambda: print(suppress_ssl_verify.get()))
Hovertip(suppress_ssl_verify_check,
'Suppress HTTPS certificate validation in youtube-dl.\n'
'This is a workaround if you have expired system root certificates.\n'
'You should rather find a way to update your system root certificates.')
suppress_ssl_verify_check.pack(side="top", fill="x")
does_ffmpeg_exists()
return frame