We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Beeg json not found
Hello, been updating ytdl but the issue remains:

root@server:~/Downloads# youtube-dl -vv https://beeg.com/6484762
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-vv', u'https://beeg.com/6484762']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.09.15
[debug] Python version 2.7.6 - Linux-3.13.0-129-generic-x86_64-with-Ubuntu-14.04-trusty
[debug] exe versions: ffmpeg N-75403-g3a8e447, ffprobe N-75403-g3a8e447, rtmpdump 2.4
[debug] Proxy map: {}
[Beeg] 6484762: Downloading webpage
[Beeg] 6484762: Downloading JSON metadata
ERROR: Unable to download JSON metadata: HTTP Error 404: Not Found (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 503, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2177, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)


--- 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/beeg.py`
Content:
```
1 from __future__ import unicode_literals
2 
3 from .common import InfoExtractor
4 from ..compat import (
5     compat_chr,
6     compat_ord,
7     compat_urllib_parse_unquote,
8 )
9 from ..utils import (
10     int_or_none,
11     parse_iso8601,
12 )
13 
14 
15 class BeegIE(InfoExtractor):
16     _VALID_URL = r'https?://(?:www\.)?beeg\.com/(?P<id>\d+)'
17     _TEST = {
18         'url': 'http://beeg.com/5416503',
19         'md5': 'a1a1b1a8bc70a89e49ccfd113aed0820',
20         'info_dict': {
21             'id': '5416503',
22             'ext': 'mp4',
23             'title': 'Sultry Striptease',
24             'description': 'md5:d22219c09da287c14bed3d6c37ce4bc2',
25             'timestamp': 1391813355,
26             'upload_date': '20140207',
27             'duration': 383,
28             'tags': list,
29             'age_limit': 18,
30         }
31     }
32 
33     def _real_extract(self, url):
34         video_id = self._match_id(url)
35 
36         webpage = self._download_webpage(url, video_id)
37 
38         cpl_url = self._search_regex(
39             r'<script[^>]+src=(["\'])(?P<url>(?:https?:)?//static\.beeg\.com/cpl/\d+\.js.*?)\1',
40             webpage, 'cpl', default=None, group='url')
41 
42         beeg_version, beeg_salt = [None] * 2
43 
44         if cpl_url:
45             cpl = self._download_webpage(
46                 self._proto_relative_url(cpl_url), video_id,
47                 'Downloading cpl JS', fatal=False)
48             if cpl:
49                 beeg_version = int_or_none(self._search_regex(
50                     r'beeg_version\s*=\s*([^\b]+)', cpl,
51                     'beeg version', default=None)) or self._search_regex(
52                     r'/(\d+)\.js', cpl_url, 'beeg version', default=None)
53                 beeg_salt = self._search_regex(
54                     r'beeg_salt\s*=\s*(["\'])(?P<beeg_salt>.+?)\1', cpl, 'beeg salt',
55                     default=None, group='beeg_salt')
56 
57         beeg_version = beeg_version or '2000'
58         beeg_salt = beeg_salt or 'pmweAkq8lAYKdfWcFCUj0yoVgoPlinamH5UE1CB3H'
59 
60         video = self._download_json(
61             'https://api.beeg.com/api/v6/%s/video/%s' % (beeg_version, video_id),
62             video_id)
63 
64         def split(o, e):
65             def cut(s, x):
66                 n.append(s[:x])
67                 return s[x:]
68             n = []
69             r = len(o) % e
70             if r > 0:
71                 o = cut(o, r)
72             while len(o) > e:
73                 o = cut(o, e)
74             n.append(o)
75             return n
76 
77         def decrypt_key(key):
78             # Reverse engineered from http://static.beeg.com/cpl/1738.js
79             a = beeg_salt
80             e = compat_urllib_parse_unquote(key)
81             o = ''.join([
82                 compat_chr(compat_ord(e[n]) - compat_ord(a[n % len(a)]) % 21)
83                 for n in range(len(e))])
84             return ''.join(split(o, 3)[::-1])
85 
86         def decrypt_url(encrypted_url):
87             encrypted_url = self._proto_relative_url(
88                 encrypted_url.replace('{DATA_MARKERS}', ''), 'https:')
89             key = self._search_regex(
90                 r'/key=(.*?)%2Cend=', encrypted_url, 'key', default=None)
91             if not key:
92                 return encrypted_url
93             return encrypted_url.replace(key, decrypt_key(key))
94 
95         formats = []
96         for format_id, video_url in video.items():
97             if not video_url:
98                 continue
99             height = self._search_regex(
100                 r'^(\d+)[pP]$', format_id, 'height', default=None)
101             if not height:
102                 continue
103             formats.append({
104                 'url': decrypt_url(video_url),
105                 'format_id': format_id,
106                 'height': int(height),
107             })
108         self._sort_formats(formats)
109 
110         title = video['title']
111         video_id = video.get('id') or video_id
112         display_id = video.get('code')
113         description = video.get('desc')
114 
115         timestamp = parse_iso8601(video.get('date'), ' ')
116         duration = int_or_none(video.get('duration'))
117 
118         tags = [tag.strip() for tag in video['tags'].split(',')] if video.get('tags') else None
119 
120         return {
121             'id': video_id,
122             'display_id': display_id,
123             'title': title,
124             'description': description,
125             'timestamp': timestamp,
126             'duration': duration,
127             'tags': tags,
128             'formats': formats,
129             'age_limit': self._rta_search(webpage),
130         }
131
```
--- 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/beeg.py b/youtube_dl/extractor/beeg.py
--- a/youtube_dl/extractor/beeg.py
+++ b/youtube_dl/extractor/beeg.py
@@ -9,6 +9,7 @@
 from ..utils import (
     int_or_none,
     parse_iso8601,
+    urljoin,
 )
 
 
@@ -36,9 +37,11 @@
         webpage = self._download_webpage(url, video_id)
 
         cpl_url = self._search_regex(
-            r'<script[^>]+src=(["\'])(?P<url>(?:https?:)?//static\.beeg\.com/cpl/\d+\.js.*?)\1',
+            r'<script[^>]+src=(["\'])(?P<url>(?:/static|(?:https?:)?//static\.beeg\.com)/cpl/\d+\.js.*?)\1',
             webpage, 'cpl', default=None, group='url')
 
+        cpl_url = urljoin(url, cpl_url)
+
         beeg_version, beeg_salt = [None] * 2
 
         if cpl_url:
@@ -54,7 +57,7 @@
                     r'beeg_salt\s*=\s*(["\'])(?P<beeg_salt>.+?)\1', cpl, 'beeg salt',
                     default=None, group='beeg_salt')
 
-        beeg_version = beeg_version or '2000'
+        beeg_version = beeg_version or '2185'
         beeg_salt = beeg_salt or 'pmweAkq8lAYKdfWcFCUj0yoVgoPlinamH5UE1CB3H'
 
         video = self._download_json(

{"golden_diff": "diff --git a/youtube_dl/extractor/beeg.py b/youtube_dl/extractor/beeg.py\n--- a/youtube_dl/extractor/beeg.py\n+++ b/youtube_dl/extractor/beeg.py\n@@ -9,6 +9,7 @@\n from ..utils import (\n     int_or_none,\n     parse_iso8601,\n+    urljoin,\n )\n \n \n@@ -36,9 +37,11 @@\n         webpage = self._download_webpage(url, video_id)\n \n         cpl_url = self._search_regex(\n-            r'<script[^>]+src=([\"\\'])(?P<url>(?:https?:)?//static\\.beeg\\.com/cpl/\\d+\\.js.*?)\\1',\n+            r'<script[^>]+src=([\"\\'])(?P<url>(?:/static|(?:https?:)?//static\\.beeg\\.com)/cpl/\\d+\\.js.*?)\\1',\n             webpage, 'cpl', default=None, group='url')\n \n+        cpl_url = urljoin(url, cpl_url)\n+\n         beeg_version, beeg_salt = [None] * 2\n \n         if cpl_url:\n@@ -54,7 +57,7 @@\n                     r'beeg_salt\\s*=\\s*([\"\\'])(?P<beeg_salt>.+?)\\1', cpl, 'beeg salt',\n                     default=None, group='beeg_salt')\n \n-        beeg_version = beeg_version or '2000'\n+        beeg_version = beeg_version or '2185'\n         beeg_salt = beeg_salt or 'pmweAkq8lAYKdfWcFCUj0yoVgoPlinamH5UE1CB3H'\n \n         video = self._download_json(\n", "issue": "Beeg json not found\nHello, been updating ytdl but the issue remains:\r\n\r\nroot@server:~/Downloads# youtube-dl -vv https://beeg.com/6484762\r\n[debug] System config: []\r\n[debug] User config: []\r\n[debug] Custom config: []\r\n[debug] Command-line args: [u'-vv', u'https://beeg.com/6484762']\r\n[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8\r\n[debug] youtube-dl version 2017.09.15\r\n[debug] Python version 2.7.6 - Linux-3.13.0-129-generic-x86_64-with-Ubuntu-14.04-trusty\r\n[debug] exe versions: ffmpeg N-75403-g3a8e447, ffprobe N-75403-g3a8e447, rtmpdump 2.4\r\n[debug] Proxy map: {}\r\n[Beeg] 6484762: Downloading webpage\r\n[Beeg] 6484762: Downloading JSON metadata\r\nERROR: Unable to download JSON metadata: HTTP Error 404: Not Found (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.\r\n  File \"/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py\", line 503, in _request_webpage\r\n    return self._downloader.urlopen(url_or_request)\r\n  File \"/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py\", line 2177, in urlopen\r\n    return self._opener.open(req, timeout=self._socket_timeout)\r\n  File \"/usr/lib/python2.7/urllib2.py\", line 410, in open\r\n    response = meth(req, response)\r\n  File \"/usr/lib/python2.7/urllib2.py\", line 523, in http_response\r\n    'http', request, response, code, msg, hdrs)\r\n  File \"/usr/lib/python2.7/urllib2.py\", line 448, in error\r\n    return self._call_chain(*args)\r\n  File \"/usr/lib/python2.7/urllib2.py\", line 382, in _call_chain\r\n    result = func(*args)\r\n  File \"/usr/lib/python2.7/urllib2.py\", line 531, in http_error_default\r\n    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)\r\n\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nfrom .common import InfoExtractor\nfrom ..compat import (\n    compat_chr,\n    compat_ord,\n    compat_urllib_parse_unquote,\n)\nfrom ..utils import (\n    int_or_none,\n    parse_iso8601,\n)\n\n\nclass BeegIE(InfoExtractor):\n    _VALID_URL = r'https?://(?:www\\.)?beeg\\.com/(?P<id>\\d+)'\n    _TEST = {\n        'url': 'http://beeg.com/5416503',\n        'md5': 'a1a1b1a8bc70a89e49ccfd113aed0820',\n        'info_dict': {\n            'id': '5416503',\n            'ext': 'mp4',\n            'title': 'Sultry Striptease',\n            'description': 'md5:d22219c09da287c14bed3d6c37ce4bc2',\n            'timestamp': 1391813355,\n            'upload_date': '20140207',\n            'duration': 383,\n            'tags': list,\n            'age_limit': 18,\n        }\n    }\n\n    def _real_extract(self, url):\n        video_id = self._match_id(url)\n\n        webpage = self._download_webpage(url, video_id)\n\n        cpl_url = self._search_regex(\n            r'<script[^>]+src=([\"\\'])(?P<url>(?:https?:)?//static\\.beeg\\.com/cpl/\\d+\\.js.*?)\\1',\n            webpage, 'cpl', default=None, group='url')\n\n        beeg_version, beeg_salt = [None] * 2\n\n        if cpl_url:\n            cpl = self._download_webpage(\n                self._proto_relative_url(cpl_url), video_id,\n                'Downloading cpl JS', fatal=False)\n            if cpl:\n                beeg_version = int_or_none(self._search_regex(\n                    r'beeg_version\\s*=\\s*([^\\b]+)', cpl,\n                    'beeg version', default=None)) or self._search_regex(\n                    r'/(\\d+)\\.js', cpl_url, 'beeg version', default=None)\n                beeg_salt = self._search_regex(\n                    r'beeg_salt\\s*=\\s*([\"\\'])(?P<beeg_salt>.+?)\\1', cpl, 'beeg salt',\n                    default=None, group='beeg_salt')\n\n        beeg_version = beeg_version or '2000'\n        beeg_salt = beeg_salt or 'pmweAkq8lAYKdfWcFCUj0yoVgoPlinamH5UE1CB3H'\n\n        video = self._download_json(\n            'https://api.beeg.com/api/v6/%s/video/%s' % (beeg_version, video_id),\n            video_id)\n\n        def split(o, e):\n            def cut(s, x):\n                n.append(s[:x])\n                return s[x:]\n            n = []\n            r = len(o) % e\n            if r > 0:\n                o = cut(o, r)\n            while len(o) > e:\n                o = cut(o, e)\n            n.append(o)\n            return n\n\n        def decrypt_key(key):\n            # Reverse engineered from http://static.beeg.com/cpl/1738.js\n            a = beeg_salt\n            e = compat_urllib_parse_unquote(key)\n            o = ''.join([\n                compat_chr(compat_ord(e[n]) - compat_ord(a[n % len(a)]) % 21)\n                for n in range(len(e))])\n            return ''.join(split(o, 3)[::-1])\n\n        def decrypt_url(encrypted_url):\n            encrypted_url = self._proto_relative_url(\n                encrypted_url.replace('{DATA_MARKERS}', ''), 'https:')\n            key = self._search_regex(\n                r'/key=(.*?)%2Cend=', encrypted_url, 'key', default=None)\n            if not key:\n                return encrypted_url\n            return encrypted_url.replace(key, decrypt_key(key))\n\n        formats = []\n        for format_id, video_url in video.items():\n            if not video_url:\n                continue\n            height = self._search_regex(\n                r'^(\\d+)[pP]$', format_id, 'height', default=None)\n            if not height:\n                continue\n            formats.append({\n                'url': decrypt_url(video_url),\n                'format_id': format_id,\n                'height': int(height),\n            })\n        self._sort_formats(formats)\n\n        title = video['title']\n        video_id = video.get('id') or video_id\n        display_id = video.get('code')\n        description = video.get('desc')\n\n        timestamp = parse_iso8601(video.get('date'), ' ')\n        duration = int_or_none(video.get('duration'))\n\n        tags = [tag.strip() for tag in video['tags'].split(',')] if video.get('tags') else None\n\n        return {\n            'id': video_id,\n            'display_id': display_id,\n            'title': title,\n            'description': description,\n            'timestamp': timestamp,\n            'duration': duration,\n            'tags': tags,\n            'formats': formats,\n            'age_limit': self._rta_search(webpage),\n        }\n", "path": "youtube_dl/extractor/beeg.py"}], "after_files": [{"content": "from __future__ import unicode_literals\n\nfrom .common import InfoExtractor\nfrom ..compat import (\n    compat_chr,\n    compat_ord,\n    compat_urllib_parse_unquote,\n)\nfrom ..utils import (\n    int_or_none,\n    parse_iso8601,\n    urljoin,\n)\n\n\nclass BeegIE(InfoExtractor):\n    _VALID_URL = r'https?://(?:www\\.)?beeg\\.com/(?P<id>\\d+)'\n    _TEST = {\n        'url': 'http://beeg.com/5416503',\n        'md5': 'a1a1b1a8bc70a89e49ccfd113aed0820',\n        'info_dict': {\n            'id': '5416503',\n            'ext': 'mp4',\n            'title': 'Sultry Striptease',\n            'description': 'md5:d22219c09da287c14bed3d6c37ce4bc2',\n            'timestamp': 1391813355,\n            'upload_date': '20140207',\n            'duration': 383,\n            'tags': list,\n            'age_limit': 18,\n        }\n    }\n\n    def _real_extract(self, url):\n        video_id = self._match_id(url)\n\n        webpage = self._download_webpage(url, video_id)\n\n        cpl_url = self._search_regex(\n            r'<script[^>]+src=([\"\\'])(?P<url>(?:/static|(?:https?:)?//static\\.beeg\\.com)/cpl/\\d+\\.js.*?)\\1',\n            webpage, 'cpl', default=None, group='url')\n\n        cpl_url = urljoin(url, cpl_url)\n\n        beeg_version, beeg_salt = [None] * 2\n\n        if cpl_url:\n            cpl = self._download_webpage(\n                self._proto_relative_url(cpl_url), video_id,\n                'Downloading cpl JS', fatal=False)\n            if cpl:\n                beeg_version = int_or_none(self._search_regex(\n                    r'beeg_version\\s*=\\s*([^\\b]+)', cpl,\n                    'beeg version', default=None)) or self._search_regex(\n                    r'/(\\d+)\\.js', cpl_url, 'beeg version', default=None)\n                beeg_salt = self._search_regex(\n                    r'beeg_salt\\s*=\\s*([\"\\'])(?P<beeg_salt>.+?)\\1', cpl, 'beeg salt',\n                    default=None, group='beeg_salt')\n\n        beeg_version = beeg_version or '2185'\n        beeg_salt = beeg_salt or 'pmweAkq8lAYKdfWcFCUj0yoVgoPlinamH5UE1CB3H'\n\n        video = self._download_json(\n            'https://api.beeg.com/api/v6/%s/video/%s' % (beeg_version, video_id),\n            video_id)\n\n        def split(o, e):\n            def cut(s, x):\n                n.append(s[:x])\n                return s[x:]\n            n = []\n            r = len(o) % e\n            if r > 0:\n                o = cut(o, r)\n            while len(o) > e:\n                o = cut(o, e)\n            n.append(o)\n            return n\n\n        def decrypt_key(key):\n            # Reverse engineered from http://static.beeg.com/cpl/1738.js\n            a = beeg_salt\n            e = compat_urllib_parse_unquote(key)\n            o = ''.join([\n                compat_chr(compat_ord(e[n]) - compat_ord(a[n % len(a)]) % 21)\n                for n in range(len(e))])\n            return ''.join(split(o, 3)[::-1])\n\n        def decrypt_url(encrypted_url):\n            encrypted_url = self._proto_relative_url(\n                encrypted_url.replace('{DATA_MARKERS}', ''), 'https:')\n            key = self._search_regex(\n                r'/key=(.*?)%2Cend=', encrypted_url, 'key', default=None)\n            if not key:\n                return encrypted_url\n            return encrypted_url.replace(key, decrypt_key(key))\n\n        formats = []\n        for format_id, video_url in video.items():\n            if not video_url:\n                continue\n            height = self._search_regex(\n                r'^(\\d+)[pP]$', format_id, 'height', default=None)\n            if not height:\n                continue\n            formats.append({\n                'url': decrypt_url(video_url),\n                'format_id': format_id,\n                'height': int(height),\n            })\n        self._sort_formats(formats)\n\n        title = video['title']\n        video_id = video.get('id') or video_id\n        display_id = video.get('code')\n        description = video.get('desc')\n\n        timestamp = parse_iso8601(video.get('date'), ' ')\n        duration = int_or_none(video.get('duration'))\n\n        tags = [tag.strip() for tag in video['tags'].split(',')] if video.get('tags') else None\n\n        return {\n            'id': video_id,\n            'display_id': display_id,\n            'title': title,\n            'description': description,\n            'timestamp': timestamp,\n            'duration': duration,\n            'tags': tags,\n            'formats': formats,\n            'age_limit': self._rta_search(webpage),\n        }\n", "path": "youtube_dl/extractor/beeg.py"}]}