We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `youtube_dl/extractor/funnyordie.py`
Content:
```
1 from __future__ import unicode_literals
2 
3 import json
4 import re
5 
6 from .common import InfoExtractor
7 from ..utils import ExtractorError
8 
9 
10 class FunnyOrDieIE(InfoExtractor):
11     _VALID_URL = r'https?://(?:www\.)?funnyordie\.com/(?P<type>embed|articles|videos)/(?P<id>[0-9a-f]+)(?:$|[?#/])'
12     _TESTS = [{
13         'url': 'http://www.funnyordie.com/videos/0732f586d7/heart-shaped-box-literal-video-version',
14         'md5': 'bcd81e0c4f26189ee09be362ad6e6ba9',
15         'info_dict': {
16             'id': '0732f586d7',
17             'ext': 'mp4',
18             'title': 'Heart-Shaped Box: Literal Video Version',
19             'description': 'md5:ea09a01bc9a1c46d9ab696c01747c338',
20             'thumbnail': 're:^http:.*\.jpg$',
21         },
22     }, {
23         'url': 'http://www.funnyordie.com/embed/e402820827',
24         'info_dict': {
25             'id': 'e402820827',
26             'ext': 'mp4',
27             'title': 'Please Use This Song (Jon Lajoie)',
28             'description': 'Please use this to sell something.  www.jonlajoie.com',
29             'thumbnail': 're:^http:.*\.jpg$',
30         },
31     }, {
32         'url': 'http://www.funnyordie.com/articles/ebf5e34fc8/10-hours-of-walking-in-nyc-as-a-man',
33         'only_matching': True,
34     }]
35 
36     def _real_extract(self, url):
37         mobj = re.match(self._VALID_URL, url)
38 
39         video_id = mobj.group('id')
40         webpage = self._download_webpage(url, video_id)
41 
42         links = re.findall(r'<source src="([^"]+/v)[^"]+\.([^"]+)" type=\'video', webpage)
43         if not links:
44             raise ExtractorError('No media links available for %s' % video_id)
45 
46         links.sort(key=lambda link: 1 if link[1] == 'mp4' else 0)
47 
48         bitrates = self._html_search_regex(r'<source src="[^"]+/v,((?:\d+,)+)\.mp4\.csmil', webpage, 'video bitrates')
49         bitrates = [int(b) for b in bitrates.rstrip(',').split(',')]
50         bitrates.sort()
51 
52         formats = []
53         for bitrate in bitrates:
54             for link in links:
55                 formats.append({
56                     'url': '%s%d.%s' % (link[0], bitrate, link[1]),
57                     'format_id': '%s-%d' % (link[1], bitrate),
58                     'vbr': bitrate,
59                 })
60 
61         subtitles = {}
62         for src, src_lang in re.findall(r'<track kind="captions" src="([^"]+)" srclang="([^"]+)"', webpage):
63             subtitles[src_lang] = [{
64                 'ext': src.split('/')[-1],
65                 'url': 'http://www.funnyordie.com%s' % src,
66             }]
67 
68         post_json = self._search_regex(
69             r'fb_post\s*=\s*(\{.*?\});', webpage, 'post details')
70         post = json.loads(post_json)
71 
72         return {
73             'id': video_id,
74             'title': post['name'],
75             'description': post.get('description'),
76             'thumbnail': post.get('picture'),
77             'formats': formats,
78             'subtitles': subtitles,
79         }
80
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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 @@
         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,
                 })

{"golden_diff": "diff --git a/youtube_dl/extractor/funnyordie.py b/youtube_dl/extractor/funnyordie.py\n--- a/youtube_dl/extractor/funnyordie.py\n+++ b/youtube_dl/extractor/funnyordie.py\n@@ -53,7 +53,7 @@\n         for bitrate in bitrates:\n             for link in links:\n                 formats.append({\n-                    'url': '%s%d.%s' % (link[0], bitrate, link[1]),\n+                    'url': self._proto_relative_url('%s%d.%s' % (link[0], bitrate, link[1])),\n                     'format_id': '%s-%d' % (link[1], bitrate),\n                     'vbr': bitrate,\n                 })\n", "issue": "Handle protocol-relative URLs\nTrying to download http://www.funnyordie.com/videos/ea20db28f8/kristen-stewart-jesse-eisenberg-interview-each-other (warning: autostarting video) fails with:\n\n```\n[debug] System config: []\n[debug] User config: []\n[debug] Command-line args: [u'-v', u'http://www.funnyordie.com/videos/ea20db28f8/kristen-stewart-jesse-eisenberg-interview-each-other']\n[debug] Encodings: locale utf-8, fs utf-8, out utf-8, pref utf-8\n[debug] youtube-dl version 2015.07.28\n[debug] Python version 2.7.10 - Darwin-13.4.0-x86_64-i386-64bit\n[debug] exe versions: ffmpeg 2.7.2, ffprobe 2.7.2, rtmpdump 2.4\n[debug] Proxy map: {}\n[FunnyOrDie] ea20db28f8: Downloading webpage\n[debug] Invoking downloader on u'//vo.fod4.com/v/ea20db28f8/v2500.mp4'\nTraceback (most recent call last):\n  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py\", line 162, in _run_module_as_main\n    \"__main__\", fname, loader, pkg_name)\n  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py\", line 72, in _run_code\n    exec code in run_globals\n  File \"/opt/local/bin/youtube-dl/__main__.py\", line 19, in <module>\n  File \"/opt/local/bin/youtube-dl/youtube_dl/__init__.py\", line 410, in main\n  File \"/opt/local/bin/youtube-dl/youtube_dl/__init__.py\", line 400, in _real_main\n  File \"/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py\", line 1504, in download\n  File \"/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py\", line 667, in extract_info\n  File \"/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py\", line 713, in process_ie_result\n  File \"/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py\", line 1174, in process_video_result\n  File \"/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py\", line 1436, in process_info\n  File \"/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py\", line 1378, in dl\n  File \"/opt/local/bin/youtube-dl/youtube_dl/downloader/common.py\", line 342, in download\n  File \"/opt/local/bin/youtube-dl/youtube_dl/downloader/http.py\", line 59, in real_download\n  File \"/opt/local/bin/youtube-dl/youtube_dl/YoutubeDL.py\", line 1732, in urlopen\n  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py\", line 423, in open\n    protocol = req.get_type()\n  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py\", line 285, in get_type\n    raise ValueError, \"unknown url type: %s\" % self.__original\nValueError: unknown url type: //vo.fod4.com/v/ea20db28f8/v2500.mp4\n```\n\nPlugging 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.\n\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nimport json\nimport re\n\nfrom .common import InfoExtractor\nfrom ..utils import ExtractorError\n\n\nclass FunnyOrDieIE(InfoExtractor):\n    _VALID_URL = r'https?://(?:www\\.)?funnyordie\\.com/(?P<type>embed|articles|videos)/(?P<id>[0-9a-f]+)(?:$|[?#/])'\n    _TESTS = [{\n        'url': 'http://www.funnyordie.com/videos/0732f586d7/heart-shaped-box-literal-video-version',\n        'md5': 'bcd81e0c4f26189ee09be362ad6e6ba9',\n        'info_dict': {\n            'id': '0732f586d7',\n            'ext': 'mp4',\n            'title': 'Heart-Shaped Box: Literal Video Version',\n            'description': 'md5:ea09a01bc9a1c46d9ab696c01747c338',\n            'thumbnail': 're:^http:.*\\.jpg$',\n        },\n    }, {\n        'url': 'http://www.funnyordie.com/embed/e402820827',\n        'info_dict': {\n            'id': 'e402820827',\n            'ext': 'mp4',\n            'title': 'Please Use This Song (Jon Lajoie)',\n            'description': 'Please use this to sell something.  www.jonlajoie.com',\n            'thumbnail': 're:^http:.*\\.jpg$',\n        },\n    }, {\n        'url': 'http://www.funnyordie.com/articles/ebf5e34fc8/10-hours-of-walking-in-nyc-as-a-man',\n        'only_matching': True,\n    }]\n\n    def _real_extract(self, url):\n        mobj = re.match(self._VALID_URL, url)\n\n        video_id = mobj.group('id')\n        webpage = self._download_webpage(url, video_id)\n\n        links = re.findall(r'<source src=\"([^\"]+/v)[^\"]+\\.([^\"]+)\" type=\\'video', webpage)\n        if not links:\n            raise ExtractorError('No media links available for %s' % video_id)\n\n        links.sort(key=lambda link: 1 if link[1] == 'mp4' else 0)\n\n        bitrates = self._html_search_regex(r'<source src=\"[^\"]+/v,((?:\\d+,)+)\\.mp4\\.csmil', webpage, 'video bitrates')\n        bitrates = [int(b) for b in bitrates.rstrip(',').split(',')]\n        bitrates.sort()\n\n        formats = []\n        for bitrate in bitrates:\n            for link in links:\n                formats.append({\n                    'url': '%s%d.%s' % (link[0], bitrate, link[1]),\n                    'format_id': '%s-%d' % (link[1], bitrate),\n                    'vbr': bitrate,\n                })\n\n        subtitles = {}\n        for src, src_lang in re.findall(r'<track kind=\"captions\" src=\"([^\"]+)\" srclang=\"([^\"]+)\"', webpage):\n            subtitles[src_lang] = [{\n                'ext': src.split('/')[-1],\n                'url': 'http://www.funnyordie.com%s' % src,\n            }]\n\n        post_json = self._search_regex(\n            r'fb_post\\s*=\\s*(\\{.*?\\});', webpage, 'post details')\n        post = json.loads(post_json)\n\n        return {\n            'id': video_id,\n            'title': post['name'],\n            'description': post.get('description'),\n            'thumbnail': post.get('picture'),\n            'formats': formats,\n            'subtitles': subtitles,\n        }\n", "path": "youtube_dl/extractor/funnyordie.py"}], "after_files": [{"content": "from __future__ import unicode_literals\n\nimport json\nimport re\n\nfrom .common import InfoExtractor\nfrom ..utils import ExtractorError\n\n\nclass FunnyOrDieIE(InfoExtractor):\n    _VALID_URL = r'https?://(?:www\\.)?funnyordie\\.com/(?P<type>embed|articles|videos)/(?P<id>[0-9a-f]+)(?:$|[?#/])'\n    _TESTS = [{\n        'url': 'http://www.funnyordie.com/videos/0732f586d7/heart-shaped-box-literal-video-version',\n        'md5': 'bcd81e0c4f26189ee09be362ad6e6ba9',\n        'info_dict': {\n            'id': '0732f586d7',\n            'ext': 'mp4',\n            'title': 'Heart-Shaped Box: Literal Video Version',\n            'description': 'md5:ea09a01bc9a1c46d9ab696c01747c338',\n            'thumbnail': 're:^http:.*\\.jpg$',\n        },\n    }, {\n        'url': 'http://www.funnyordie.com/embed/e402820827',\n        'info_dict': {\n            'id': 'e402820827',\n            'ext': 'mp4',\n            'title': 'Please Use This Song (Jon Lajoie)',\n            'description': 'Please use this to sell something.  www.jonlajoie.com',\n            'thumbnail': 're:^http:.*\\.jpg$',\n        },\n    }, {\n        'url': 'http://www.funnyordie.com/articles/ebf5e34fc8/10-hours-of-walking-in-nyc-as-a-man',\n        'only_matching': True,\n    }]\n\n    def _real_extract(self, url):\n        mobj = re.match(self._VALID_URL, url)\n\n        video_id = mobj.group('id')\n        webpage = self._download_webpage(url, video_id)\n\n        links = re.findall(r'<source src=\"([^\"]+/v)[^\"]+\\.([^\"]+)\" type=\\'video', webpage)\n        if not links:\n            raise ExtractorError('No media links available for %s' % video_id)\n\n        links.sort(key=lambda link: 1 if link[1] == 'mp4' else 0)\n\n        bitrates = self._html_search_regex(r'<source src=\"[^\"]+/v,((?:\\d+,)+)\\.mp4\\.csmil', webpage, 'video bitrates')\n        bitrates = [int(b) for b in bitrates.rstrip(',').split(',')]\n        bitrates.sort()\n\n        formats = []\n        for bitrate in bitrates:\n            for link in links:\n                formats.append({\n                    'url': self._proto_relative_url('%s%d.%s' % (link[0], bitrate, link[1])),\n                    'format_id': '%s-%d' % (link[1], bitrate),\n                    'vbr': bitrate,\n                })\n\n        subtitles = {}\n        for src, src_lang in re.findall(r'<track kind=\"captions\" src=\"([^\"]+)\" srclang=\"([^\"]+)\"', webpage):\n            subtitles[src_lang] = [{\n                'ext': src.split('/')[-1],\n                'url': 'http://www.funnyordie.com%s' % src,\n            }]\n\n        post_json = self._search_regex(\n            r'fb_post\\s*=\\s*(\\{.*?\\});', webpage, 'post details')\n        post = json.loads(post_json)\n\n        return {\n            'id': video_id,\n            'title': post['name'],\n            'description': post.get('description'),\n            'thumbnail': post.get('picture'),\n            'formats': formats,\n            'subtitles': subtitles,\n        }\n", "path": "youtube_dl/extractor/funnyordie.py"}]}