diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2024-08-07 23:23:24 +0200 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2024-08-07 23:26:10 +0200 |
| commit | cc36a8293359764c8df38605818242c60f41bbec (patch) | |
| tree | b7a891e97af914dcb07966b6a0bdf191cee1079c /src | |
| parent | 7798faf23425f11cee77742629ca589a5f33392b (diff) | |
| download | invidious-cc36a8293359764c8df38605818242c60f41bbec.tar.gz invidious-cc36a8293359764c8df38605818242c60f41bbec.tar.bz2 invidious-cc36a8293359764c8df38605818242c60f41bbec.zip | |
SigHelper: Fix some logic errors raised during code review
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/helpers/sig_helper.cr | 2 | ||||
| -rw-r--r-- | src/invidious/helpers/signatures.cr | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/invidious/helpers/sig_helper.cr b/src/invidious/helpers/sig_helper.cr index 13026321..9e72c1c7 100644 --- a/src/invidious/helpers/sig_helper.cr +++ b/src/invidious/helpers/sig_helper.cr @@ -144,7 +144,7 @@ module Invidious::SigHelper # Return when the player was last updated def get_player_timestamp : UInt64? - request = Request.new(Opcode::GET_SIGNATURE_TIMESTAMP, nil) + request = Request.new(Opcode::PLAYER_UPDATE_TIMESTAMP, nil) return self.send_request(request) do |bytes| IO::ByteFormat::NetworkEndian.decode(UInt64, bytes) diff --git a/src/invidious/helpers/signatures.cr b/src/invidious/helpers/signatures.cr index a2abf327..84a8a86d 100644 --- a/src/invidious/helpers/signatures.cr +++ b/src/invidious/helpers/signatures.cr @@ -15,11 +15,11 @@ class Invidious::DecryptFunction # If we have updated in the last 5 minutes, do nothing return if (now - @last_update) > 5.minutes - # Get the time when the player was updated, in the event where - # multiple invidious processes are run in parallel. - player_time = Time.unix(@client.get_player_timestamp || 0) + # Get the amount of time elapsed since when the player was updated, in the + # event where multiple invidious processes are run in parallel. + update_time_elapsed = (@client.get_player_timestamp || 301).seconds - if (now - player_time) > 5.minutes + if update_time_elapsed > 5.minutes LOGGER.debug("Signature: Player might be outdated, updating") @client.force_update @last_update = Time.utc |
