HaarigerHarald / android-youtubeExtractor

Deprecated: Android based YouTube URL extractor and downloader
Other
877 stars 304 forks source link

not extract video today again after ading "&html5=1" + "&c=TVHTML5"+ "&cver=6.20180913" #196

Open shailendra-rajpoot opened 3 years ago

shailendra-rajpoot commented 3 years ago

not extract video today again after ading "&html5=1" + "&c=TVHTML5"+ "&cver=6.20180913"

shailendra-rajpoot commented 3 years ago

java.io.FileNotFoundException: https://www.youtube.com/get_video_info?video_id=LvdAuNQs-eU&html5=1&c=TVHTML5&cver=6.20180913&eurl=https%3A%2F%2Fyoutube.googleapis.com%2Fv%2FLvdAuNQs-eU

saurabhgoyal795 commented 3 years ago

Any solution?

shailendra-rajpoot commented 3 years ago

plz anybody provide permanent solutions of this problem why this happen again and again ?

saurabhgoyal795 commented 3 years ago

Pls give solution for today?

nadishan commented 3 years ago

same issue here. Any thoughts on new changes?

thenandkishorkumawat commented 3 years ago

I'm also facing the same issue from morning any new script for this solution?

SushilBerwal commented 3 years ago

I'm also facing the same issue. Any solution?

kunwar295 commented 3 years ago

I'm also facing the same issue. ytFiles coming null. any solution ??

muthu1512 commented 3 years ago

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

saurabhgoyal795 commented 3 years ago

any solution??

zsg-ad commented 3 years ago

ytFiles always null

thenandkishorkumawat commented 3 years ago

any new update for this problem?

sssdevwebkit commented 3 years ago

I'm facing the same problem. Any solution.

andresayac commented 3 years ago

I have the same problem :(

thenandkishorkumawat commented 3 years ago

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";
gtxPrime commented 3 years ago

not extract video today again after ading "&html5=1" + "&c=TVHTML5"+ "&cver=6.20180913"

Have you got the solution ?

nadishan commented 3 years ago

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. 😎

prakashraooo commented 3 years ago

In key param u need to put your youtube api key

nadishan commented 3 years ago

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. 🙄

OmarDev01 commented 3 years ago

Hi Devs Does the code work now after the update??

prakashraooo commented 3 years ago

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 .

gtxPrime commented 3 years ago

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

inforaamitsolutions commented 3 years ago

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 getStreamUrls() throws IOException, InterruptedException, JSONException {

    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;
}
kunwar295 commented 3 years ago

library updated get the details from library

muthu1512 commented 3 years ago

Hi Devs Does the code work now after the update??

now its working for me.

OmarDev01 commented 3 years ago

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 ??

satish245 commented 3 years ago

Working when change network.

SushilBerwal commented 3 years ago

I am facing issue Youtube Live video url not working .Any solution.

xiao-lidia commented 3 years ago

any solution?