kopia lustrzana https://github.com/TeamNewPipe/NewPipeExtractor
Removed unused code
rodzic
2f2e2df5aa
commit
4c3918ac4c
|
@ -60,7 +60,6 @@ import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
|
|||
import org.schabi.newpipe.extractor.stream.AudioTrackType;
|
||||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||
import org.schabi.newpipe.extractor.utils.Parser;
|
||||
import org.schabi.newpipe.extractor.utils.ProtoBuilder;
|
||||
import org.schabi.newpipe.extractor.utils.RandomStringFromAlphabetGenerator;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
|
@ -235,23 +234,6 @@ public final class YoutubeParsingHelper {
|
|||
return url.getHost().equalsIgnoreCase("y2u.be");
|
||||
}
|
||||
|
||||
public static String randomVisitorData(final ContentCountry country) {
|
||||
final ProtoBuilder pbE2 = new ProtoBuilder();
|
||||
pbE2.string(2, "");
|
||||
pbE2.varint(4, numberGenerator.nextInt(255) + 1);
|
||||
|
||||
final ProtoBuilder pbE = new ProtoBuilder();
|
||||
pbE.string(1, country.getCountryCode());
|
||||
pbE.bytes(2, pbE2.toBytes());
|
||||
|
||||
final ProtoBuilder pb = new ProtoBuilder();
|
||||
pb.string(1, RandomStringFromAlphabetGenerator.generate(
|
||||
CONTENT_PLAYBACK_NONCE_ALPHABET, 11, numberGenerator));
|
||||
pb.varint(5, System.currentTimeMillis() / 1000 - numberGenerator.nextInt(600000));
|
||||
pb.bytes(6, pbE.toBytes());
|
||||
return pb.toUrlencodedBase64();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the duration string of the video expecting ":" or "." as separators
|
||||
*
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
package org.schabi.newpipe.extractor.utils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
public class ProtoBuilder {
|
||||
ByteArrayOutputStream byteBuffer;
|
||||
|
||||
public ProtoBuilder() {
|
||||
this.byteBuffer = new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
public byte[] toBytes() {
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toUrlencodedBase64() {
|
||||
final String b64 = Base64.getUrlEncoder().encodeToString(toBytes());
|
||||
return URLEncoder.encode(b64, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private void writeVarint(final long val) {
|
||||
try {
|
||||
if (val == 0) {
|
||||
byteBuffer.write(new byte[]{(byte) 0});
|
||||
} else {
|
||||
long v = val;
|
||||
while (v != 0) {
|
||||
byte b = (byte) (v & 0x7f);
|
||||
v >>= 7;
|
||||
|
||||
if (v != 0) {
|
||||
b |= (byte) 0x80;
|
||||
}
|
||||
byteBuffer.write(new byte[]{b});
|
||||
}
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void field(final int field, final byte wire) {
|
||||
final long fbits = ((long) field) << 3;
|
||||
final long wbits = ((long) wire) & 0x07;
|
||||
final long val = fbits | wbits;
|
||||
writeVarint(val);
|
||||
}
|
||||
|
||||
public void varint(final int field, final long val) {
|
||||
field(field, (byte) 0);
|
||||
writeVarint(val);
|
||||
}
|
||||
|
||||
public void string(final int field, final String string) {
|
||||
final byte[] strBts = string.getBytes(StandardCharsets.UTF_8);
|
||||
bytes(field, strBts);
|
||||
}
|
||||
|
||||
public void bytes(final int field, final byte[] bytes) {
|
||||
field(field, (byte) 2);
|
||||
writeVarint(bytes.length);
|
||||
try {
|
||||
byteBuffer.write(bytes);
|
||||
} catch (final IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package org.schabi.newpipe.extractor.utils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class ProtoBuilderTest {
|
||||
@Test
|
||||
public void testProtoBuilder() {
|
||||
final ProtoBuilder pb = new ProtoBuilder();
|
||||
pb.varint(1, 128);
|
||||
pb.varint(2, 1234567890);
|
||||
pb.varint(3, 1234567890123456789L);
|
||||
pb.string(4, "Hello");
|
||||
pb.bytes(5, new byte[]{1, 2, 3});
|
||||
assertEquals("CIABENKF2MwEGJWCpu_HnoSRESIFSGVsbG8qAwECAw%3D%3D", pb.toUrlencodedBase64());
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue