Repository: ytdl-org/youtube-dl

Issue:
Ustream extractor does not recognize URLs of the form www.ustream.tv/embed/recorded/<ID>
The ustream extractor looks for URLs with either 'embed' or 'recorded', but Ustream allows sites to embed with URLs of this form:
http://www.ustream.tv/embed/recorded/44195705

An example is at http://inside.twit.tv/blog/2014/5/14/ustream-goes-behind-the-scenes-at-twit.html, which gives this result from youtube_dl:

python -m youtube_dl --skip-download --write-info-json -v http://inside.twit.tv/blog/2014/5/14/ustream-goes-behind-the-scenes-at-twit.html
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['--skip-download', '--write-info-json', '-v', 'http://inside.twit.tv/blog/2014/5/14/ustream-goes-behind-the-scenes-at-twit.html']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2014.05.13
[debug] Python version 2.7.5 - Darwin-13.2.0-x86_64-i386-64bit
[debug] Proxy map: {}
[generic] ustream-goes-behind-the-scenes-at-twit: Requesting header
WARNING: Falling back on generic information extractor.
[generic] ustream-goes-behind-the-scenes-at-twit: Downloading webpage
[generic] ustream-goes-behind-the-scenes-at-twit: Extracting information
ERROR: no suitable InfoExtractor for URL http://www.ustream.tv/embed/recorded/44195705?v=3&amp;wmode=direct#to13:09
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/jill/june/.virtualenv/lib/python2.7/site-packages/youtube_dl/__main__.py", line 18, in <module>
    youtube_dl.main()
  File "/Users/jill/june/.virtualenv/lib/python2.7/site-packages/youtube_dl/**init**.py", line 849, in main
    _real_main(argv)
  File "/Users/jill/june/.virtualenv/lib/python2.7/site-packages/youtube_dl/__init__.py", line 839, in _real_main
    retcode = ydl.download(all_urls)
  File "/Users/jill/june/.virtualenv/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 1039, in download
    self.extract_info(url)
  File "/Users/jill/june/.virtualenv/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 527, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/Users/jill/june/.virtualenv/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 571, in process_ie_result
    extra_info=extra_info)
  File "/Users/jill/june/.virtualenv/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 542, in extract_info
    self.report_error('no suitable InfoExtractor for URL %s' % url)
  File "/Users/jill/june/.virtualenv/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 405, in report_error
    self.trouble(error_message, tb)
  File "/Users/jill/june/.virtualenv/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 367, in trouble
    tb_data = traceback.format_list(traceback.extract_stack())



Discussion:

Resolving patch:
diff --git a/youtube_dl/extractor/ustream.py b/youtube_dl/extractor/ustream.py
--- a/youtube_dl/extractor/ustream.py
+++ b/youtube_dl/extractor/ustream.py
@@ -11,7 +11,7 @@
 
 
 class UstreamIE(InfoExtractor):
-    _VALID_URL = r'https?://www\.ustream\.tv/(?P<type>recorded|embed)/(?P<videoID>\d+)'
+    _VALID_URL = r'https?://www\.ustream\.tv/(?P<type>recorded|embed|embed/recorded)/(?P<videoID>\d+)'
     IE_NAME = 'ustream'
     _TEST = {
         'url': 'http://www.ustream.tv/recorded/20274954',
@@ -25,6 +25,13 @@ class UstreamIE(InfoExtractor):
 
     def _real_extract(self, url):
         m = re.match(self._VALID_URL, url)
+        video_id = m.group('videoID')
+
+        if m.group('type') == 'embed/recorded': # some sites use this embed format (see: http://github.com/rg3/youtube-dl/issues/2990)
+            video_id = m.group('videoID')
+            webpage = self._download_webpage(url, video_id, note="Downloading embedded Ustream page")
+            desktop_url = 'http://www.ustream.tv/recorded/' + video_id
+            return self.url_result(desktop_url, 'Ustream')
         if m.group('type') == 'embed':
             video_id = m.group('videoID')
             webpage = self._download_webpage(url, video_id)
@@ -32,8 +39,6 @@ def _real_extract(self, url):
             desktop_url = 'http://www.ustream.tv/recorded/' + desktop_video_id
             return self.url_result(desktop_url, 'Ustream')
 
-        video_id = m.group('videoID')
-
         video_url = 'http://tcdn.ustream.tv/video/%s' % video_id
         webpage = self._download_webpage(url, video_id)
 


Test patch: