From 5cd137d8083e2728f5694c05da90714d54bad23d Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Fri, 14 Sep 2018 19:50:11 -0500 Subject: [PATCH] Refactor signature extractor --- src/invidious/jobs.cr | 3 +-- src/invidious/signatures.cr | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/invidious/jobs.cr b/src/invidious/jobs.cr index 1bc550ad..1b0a1442 100644 --- a/src/invidious/jobs.cr +++ b/src/invidious/jobs.cr @@ -141,8 +141,7 @@ end def update_decrypt_function loop do begin - client = make_client(YT_URL) - decrypt_function = fetch_decrypt_function(client) + decrypt_function = fetch_decrypt_function rescue ex next end diff --git a/src/invidious/signatures.cr b/src/invidious/signatures.cr index 9e98c2a1..eaf91902 100644 --- a/src/invidious/signatures.cr +++ b/src/invidious/signatures.cr @@ -1,4 +1,5 @@ -def fetch_decrypt_function(client, id = "CvFH_6DNRCY") +def fetch_decrypt_function(id = "CvFH_6DNRCY") + client = make_client(YT_URL) document = client.get("/watch?v=#{id}").body url = document.match(/src="(?\/yts\/jsbin\/player-.{9}\/en_US\/base.js)"/).not_nil!["url"] player = client.get(url).body