Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Commit

Permalink
Fixed Extraction of protected videos
Browse files Browse the repository at this point in the history
  • Loading branch information
nhCoder committed Jan 24, 2020
1 parent 680b776 commit e29179b
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Copy the classes or compile project.
- Mozilla Rhino
- UniversalVideoView(Used only for video testing)

Example
Usage

```
```Java
new YoutubeStreamExtractor(new YoutubeStreamExtractor.ExtractorListner(){
@Override
public void onExtractionDone(List adativeStream, final List muxedStream, YoutubeMeta meta) {
Expand All @@ -43,4 +43,4 @@ new YoutubeStreamExtractor(new YoutubeStreamExtractor.ExtractorListner(){

## For age restricted Videos

For extraction of age restricted videos use `useDefaultLogin()` to Use default cookie.. OR YOU CAN override with your own cookies by method `setHeaders`
For extraction of age restricted videos use `useDefaultLogin()` to Use default cookie.. OR YOU CAN override with your own cookies by method `setHeaders`
Binary file modified YoutubeExtractor/app/build/bin/app.apk
Binary file not shown.
Binary file modified YoutubeExtractor/app/build/bin/classes.dex
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,29 @@
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
import com.naveed.ytextractor.utils.Utils;

public class CipherManager {

private static final String RegexDesipherFunctionCode="\\{[a-zA-Z]{1,}=[a-zA-Z]{1,}\\.split\\(\"\"\\).*?\\};";
private static final String RegexDesipherFunctionCode="\\{[a-zA-Z]{1,}=[a-zA-Z]{1,}.split\\(\"\"\\);[a-zA-Z0-9$]{2}\\.[a-zA-Z0-9$]{2}.*?[a-zA-Z]{1,}.join\\(\"\"\\)\\};";
private static final String RegexVarName="[a-zA-Z0-9$]{2}\\.[a-zA-Z0-9$]{2}\\([a-zA-Z]\\,(\\d\\d|\\d)\\)";
private static String RegexFindVarCode="";
private static String cachedDechiperFunction=null;



private static String getDecipherCode(String Basejs) {
public static String getDecipherCode(String Basejs) {
String DechipherCode;
String DecipherFun="decipher=function(a)" + RegexUtils.matchGroup(RegexDesipherFunctionCode, Basejs);
String RawName=RegexUtils.matchGroup(RegexVarName, DecipherFun).replace("$","\\$");;
//Utils.copyToBoard(Basejs);
LogUtils.log("decfun="+DecipherFun);
String RawName=RegexUtils.matchGroup(RegexVarName, DecipherFun).replace("$","\\$");
String RealVarName=RawName.split("\\.")[0];
RegexFindVarCode = "var\\s" + RealVarName + "=.*?\\};"; // Word 1
String varCode=RegexUtils.matchGroup(RegexFindVarCode, Basejs);
DechipherCode = DecipherFun + "\n" + varCode;
//LogUtils.log("code= "+DechipherCode);
LogUtils.log("code= "+DechipherCode);

return DechipherCode;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected Void doInBackground(String[] ids) {

PlayerResponse playerResponse=parseJson(jsonBody);
ytmeta = playerResponse.getVideoDetails();
//Utils.copyToBoard(playerResponse.getStreamingData().);
//Utils.copyToBoard(jsonBody);
if (playerResponse.getVideoDetails().getisLive()) {
parseLiveUrls(playerResponse.getStreamingData());
} else {
Expand All @@ -122,7 +122,7 @@ protected Void doInBackground(String[] ids) {
}
}
catch (Exception e) {
LogUtils.log(Arrays.toString(e.getStackTrace()));// e.toString());
LogUtils.log(Arrays.toString(e.getStackTrace()));
Ex = new ExtractorException("Error While getting Youtube Data:" + e.getMessage());
this.cancel(true);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ private List<YTMedia> parseUrls(YTMedia[] rawMedia) {

if (partCipher.startsWith("url=")) {
tempUrl = URLDecoder.decode(partCipher.replace("url=", ""));

for (String url_part:tempUrl.split("&")) {
if (url_part.startsWith("s=")) {
decodedSig = CipherManager.dechiperSig(URLDecoder.decode(url_part.replace("s=", "")), response.getAssets().getJs());
Expand All @@ -184,6 +184,7 @@ private List<YTMedia> parseUrls(YTMedia[] rawMedia) {
}

String FinalUrl= tempUrl + "&sig=" + decodedSig;

media.setUrl(FinalUrl);
links.add(media);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class Assets {
public String getJs() {
if(js.startsWith("http")&&js.contains("youtube.com")){
return js;
}else return "https://youtube.com"+js;
}else return "https://www.youtube.com"+js;
}

public void setJs(String js) {
Expand Down

0 comments on commit e29179b

Please sign in to comment.