Repository: ytdl-org/youtube-dl

Issue:
LiveLeak: some videos return HTTP Error 403
## Checklist

- [x] I'm reporting a broken site support
- [x] I've verified that I'm running youtube-dl version **2019.05.20**
- [x] I've checked that all provided URLs are alive and playable in a browser
- [x] I've checked that all URLs and arguments with special characters are properly quoted or escaped
- [x] I've searched the bugtracker for similar issues including closed ones


## Verbose log

```
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'https://www.liveleak.com/view?t=C26ZZ_1558612804']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2019.05.20
[debug] Git HEAD: 25b83c2a0
[debug] Python version 3.7.3 (CPython) - Linux-5.1.4-arch1-1-ARCH-x86_64-with-arch
[debug] exe versions: ffmpeg 4.1.3, ffprobe 4.1.3, phantomjs ., rtmpdump 2.4
[debug] Proxy map: {}
[LiveLeak] C26ZZ_1558612804: Downloading webpage
[download] Downloading playlist: Liveleak.com - Stray dog nearly wins 100m race after joining in accidentally
[LiveLeak] playlist Liveleak.com - Stray dog nearly wins 100m race after joining in accidentally: Collected 1 video ids (downloading 1 of them)
[download] Downloading video 1 of 1
[debug] Default format spec: bestvideo+bestaudio/best
[debug] Invoking downloader on 'https://cdn.liveleak.com/80281E/ll_a_s/2019/May/23/LiveLeak-dot-com-Ih8Y_1558612804-LbnxSMi8jWXVzuYSWml0tgjM2nnK7dj21558611813mp4.mp4?Wk0GS8abpvNJ7QeS3f7boxotGr6iGqNlOYpfW0GbwCV5FbSzf8lZqdJIvBw5tzmdB6r8Hc8pV3eAW9wqT1aVzHadkMVngpbTEOIpaaKCZ8b8IWdQP8Ku4rNon9CkOLY7cc6_J9MZio86w7h5lgTxAw'
ERROR: unable to download video data: HTTP Error 403: Forbidden
Traceback (most recent call last):
  File "/home/bitraid/src/youtube-dl/youtube_dl/YoutubeDL.py", line 1915, in process_info
    success = dl(filename, info_dict)
  File "/home/bitraid/src/youtube-dl/youtube_dl/YoutubeDL.py", line 1854, in dl
    return fd.download(name, info)
  File "/home/bitraid/src/youtube-dl/youtube_dl/downloader/common.py", line 364, in download
    return self.real_download(filename, info_dict)
  File "/home/bitraid/src/youtube-dl/youtube_dl/downloader/http.py", line 341, in real_download
    establish_connection()
  File "/home/bitraid/src/youtube-dl/youtube_dl/downloader/http.py", line 109, in establish_connection
    ctx.data = self.ydl.urlopen(request)
  File "/home/bitraid/src/youtube-dl/youtube_dl/YoutubeDL.py", line 2227, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
```


## Description

Started with #4768, the extracted LiveLeak urls are modified (remove `.*.mp4`) to include the "original" version(s) of the video (without the "Liveleak" logo) and also use it as "best". It seems that lately there are some videos that don't have an "original" version, and while the extracted urls work fine - the modified ("original") ones result in: `HTTP Error 403: Forbidden`. These videos also don't have the "LiveLeak" logo, but have the "newsflare" logo. There doesn't seem to be any obvious difference in the urls of the videos that doesn't have an "original" version from those that do, so i'm not sure what the best fix would be.

Only the first two formats (from the unmodified urls) work for this video:
```
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-F', '-v', 'https://www.liveleak.com/view?t=C26ZZ_1558612804']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2019.05.20
[debug] Git HEAD: 25b83c2a0
[debug] Python version 3.7.3 (CPython) - Linux-5.1.4-arch1-1-ARCH-x86_64-with-arch
[debug] exe versions: ffmpeg 4.1.3, ffprobe 4.1.3, phantomjs ., rtmpdump 2.4
[debug] Proxy map: {}
[LiveLeak] C26ZZ_1558612804: Downloading webpage
[download] Downloading playlist: Liveleak.com - Stray dog nearly wins 100m race after joining in accidentally
[LiveLeak] playlist Liveleak.com - Stray dog nearly wins 100m race after joining in accidentally: Collected 1 video ids (downloading 1 of them)
[download] Downloading video 1 of 1
[info] Available formats for C26ZZ_1558612804:
format code    extension  resolution note
360p           mp4        360p       
720p           mp4        720p       
original-360p  mp4        unknown    
original-720p  mp4        unknown    (best)
[download] Finished downloading playlist: Liveleak.com - Stray dog nearly wins 100m race after joining in accidentally
```

Their urls doesn't seem to have any differences from the other videos:

- `Error 403` when removing `.*.mp4` (`.5ce68b68c42ea.mp4`) from:
`https://cdn.liveleak.com/80281E/ll_a_s/2019/May/23/LiveLeak-dot-com-Ih8Y_1558612804-LbnxSMi8jWXVzuYSWml0tgjM2nnK7dj21558611813mp4.mp4.5ce68b68c42ea.mp4?2uCjJmr004dtCQ-BFJlaAuCczOd_rc1bk3FD-_3r6IxzZjgXgmSxIWCHl9jfHWvAHLrY8c_B0957_9Sql75Tq9tWKnmUQfP6un0USD410MVIy1M9d2mbh2g88XaU8IYe-hhdAoDY_epUHyKc2zb32g`

- Gets the "original" video when removing `.*.mp4` (`.5ce66383ad172.mp4`) from:
`https://cdn.liveleak.com/80281E/ll_a_s/2019/May/23/LiveLeak-dot-com-149530jakartaaa_1558602606.mp4.5ce66383ad172.mp4?1DvRuMj1HtdJBRz7h-2990qTokZQjSNvFjLAqOvG3Uz-PTStbyzYKfVGKcacqRx1VYGK80Tc2u6Iox6R2D3fhHb6PvNzT6fvjrmNET1ycDwzHpWFIsSpnc44fZ8BTswDTbruQs__OdkuyCkRMeNxXw`


Discussion:

Resolving patch:
diff --git a/youtube_dl/extractor/liveleak.py b/youtube_dl/extractor/liveleak.py
--- a/youtube_dl/extractor/liveleak.py
+++ b/youtube_dl/extractor/liveleak.py
@@ -82,6 +82,10 @@ class LiveLeakIE(InfoExtractor):
     }, {
         'url': 'https://www.liveleak.com/view?t=HvHi_1523016227',
         'only_matching': True,
+    }, {
+        # No original video
+        'url': 'https://www.liveleak.com/view?t=C26ZZ_1558612804',
+        'only_matching': True,
     }]
 
     @staticmethod
@@ -134,11 +138,13 @@ def _real_extract(self, url):
                 orig_url = re.sub(r'\.mp4\.[^.]+', '', a_format['url'])
                 if a_format['url'] != orig_url:
                     format_id = a_format.get('format_id')
-                    formats.append({
-                        'format_id': 'original' + ('-' + format_id if format_id else ''),
-                        'url': orig_url,
-                        'preference': 1,
-                    })
+                    format_id = 'original' + ('-' + format_id if format_id else '')
+                    if self._is_valid_url(orig_url, video_id, format_id):
+                        formats.append({
+                            'format_id': format_id,
+                            'url': orig_url,
+                            'preference': 1,
+                        })
             self._sort_formats(formats)
             info_dict['formats'] = formats
 


Test patch: