ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.23k stars 10.03k forks source link

[Request] support for npo.nl live videostreams #4691

Closed Reino17 closed 9 years ago

Reino17 commented 9 years ago

My last request for now, because I'm asking a lot. For complete npo.nl support, I was wondering if it's possible for youtube-dl to generate npo.nl live video-stream-urls, and only generate these urls, since live-streams can't be downloaded. Npo.nl has the following live-streams: http://www.npo.nl/live/npo-1 http://www.npo.nl/live/npo-2 http://www.npo.nl/live/npo-3 http://www.npo.nl/live/npo-nieuws http://www.npo.nl/live/npo-politiek http://www.npo.nl/live/npo-best http://www.npo.nl/live/npo-doc http://www.npo.nl/live/npo-101 http://www.npo.nl/live/npo-cultura http://www.npo.nl/live/npo-zappxtra http://www.npo.nl/live/npo-humor-tv

Youtube-dl at the moment:

D:\youtube-dl-master>python -m youtube_dl -vg http://www.npo.nl/live/npo-1
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-vg', 'http://www.npo.nl/live/npo-1']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2015.01.11
[debug] Python version 3.4.2 - Windows-XP-5.1.2600-SP3
[debug] exe versions: none
[debug] Proxy map: {}
WARNING: Falling back on generic information extractor.
ERROR: Unsupported URL: http://www.npo.nl/live/npo-1
Traceback (most recent call last):
  File "D:\youtube-dl-master\youtube_dl\YoutubeDL.py", line 600, in extract_info
    ie_result = ie.extract(url)
  File "D:\youtube-dl-master\youtube_dl\extractor\common.py", line 260, in extract
    return self._real_extract(url)
  File "D:\youtube-dl-master\youtube_dl\extractor\generic.py", line 1075, in _real_extract
    raise UnsupportedError(url)
youtube_dl.utils.UnsupportedError: Unsupported URL: http://www.npo.nl/live/npo-1

Please visit this helpdeskweb.nl-website, because this guy has already done most of the work. The focus here is one the list of "Genereer link"-links, line 171-173 of the html-source:

<div id='channel-wrapper'>(geen URL's zichtbaar? Probeer CTRL+F5)<script type="text/javascript">
   $('#channel-wrapper').html(generateTable()); 
</script></div>

...and the corresponding javascript in http://www.helpdeskweb.nl/script.js:

function getStream(url,id){
  $("#"+id).html('Bezig...');

  $.getScript("http://ida.omroep.nl/npoplayer/i.js", function(){
    var url2 = "http://ida.omroep.nl/aapi/?type=jsonp&callback=?&stream=" + encodeURIComponent(url) + "&token=" + npoplayer.token;                              
    $.getJSON(url2, function(jsonx){   
      $.ajax({ dataType: 'jsonp',
        url:jsonx.stream,
        jsonp: "callback",
        success:function(json2){                           
          $("#"+id).html("<input type='text' readonly='readonly' value='"+json2+"' onclick=\"this.setSelectionRange(0, this.value.length)\"></input>");   
        }
      });                     
    }); 
  });
}

function generateTable(){
  var output = "<table border='0' style='width: 100%;'>";

  var channels    = {"Nederland 1":"http://livestreams.omroep.nl/live/npo/tvlive/ned1/ned1.isml/ned1.m3u8", 
                     "Nederland 2":"http://livestreams.omroep.nl/live/npo/tvlive/ned2/ned2.isml/ned2.m3u8", 
                     "Nederland 3":"http://livestreams.omroep.nl/live/npo/tvlive/ned3/ned3.isml/ned3.m3u8",
                     "NPO Nieuws":"http://livestreams.omroep.nl/live/npo/thematv/journaal24/journaal24.isml/journaal24.m3u8",
                     "NPO Politiek":"http://livestreams.omroep.nl/live/npo/thematv/politiek24/politiek24.isml/politiek24.m3u8",
                     "NPO Best":"http://livestreams.omroep.nl/live/npo/thematv/best24/best24.isml/best24.m3u8",
                     "NPO Doc":"http://livestreams.omroep.nl/live/npo/thematv/hollanddoc24/hollanddoc24.isml/hollanddoc24.m3u8",
                     "NPO 101":"http://livestreams.omroep.nl/live/npo/thematv/101tv/101tv.isml/101tv.m3u8",
                     "NPO Cultura":"http://livestreams.omroep.nl/live/npo/thematv/cultura24/cultura24.isml/cultura24.m3u8",
                     "NPO Zapp Xtra":"http://livestreams.omroep.nl/live/npo/thematv/zappelin24/zappelin24.isml/zappelin24.m3u8",
                     "NPO Humor tv":"http://livestreams.omroep.nl/live/npo/thematv/humor24/humor24.isml/humor24.m3u8"};
  var keys = $.map( channels, function( value, key ) {
    var name = key.replace(/ /g, '-');
    output += "<tr><td class='channel'>"+key+"</td><td class='url' id='"+name+"'><a href='javascript:' onclick=\"getStream('"+value+"','"+name+"')\">Genereer link</a></td></tr>";
  });
  return output + '</table>';                      
}

For http://www.npo.nl/live/npo-1 (Nederland 1) for instance it generates the following temporary(!) manifest-url: http://l2cmb7eb7ed22b0054b46076000000.fde6e2a445ca7074.kpnsmoote1e.npostreaming.nl/d/live/npo/tvlive/ned1/ned1.isml/ned1.m3u8. ...after which the live videostream-urls after a self._extract_m3u8_formats() will be: http://l2cmb7eb7ed22b0054b46076000000.fde6e2a445ca7074.kpnsmoote1e.npostreaming.nl/d/live/npo/tvlive/ned1/ned1.isml/ned1-audio=64000-video=200000.m3u8 http://l2cmb7eb7ed22b0054b46076000000.fde6e2a445ca7074.kpnsmoote1e.npostreaming.nl/d/live/npo/tvlive/ned1/ned1.isml/ned1-audio=128000-video=500000.m3u8 http://l2cmb7eb7ed22b0054b46076000000.fde6e2a445ca7074.kpnsmoote1e.npostreaming.nl/d/live/npo/tvlive/ned1/ned1.isml/ned1-audio=128000-video=700000.m3u8 http://l2cmb7eb7ed22b0054b46076000000.fde6e2a445ca7074.kpnsmoote1e.npostreaming.nl/d/live/npo/tvlive/ned1/ned1.isml/ned1-audio=128000-video=900000.m3u8 http://l2cmb7eb7ed22b0054b46076000000.fde6e2a445ca7074.kpnsmoote1e.npostreaming.nl/d/live/npo/tvlive/ned1/ned1.isml/ned1-audio=128000.m3u8

Is this possible with youtube-dl? Could this code be translated to python?

dstftw commented 9 years ago

npo live streams will be supported in the next version. Thanks for the report.

Reino17 commented 9 years ago

Absolutely fantastic! The urls work and with ffmpeg in place one can even 'record'. Thanks a million for your hard work!

malekairmaroc7 commented 7 years ago

Didn't work any more