Skip to content

Commit

Permalink
[YouTube] Convert signature timestamp to integer
Browse files Browse the repository at this point in the history
The signature timestamp is used as a number by HTML5 clients, so it should be
used in the same way by the extractor too instead of being a string.

As the timestamp doesn't seem to exceed 5 digits, an integer is used to store
its value.
  • Loading branch information
AudricV committed Sep 18, 2023
1 parent 8483b74 commit 6940913
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class YoutubeJavaScriptPlayerManager {
private static String cachedJavaScriptPlayerCode;

@Nullable
private static String cachedSignatureTimestamp;
private static Integer cachedSignatureTimestamp;
@Nullable
private static String cachedSignatureDeobfuscationFunction;
@Nullable
Expand Down Expand Up @@ -76,7 +76,7 @@ private YoutubeJavaScriptPlayerManager() {
* signature timestamp failed
*/
@Nonnull
public static String getSignatureTimestamp(@Nonnull final String videoId)
public static Integer getSignatureTimestamp(@Nonnull final String videoId)
throws ParsingException {
// Return the cached result if it is present
if (cachedSignatureTimestamp != null) {
Expand All @@ -93,8 +93,8 @@ public static String getSignatureTimestamp(@Nonnull final String videoId)
extractJavaScriptCodeIfNeeded(videoId);

try {
cachedSignatureTimestamp = YoutubeSignatureUtils.getSignatureTimestamp(
cachedJavaScriptPlayerCode);
cachedSignatureTimestamp = Integer.valueOf(
YoutubeSignatureUtils.getSignatureTimestamp(cachedJavaScriptPlayerCode));
} catch (final ParsingException e) {
// Store the exception for future calls of this method, in order to improve performance
sigTimestampExtractionEx = e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ public static byte[] createDesktopPlayerBody(
@Nonnull final Localization localization,
@Nonnull final ContentCountry contentCountry,
@Nonnull final String videoId,
@Nonnull final String sts,
@Nonnull final Integer sts,
final boolean isTvHtml5DesktopJsonBuilder,
@Nonnull final String contentPlaybackNonce) throws IOException, ExtractionException {
// @formatter:off
Expand Down

0 comments on commit 6940913

Please sign in to comment.