summaryrefslogtreecommitdiffstats
path: root/src/helpers.cr
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-02-11 22:06:29 -0600
committerOmar Roth <omarroth@hotmail.com>2018-02-11 22:06:29 -0600
commit1d301a5055328881f348b61ac10b74d175a54a3c (patch)
treec51b4e9bdfff85f9f4d5caec3fd29ebb7fa87392 /src/helpers.cr
parent42df0df5a0270fbb61abef22e1e071dc77b77909 (diff)
downloadinvidious-1d301a5055328881f348b61ac10b74d175a54a3c.tar.gz
invidious-1d301a5055328881f348b61ac10b74d175a54a3c.tar.bz2
invidious-1d301a5055328881f348b61ac10b74d175a54a3c.zip
Add support for different signature functions
Diffstat (limited to 'src/helpers.cr')
-rw-r--r--src/helpers.cr39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/helpers.cr b/src/helpers.cr
index b260ec9b..4ac08f9e 100644
--- a/src/helpers.cr
+++ b/src/helpers.cr
@@ -175,14 +175,39 @@ def search(query, client)
end
end
-def decrypt_signature(a)
- a = a.split("")
- a.delete_at(0..2)
- a = a.reverse
+def swap(a, b)
c = a[0]
- a[0] = a[49 % a.size]
- a[49] = c
- return a.join("")
+ a[0] = a[b % a.size]
+ a[b % a.size] = c
+ return a
+end
+
+def decrypt_signature(a, base)
+ if a && base
+ a = a.split("")
+
+ if base == "vflG9lb96"
+ a = swap(a, 26)
+ a.reverse!
+ a = swap(a, 8)
+ a = swap(a, 61)
+ elsif base == "vflxuxnEY"
+ a.delete_at(0..2)
+ a.reverse!
+ c = a[0]
+ a[0] = a[49 % a.size]
+ a[49] = c
+ elsif base == "vflAXQwEj"
+ a = swap(a, 26)
+ a.reverse!
+ a = swap(a, 8)
+ a = swap(a, 61)
+ else
+ raise "Could not decrypt signature for player #{base}"
+ end
+
+ return a.join("")
+ end
end
def rank_videos(db, n)