Repository: ytdl-org/youtube-dl

Issue:
[NBC Nightly News] IndexError: list index out of range
## Please follow the guide below

- You will be asked some questions and requested to provide some information, please read them **carefully** and answer honestly
- Put an `x` into all the boxes [ ] relevant to your *issue* (like this: `[x]`)
- Use the *Preview* tab to see what your issue will actually look like

---

### Make sure you are using the *latest* version: run `youtube-dl --version` and ensure your version is *2018.04.09*. If it's not, read [this FAQ entry](https://github.com/rg3/youtube-dl/blob/master/README.md#how-do-i-update-youtube-dl) and update. Issues with outdated version will be rejected.
- [x] I've **verified** and **I assure** that I'm running youtube-dl **2018.04.09**

### Before submitting an *issue* make sure you have:
- [x] At least skimmed through the [README](https://github.com/rg3/youtube-dl/blob/master/README.md), **most notably** the [FAQ](https://github.com/rg3/youtube-dl#faq) and [BUGS](https://github.com/rg3/youtube-dl#bugs) sections
- [x] [Searched](https://github.com/rg3/youtube-dl/search?type=Issues) the bugtracker for similar issues including closed ones
- [x] Checked that provided video/audio/playlist URLs (if any) are alive and playable in a browser

### What is the purpose of your *issue*?
- [x] Bug report (encountered problems with youtube-dl)
- [ ] Site support request (request for adding support for a new site)
- [ ] Feature request (request for a new functionality)
- [ ] Question
- [ ] Other

---

### The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your *issue*

---

### If the purpose of this *issue* is a *bug report*, *site support request* or you are not completely sure provide the full verbose output as follows:

Add the `-v` flag to **your command line** you run youtube-dl with (`youtube-dl -v <your command line>`), copy the **whole** output and insert it here. It should look similar to one below (replace it with **your** log inserted between triple ```):

```
[nathaniel@vega ~]$ youtube-dl --version
2018.04.09
[nathaniel@vega ~]$ youtube-dl -v --id 'https://www.nbcnews.com/nightly-news/video/nightly-news-full-broadcast-march-6th-1178601539724'
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'--id', u'https://www.nbcnews.com/nightly-news/video/nightly-news-full-broadcast-march-6th-1178601539724']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2018.04.09
[debug] Python version 2.6.6 (CPython) - Linux-2.6.32-358.el6.x86_64-x86_64-with-centos-6.4-Final
[debug] exe versions: ffmpeg 2.6.2, ffprobe 2.6.2
[debug] Proxy map: {}
[NBCNews] 1178601539724: Downloading webpage
[ThePlatformFeed] nn_netcast_180306: Downloading JSON metadata
Traceback (most recent call last):
  File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File "/opt/youtube-dl/bin/youtube-dl/__main__.py", line 19, in <module>
  File "/opt/youtube-dl/bin/youtube-dl/youtube_dl/__init__.py", line 471, in main
  File "/opt/youtube-dl/bin/youtube-dl/youtube_dl/__init__.py", line 461, in _real_main
  File "/opt/youtube-dl/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1993, in download
  File "/opt/youtube-dl/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 800, in extract_info
  File "/opt/youtube-dl/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 866, in process_ie_result
  File "/opt/youtube-dl/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 789, in extract_info
  File "/opt/youtube-dl/bin/youtube-dl/youtube_dl/extractor/common.py", line 440, in extract
  File "/opt/youtube-dl/bin/youtube-dl/youtube_dl/extractor/theplatform.py", line 397, in _real_extract
  File "/opt/youtube-dl/bin/youtube-dl/youtube_dl/extractor/theplatform.py", line 332, in _extract_feed_info
IndexError: list index out of range
<end of log>
```

---

### If the purpose of this *issue* is a *site support request* please provide all kinds of example URLs support for which should be included (replace following example URLs by **yours**):
- Single video: https://www.nbcnews.com/nightly-news/video/nightly-news-full-broadcast-march-6th-1178601539724

Note that **youtube-dl does not support sites dedicated to [copyright infringement](https://github.com/rg3/youtube-dl#can-you-add-support-for-this-anime-video-site-or-site-which-shows-current-movies-for-free)**. In order for site support request to be accepted all provided example URLs should not violate any copyrights.

---

### Description of your *issue*, suggested solution and other information

Explanation of your *issue* in arbitrary form goes here. Please make sure the [description is worded well enough to be understood](https://github.com/rg3/youtube-dl#is-the-description-of-the-issue-itself-sufficient). Provide as much context and examples as possible.
If work on your *issue* requires account credentials please provide them or explain how one can obtain them.



youtube-dl works on almost every NBC Nightly News video, except for this one





Discussion:
I've looked into this (but still am inexperienced in opensource). Here's my findings:

- I replicated the bug: this url does not download.
- I found the url that contains the video data: https://msnbc.vo.llnwd.net/l1/video/h264/2017/low/nn_netcast_180306.Copy.01.mp4   this does work with youtube-dl.
- I found a way to get this url from the page's html: there's a <script> within the body of the page where
   var playlistData = {...}
   to get the uri from the json data: root.video.guid, which is "nn_netcast_180306.Copy.01.mp4"

But... 

Checking yesterday's news today, it appears youtube-dl works:
https://www.nbcnews.com/nightly-news/video/video-shows-inside-southwest-plane-before-emergency-landing-1215017027899

I'd recommend testing a few more times and if it continues to work then close it.
Multiple current videos are working on nbcnews.com

If it's worth it: we could add more error handling in parsing / better error message during "downloading JSON metadata" phase where this breaks*.  Not sure if this is worth it, could someone advise?

*: stack at break:
  File "c:\python27\lib\site-packages\youtube_dl\__init__.py", line 461, in _real_main
    retcode = ydl.download(all_urls)
  File "c:\python27\lib\site-packages\youtube_dl\YoutubeDL.py", line 1993, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "c:\python27\lib\site-packages\youtube_dl\YoutubeDL.py", line 800, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "c:\python27\lib\site-packages\youtube_dl\YoutubeDL.py", line 866, in process_ie_result
    extra_info=extra_info, download=False, process=False)
  File "c:\python27\lib\site-packages\youtube_dl\YoutubeDL.py", line 789, in extract_info
    ie_result = ie.extract(url)
  File "c:\python27\lib\site-packages\youtube_dl\extractor\common.py", line 440, in extract
    ie_result = self._real_extract(url)
  File "c:\python27\lib\site-packages\youtube_dl\extractor\theplatform.py", line 397, in _real_extract
    return self._extract_feed_info(provider_id, feed_id, filter_query, video_id)
  File "c:\python27\lib\site-packages\youtube_dl\extractor\theplatform.py", line 332, in _extract_feed_info
    entry = self._download_json(real_url, video_id)['entries'][0]

Resolving patch:
diff --git a/youtube_dl/extractor/theplatform.py b/youtube_dl/extractor/theplatform.py
--- a/youtube_dl/extractor/theplatform.py
+++ b/youtube_dl/extractor/theplatform.py
@@ -310,7 +310,7 @@ def _real_extract(self, url):
 
 class ThePlatformFeedIE(ThePlatformBaseIE):
     _URL_TEMPLATE = '%s//feed.theplatform.com/f/%s/%s?form=json&%s'
-    _VALID_URL = r'https?://feed\.theplatform\.com/f/(?P<provider_id>[^/]+)/(?P<feed_id>[^?/]+)\?(?:[^&]+&)*(?P<filter>by(?:Gui|I)d=(?P<id>[\w-]+))'
+    _VALID_URL = r'https?://feed\.theplatform\.com/f/(?P<provider_id>[^/]+)/(?P<feed_id>[^?/]+)\?(?:[^&]+&)*(?P<filter>by(?:Gui|I)d=(?P<id>[^&]+))'
     _TESTS = [{
         # From http://player.theplatform.com/p/7wvmTC/MSNBCEmbeddedOffSite?guid=n_hardball_5biden_140207
         'url': 'http://feed.theplatform.com/f/7wvmTC/msnbc_video-p-test?form=json&pretty=true&range=-40&byGuid=n_hardball_5biden_140207',
@@ -327,6 +327,9 @@ class ThePlatformFeedIE(ThePlatformBaseIE):
             'categories': ['MSNBC/Issues/Democrats', 'MSNBC/Issues/Elections/Election 2016'],
             'uploader': 'NBCU-NEWS',
         },
+    }, {
+        'url': 'http://feed.theplatform.com/f/2E2eJC/nnd_NBCNews?byGuid=nn_netcast_180306.Copy.01',
+        'only_matching': True,
     }]
 
     def _extract_feed_info(self, provider_id, feed_id, filter_query, video_id, custom_fields=None, asset_types_query={}, account_id=None):


Test patch: