Open shailendra-rajpoot opened 3 years ago
Any solution?
plz anybody provide permanent solutions of this problem why this happen again and again ?
Pls give solution for today?
same issue here. Any thoughts on new changes?
I'm also facing the same issue from morning any new script for this solution?
I'm also facing the same issue. Any solution?
I'm also facing the same issue. ytFiles coming null. any solution ??
Hi am also facing this same issue. Plz give solution for this. Always ytfiles comes null.
Attempt to invoke virtual method 'int android.util.SparseArray.size()' on a null object reference
any solution??
ytFiles always null
any new update for this problem?
I'm facing the same problem. Any solution.
I have the same problem :(
old ytInfoUrl += "www.youtube.com/get_video_info?video_id=" + videoID + "&eurl="
URLEncoder.encode("https://youtube.googleapis.com/v/" + videoID, "UTF-8") +"&html5=1&c=TVHTML5&cver=6.20180913"; and i update new ytInfoUrl but not working
ytInfoUrl += "www.youtube.com/get_video_info?video_id=" + videoID + "&eurl="
+ URLEncoder.encode("https://www.youtube.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8/" + videoID, "UTF-8")
+"&html5=1&c=TVHTML5&cver=6.20180913";
not extract video today again after ading "&html5=1" + "&c=TVHTML5"+ "&cver=6.20180913"
Have you got the solution ?
old ytInfoUrl += "www.youtube.com/get_video_info?video_id=" + videoID + "&eurl="
URLEncoder.encode("https://youtube.googleapis.com/v/" + videoID, "UTF-8") +"&html5=1&c=TVHTML5&cver=6.20180913"; and i update new ytInfoUrl but not working
ytInfoUrl += "www.youtube.com/get_video_info?video_id=" + videoID + "&eurl=" + URLEncoder.encode("https://www.youtube.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8/" + videoID, "UTF-8") +"&html5=1&c=TVHTML5&cver=6.20180913";
I saw this solution on Stackoverflow too. Postman returns a success payload for this. But dunno what is the key query param mean. 😎
In key param u need to put your youtube api key
In key param u need to put your youtube api key Are you sure about it? I don't think YT API keys will work with it. 🙄
Hi Devs Does the code work now after the update??
No brother its not working .
On Sun, Jul 25, 2021, 2:36 PM OmarDev01 @.***> wrote:
Hi Devs Does the code work now after the update??
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HaarigerHarald/android-youtubeExtractor/issues/196#issuecomment-886170896, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANXMWA3OQKWLEJXTRCGPHPLTZPH23ANCNFSM5AZEHHJA .
Hi Devs Does the code work now after the update??
it is working in 1 of my projects but not on others, please fix it fast, its a request
replace your getStreamUrls method with below and add this parameters:
private static final Pattern patPlayerResponse = Pattern.compile("var ytInitialPlayerResponse\s=\s(\{.+?\})\s*;"); private static final Pattern patSigEncUrl = Pattern.compile("url=(.+?)(\u0026|$)"); private static final Pattern patSignature = Pattern.compile("s=(.+?)(\u0026|$)");
private SparseArray
String pageHtml;
SparseArray<String> encSignatures = new SparseArray<>();
SparseArray<YtFile> ytFiles = new SparseArray<>();
BufferedReader reader = null;
HttpURLConnection urlConnection = null;
URL getUrl = new URL("https://youtube.com/watch?v=" + videoID);
try {
urlConnection = (HttpURLConnection) getUrl.openConnection();
urlConnection.setRequestProperty("User-Agent", USER_AGENT);
reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
StringBuilder sbPageHtml = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
sbPageHtml.append(line);
}
pageHtml = sbPageHtml.toString();
} finally {
if (reader != null) {
reader.close();
}
if (urlConnection != null) {
urlConnection.disconnect();
}
}
Matcher mat = patPlayerResponse.matcher(pageHtml);
if (mat.find()) {
JSONObject ytPlayerResponse = new JSONObject(mat.group(1));
JSONObject streamingData = ytPlayerResponse.getJSONObject("streamingData");
JSONArray formats = streamingData.getJSONArray("formats");
for (int i = 0; i < formats.length(); i++) {
JSONObject format = formats.getJSONObject(i);
int itag = format.getInt("itag");
if (FORMAT_MAP.get(itag) != null) {
if (format.has("url")) {
String url = format.getString("url").replace("\\u0026", "&");
ytFiles.append(itag, new YtFile(FORMAT_MAP.get(itag), url));
} else if (format.has("signatureCipher")) {
mat = patSigEncUrl.matcher(format.getString("signatureCipher"));
Matcher matSig = patSignature.matcher(format.getString("signatureCipher"));
if (mat.find() && matSig.find()) {
String url = URLDecoder.decode(mat.group(1), "UTF-8");
String signature = URLDecoder.decode(matSig.group(1), "UTF-8");
ytFiles.append(itag, new YtFile(FORMAT_MAP.get(itag), url));
encSignatures.append(itag, signature);
}
}
}
}
JSONArray adaptiveFormats = streamingData.getJSONArray("adaptiveFormats");
for (int i = 0; i < adaptiveFormats.length(); i++) {
JSONObject adaptiveFormat = adaptiveFormats.getJSONObject(i);
int itag = adaptiveFormat.getInt("itag");
if (FORMAT_MAP.get(itag) != null) {
if (adaptiveFormat.has("url")) {
String url = adaptiveFormat.getString("url").replace("\\u0026", "&");
ytFiles.append(itag, new YtFile(FORMAT_MAP.get(itag), url));
} else if (adaptiveFormat.has("signatureCipher")) {
mat = patSigEncUrl.matcher(adaptiveFormat.getString("signatureCipher"));
Matcher matSig = patSignature.matcher(adaptiveFormat.getString("signatureCipher"));
if (mat.find() && matSig.find()) {
String url = URLDecoder.decode(mat.group(1), "UTF-8");
String signature = URLDecoder.decode(matSig.group(1), "UTF-8");
ytFiles.append(itag, new YtFile(FORMAT_MAP.get(itag), url));
encSignatures.append(itag, signature);
}
}
}
}
JSONObject videoDetails = ytPlayerResponse.getJSONObject("videoDetails");
this.videoMeta = new VideoMeta(videoDetails.getString("videoId"),
videoDetails.getString("title"),
videoDetails.getString("author"),
videoDetails.getString("channelId"),
Long.parseLong(videoDetails.getString("lengthSeconds")),
Long.parseLong(videoDetails.getString("viewCount")),
videoDetails.getBoolean("isLiveContent"),
videoDetails.getString("shortDescription"));
} else {
Log.d(LOG_TAG, "ytPlayerResponse was not found");
}
if (encSignatures.size() > 0) {
String curJsFileName;
if (CACHING
&& (decipherJsFileName == null || decipherFunctions == null || decipherFunctionName == null)) {
readDecipherFunctFromCache();
}
mat = patDecryptionJsFile.matcher(pageHtml);
if (!mat.find())
mat = patDecryptionJsFileWithoutSlash.matcher(pageHtml);
if (mat.find()) {
curJsFileName = mat.group(0).replace("\\/", "/");
if (decipherJsFileName == null || !decipherJsFileName.equals(curJsFileName)) {
decipherFunctions = null;
decipherFunctionName = null;
}
decipherJsFileName = curJsFileName;
}
if (LOGGING)
Log.d(LOG_TAG, "Decipher signatures: " + encSignatures.size() + ", videos: " + ytFiles.size());
String signature;
decipheredSignature = null;
if (decipherSignature(encSignatures)) {
lock.lock();
try {
jsExecuting.await(7, TimeUnit.SECONDS);
} finally {
lock.unlock();
}
}
signature = decipheredSignature;
if (signature == null) {
return null;
} else {
String[] sigs = signature.split("\n");
for (int i = 0; i < encSignatures.size() && i < sigs.length; i++) {
int key = encSignatures.keyAt(i);
String url = ytFiles.get(key).getUrl();
url += "&sig=" + sigs[i];
YtFile newFile = new YtFile(FORMAT_MAP.get(key), url);
ytFiles.put(key, newFile);
}
}
}
if (ytFiles.size() == 0) {
if (LOGGING)
Log.d(LOG_TAG, pageHtml);
return null;
}
return ytFiles;
}
library updated get the details from library
Hi Devs Does the code work now after the update??
now its working for me.
Hi Devs Does the code work now after the update??
now its working for me.
do you add or change something in your app code ??
Working when change network.
I am facing issue Youtube Live video url not working .Any solution.
any solution?
not extract video today again after ading "&html5=1" + "&c=TVHTML5"+ "&cver=6.20180913"