[YouTube] Convert signature timestamp to integer
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.
This commit is contained in:
parent
7de3753a81
commit
a04bc320de
|
@ -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
|
||||
|
@ -76,7 +76,7 @@ public final class 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) {
|
||||
|
@ -93,12 +93,15 @@ public final class YoutubeJavaScriptPlayerManager {
|
|||
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;
|
||||
throw e;
|
||||
} catch (final NumberFormatException e) {
|
||||
sigTimestampExtractionEx =
|
||||
new ParsingException("Could not convert signature timestamp to a number", e);
|
||||
}
|
||||
|
||||
return cachedSignatureTimestamp;
|
||||
|
|
|
@ -1419,7 +1419,7 @@ public final class YoutubeParsingHelper {
|
|||
@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
|
||||
|
|
Loading…
Reference in New Issue