首页 > 解决方案 > capture HLS Stream URL From Webview Android

问题描述

so I am trying to get the ".m3u8" link from an Embed Video (JWplayer) programmatically from my java android app, the source code of the embed page is obfuscated with this "adilbo_HTML_encoder" here's what i get from chrome View-Source :

<script type="text/javascript" language="Javascript">
    var adilbo_HTML_encoder_DYk ='';
    var hide_my_HTML_WiO=bzIwNFI.WDE1OFg.bTEyOGc.czEwNlM.UDE1NkM.QjIwMGo.dzIxMkQ.SzIwNVY.VjIwNFc.dzE1OFg.bzEyOGE.eTEwNmc.'+'eDEwNVI.bTE1Nk............................etc

so trying to get the URL with Jsoup won't work. what I tried :

1- De-obfuscating the code which was a fail ( if anyone know how please help ).

2-i noticed that Internet Download manager and a chrome extension named "Hls downloader" on my pc can successfully capture the .m3u8 link then I tried using another network extension named "Network sniffer" to capture the html requests and responses on page load ; I found some requests and responses to and from the famous wanted ".m3u8" streaming URL which is by the way secured with a token=XXXXXXXX and expiry=XXXXXX , so in my android app i tried to open the embed URL in a hidden WebView and try to get the streaming URL from there,

I tried using "onLoadResource" and "shouldInterceptRequest" methods to capture the URL but no success here is my code :

  hddwebview.setVisibility(View.GONE);
    hddwebview.setWebChromeClient(new WebChromeClient());
    hddwebview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

    hddwebview.getSettings().setJavaScriptEnabled(true);
    hddwebview.loadUrl(url);

    hddwebview.getSettings().setDomStorageEnabled(true);
    hddwebview.setWebViewClient(new WebViewClient() {
        @Override
        public void onLoadResource(WebView view, String url) {
            if(url.contains("/hls/")){
                wantedurl=url;   }

            super.onLoadResource(view, url);
        }

     //   @Nullable
    //    @Override
     //   public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
      //      if(url.contains("/hls/")){
                wantedurl=url;  
      //      }
     //       return super.shouldInterceptRequest(view, url);

    //    }

So what I need : a way to get the hls ".m3u8" url From this embed URL ( from my android app ofc ) I searched for a library ( like an advanced browser )or an android opensource video downloader that can capture the URL Like SNAPTUBE for example. THANKS.

标签: androidvideodownloadstreaminghttp-live-streaming

解决方案


推荐阅读