Repository: ytdl-org/youtube-dl

Issue:
Handle protocol-relative URLs
Trying to download http://www.funnyordie.com/videos/ea20db28f8/kristen-stewart-jesse-eisenberg-interview-each-other (warning: autostarting video) fails with:

```
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-v', u'http://www.funnyordie.com/videos/ea20db28f8/kristen-stewart-jesse-eisenberg-interview-each-other']
[debug] Encodings: locale utf-8, fs utf-8, out utf-8, pref utf-8
[debug] youtube-dl version 2015.07.28
[debug] Python version 2.7.10 - Darwin-13.4.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 2.7.2, ffprobe 2.7.2, rtmpdump 2.4
[debug] Proxy map: {}
[FunnyOrDie] ea20db28f8: Downloading webpage
[debug] Invoking downloader on u'//vo.fod4.com/v/ea20db28f8/v2500.mp4'
Traceback (most recent call last):
  File "/opt/local/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 "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/opt/local/bin/youtube-dl/__main__.py", line 19, in <module>
  File "/opt/local/bin/youtube-dl/youtube_dl/__init__.py", line 410, in main
  File "/opt/local/bin/youtube-dl/youtube_dl/__init__.py", line 400, in _real_main
  File "/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1504, in download
  File "/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 667, in extract_info
  File "/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 713, in process_ie_result
  File "/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1174, in process_video_result
  File "/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1436, in process_info
  File "/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1378, in dl
  File "/opt/local/bin/youtube-dl/youtube_dl/downloader/common.py", line 342, in download
  File "/opt/local/bin/youtube-dl/youtube_dl/downloader/http.py", line 59, in real_download
  File "/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1732, in urlopen
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 423, in open
    protocol = req.get_type()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 285, in get_type
    raise ValueError, "unknown url type: %s" % self.__original
ValueError: unknown url type: //vo.fod4.com/v/ea20db28f8/v2500.mp4
```

Plugging the url into wget (with a scheme) correctly downloads the video so youtube-dl finds it just fine, it just needs to resolve the protocol-relative URL by re-using the protocol of the source page.



Discussion:

Resolving patch:
diff --git a/youtube_dl/extractor/funnyordie.py b/youtube_dl/extractor/funnyordie.py
--- a/youtube_dl/extractor/funnyordie.py
+++ b/youtube_dl/extractor/funnyordie.py
@@ -53,7 +53,7 @@ def _real_extract(self, url):
         for bitrate in bitrates:
             for link in links:
                 formats.append({
-                    'url': '%s%d.%s' % (link[0], bitrate, link[1]),
+                    'url': self._proto_relative_url('%s%d.%s' % (link[0], bitrate, link[1])),
                     'format_id': '%s-%d' % (link[1], bitrate),
                     'vbr': bitrate,
                 })


Test patch: