Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

Commit

Permalink
Adapt pattern to rare player mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
HaarigerHarald committed Sep 8, 2018
1 parent f965406 commit e5ef7d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Expand Up @@ -69,8 +69,8 @@ public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta videoMet
}
}
itag = ytFiles.keyAt(new Random().nextInt(ytFiles.size() - numNotDash) + numNotDash);
Log.d(EXTRACTOR_TEST_TAG, "Testing itag:" + itag);
testUrl = ytFiles.get(itag).getUrl();
Log.d(EXTRACTOR_TEST_TAG, "Testing itag: " + itag +", url:" + testUrl);
signal.countDown();
}
};
Expand Down Expand Up @@ -114,8 +114,8 @@ public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta videoMe
assertNotSame(0, videoMeta.getViewCount());
assertNotNull(ytFiles);
int itag = ytFiles.keyAt(new Random().nextInt(ytFiles.size()));
Log.d(EXTRACTOR_TEST_TAG, "Testing itag:" + itag);
testUrl = ytFiles.get(itag).getUrl();
Log.d(EXTRACTOR_TEST_TAG, "Testing itag: " + itag +", url:" + testUrl);
signal.countDown();
}
};
Expand Down
Expand Up @@ -80,12 +80,12 @@ public abstract class YouTubeExtractor extends AsyncTask<String, Void, SparseArr

private static final Pattern patItag = Pattern.compile("itag=([0-9]+?)([&,])");
private static final Pattern patEncSig = Pattern.compile("s=([0-9A-F|.]{10,}?)([&,\"])");
private static final Pattern patIsSigEnc = Pattern.compile("s%3D([0-9A-F|.]{10,}?)%26");
private static final Pattern patIsSigEnc = Pattern.compile("s%3D([0-9A-F|.]{10,}?)(%26|%2C)");
private static final Pattern patUrl = Pattern.compile("url=(.+?)([&,])");

private static final Pattern patVariableFunction = Pattern.compile("([{; =])([a-zA-Z$][a-zA-Z0-9$]{0,2})\\.([a-zA-Z$][a-zA-Z0-9$]{0,2})\\(");
private static final Pattern patFunction = Pattern.compile("([{; =])([a-zA-Z$_][a-zA-Z0-9$]{0,2})\\(");
private static final Pattern patDecryptionJsFile = Pattern.compile("jsbin\\\\/(player-(.+?).js)");
private static final Pattern patDecryptionJsFile = Pattern.compile("jsbin\\\\/(player(_ias)?-(.+?).js)");
private static final Pattern patSignatureDecFunction = Pattern.compile("\"signature\",(.{1,3}?)\\(.{1,10}?\\)");

private static final SparseArray<Format> FORMAT_MAP = new SparseArray<>();
Expand Down Expand Up @@ -314,6 +314,8 @@ private SparseArray<YtFile> getStreamUrls() throws IOException, InterruptedExcep
mat = patDecryptionJsFile.matcher(streamMap);
if (mat.find()) {
curJsFileName = mat.group(1).replace("\\/", "/");
if (mat.group(2) != null)
curJsFileName.replace(mat.group(2), "");
if (decipherJsFileName == null || !decipherJsFileName.equals(curJsFileName)) {
decipherFunctions = null;
decipherFunctionName = null;
Expand Down Expand Up @@ -392,7 +394,7 @@ private SparseArray<YtFile> getStreamUrls() throws IOException, InterruptedExcep

if (encSignatures != null) {
if (LOGGING)
Log.d(LOG_TAG, "Decipher signatures");
Log.d(LOG_TAG, "Decipher signatures: " + encSignatures.size()+ ", videos: " + ytFiles.size());
String signature;
decipheredSignature = null;
if (decipherSignature(encSignatures)) {
Expand Down

0 comments on commit e5ef7d6

Please sign in to comment.