Repository: youtube-dl
Issue: [GameStar] ERROR: 92640: Failed to parse JSON  (caused by JSONDecodeError('Invalid control character at...')
Labels: bug

## 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 that [x])
- Use *Preview* tab to see how your issue will actually look like

---

### Make sure you are using the *latest* version: run `youtube-dl --version` and ensure your version is *2017.04.03*. 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 **2017.04.03**

### Before submitting an *issue* make sure you have:
- [x] At least skimmed through [README](https://github.com/rg3/youtube-dl/blob/master/README.md) and **most notably** [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

### 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

---

Downloading of some Gamestar videos fail with the following error message:
```
$ youtube-dl -v http://www.gamestar.de/videos/rain-world-gameplay-trailer-stellt-das-sandbox-spiel-vor,92640.html
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'http://www.gamestar.de/videos/rain-world-gameplay-trailer-stellt-das-sandbox-spiel-vor,92640.html']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.04.03
[debug] Python version 3.6.0 - Linux-4.10.6-1-ARCH-x86_64-with-arch
[debug] exe versions: ffmpeg 3.2.4, ffprobe 3.2.4, rtmpdump 2.4
[debug] Proxy map: {}
[GameStar] 92640: Downloading webpage
ERROR: 92640: Failed to parse JSON  (caused by JSONDecodeError('Invalid control character at: line 6 column 140 (char 280)',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 672, in _parse_json
    return json.loads(json_string)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid control character at: line 6 column 140 (char 280)
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 672, in _parse_json
    return json.loads(json_string)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid control character at: line 6 column 140 (char 280)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 761, in extract_info
    ie_result = ie.extract(url)
  File "/usr/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 429, in extract
    ie_result = self._real_extract(url)
  File "/usr/lib/python3.6/site-packages/youtube_dl/extractor/gamestar.py", line 38, in _real_extract
    webpage, 'JSON-LD', group='json_ld'), video_id)
  File "/usr/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 676, in _parse_json
    raise ExtractorError(errmsg, cause=ve)
youtube_dl.utils.ExtractorError: 92640: Failed to parse JSON  (caused by JSONDecodeError('Invalid control character at: line 6 column 140 (char 280)',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
```
- This also happens with some other (not all) GameStar videos e.g. http://www.gamestar.de/videos/news-neuer-tomb-raider-kinofilm-destiny-2-offiziell-angekuendigt,92626.html, but with different control characters: `ERROR: 92626: Failed to parse JSON  (caused by JSONDecodeError('Invalid control character at: line 6 column 32 (char 180)',));`

### Identified problem
- New line characters in json string.

#### Reference
- http://stackoverflow.com/questions/9295439/python-json-loads-fails-with-valueerror-invalid-control-character-at-line-1-c
- http://stackoverflow.com/questions/22394235/invalid-control-character-with-python-json-loads

### Possible fixes
- _Ignore_ new line characters: Change `json.loads(json_string)`  to `json.loads(json_string, strict=False)` in `extractors/common.py`.
  - This might conceal other errors? -> Create a new key word argument called `strict=True` in `def _parse_json()`.
- _Remove_ new line characters in json string (in `extractors/gamestar.py`):
 ```python
        json_ld = self._parse_json(self._search_regex(
            r'(?s)<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json_ld>[^<]+VideoObject[^<]+)</script>',
            webpage, 'JSON-LD', group='json_ld'), video_id,
            transform_source=lambda s: s.replace('\n', ''))
```
  - or
```python
        json_ld = self._parse_json(self._search_regex(
            r'(?s)<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json_ld>[^<]+VideoObject[^<]+)</script>',
            webpage, 'JSON-LD', group='json_ld').replace('\n', ''), video_id)
```