Repository: ytdl-org/youtube-dl

Issue:
format choosing option "bestvideo[height>=xxxx]" not working as expected for one Youtube video
Hello, folks.

First, thanks to all the contributors to this nice piece of software, I'm much indebted to it, with rtmpdump not functioning at all on my Windows 7 PC for unknown reasons.

I will report an issue with the windows build of youtube-dl I've just upgraded some minutes ago (version 2015.05.20).

First, the url of the Youtube video in question is as follows : 
`https://www.youtube.com/watch?v=EQCrhbBxsjA`

The list of video formats given by the command 
`youtube-dl.exe -F https://www.youtube.com/watch?v=EQCrhbBxsjA`
is :

```
[youtube] EQCrhbBxsjA: Downloading webpage
[youtube] EQCrhbBxsjA: Extracting video information
[youtube] EQCrhbBxsjA: Downloading DASH manifest
[info] Available formats for EQCrhbBxsjA:
format code  extension  resolution note
171          webm       audio only DASH audio   85k , audio@128k (44100Hz), 1.51MiB
140          m4a        audio only DASH audio   95k , m4a_dash container, aac  @128k (44100Hz), 1.75MiB
141          m4a        audio only DASH audio  191k , m4a_dash container, aac  @256k (44100Hz), 3.52MiB
278          webm       82x144     DASH video   42k , webm container, VP9, 15fps, video only, 750.13KiB
160          mp4        82x144     DASH video  111k , 15fps, video only, 1.99MiB
242          webm       136x240    DASH video  147k , 30fps, video only, 1.96MiB
133          mp4        136x240    DASH video  247k , 30fps, video only, 4.50MiB
243          webm       202x360    DASH video  268k , 30fps, video only, 3.71MiB
134          mp4        202x360    DASH video  318k , 30fps, video only, 5.43MiB
244          webm       270x480    DASH video  430k , 30fps, video only, 6.03MiB
135          mp4        270x480    DASH video  674k , 30fps, video only, 11.67MiB
247          webm       406x720    DASH video  867k , 30fps, video only, 12.59MiB
136          mp4        406x720    DASH video 1390k , 30fps, video only, 23.57MiB
248          webm       608x1080   DASH video 1732k , 30fps, video only, 26.41MiB
137          mp4        608x1080   DASH video 2546k , 30fps, video only, 44.32MiB
264          mp4        720x1280   DASH video 4183k , 30fps, video only, 74.10MiB
271          webm       720x1280   DASH video 4939k , 30fps, video only, 81.73MiB
17           3gp        176x144
36           3gp        320x240
5            flv        400x240
43           webm       640x360
18           mp4        640x360
22           mp4        1280x720   (best) 
```

Now, I want to download this video 'only if' it is available in 1440p or a higher resolution, so I run the following command:
`youtube-dl.exe -f "bestvideo[height>=1440]+bestaudio" https://www.youtube.com/watch?v=EQCrhbBxsjA`

the maximum height available for this video is 1280, so I expected that it would not be downloaded, but against my intuition, youtube-dl started to download a video file with a size of 74.1mb(which must be the following format, considering its size):
`264          mp4        720x1280   DASH video 4183k , 30fps, video only, 74.10MiB`

Not only is the height condition mismatched, but it isn't the best video format either; the video format whose height is 1280(maximum) which has the highest bitrate is 271 :
`271          webm       720x1280   DASH video 4939k , 30fps, video only, 81.73MiB`

Actually, the command
`youtube-dl.exe -f "bestvideo[height>=xxxx]+bestaudio https://www.youtube.com/watch?v=EQCrhbBxsjA`
with _xxxx_ replaced by anything higher than 1280 seems to try to fetch that same video file with a size of 74.1mb.

`youtube-dl.exe -f "bestvideo[height>=1280]+bestaudio https://www.youtube.com/watch?v=EQCrhbBxsjA`
seems to finally select the video format with a size of around 81mb (probably 271 listed above), which is a behavior that I can understand.

Should this be considered a bug, or am I missing something?
If the latter is true, please point me in the right direction.

Thanks.



Discussion:

Resolving patch:
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -1126,12 +1126,13 @@ def _map_to_format_list(urlmap):
                     self.report_warning(
                         'Skipping DASH manifest: %r' % e, video_id)
                 else:
-                    # Hide the formats we found through non-DASH
+                    # Remove the formats we found through non-DASH, they
+                    # contain less info and it can be wrong, because we use
+                    # fixed values (for example the resolution). See
+                    # https://github.com/rg3/youtube-dl/issues/5774 for an
+                    # example.
                     dash_keys = set(df['format_id'] for df in dash_formats)
-                    for f in formats:
-                        if f['format_id'] in dash_keys:
-                            f['format_id'] = 'nondash-%s' % f['format_id']
-                            f['preference'] = f.get('preference', 0) - 10000
+                    formats = [f for f in formats if f['format_id'] not in dash_keys]
                     formats.extend(dash_formats)
 
         # Check for malformed aspect ratio


Test patch: