mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-16 05:13:21 +00:00
[pluralsight] Until listing formats request only single format
This commit is contained in:
parent
38eb2968ab
commit
4c57b4853d
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
|
import collections
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
|
@ -131,13 +132,30 @@ def _real_extract(self, url):
|
||||||
'high': {'width': 1024, 'height': 768},
|
'high': {'width': 1024, 'height': 768},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AllowedQuality = collections.namedtuple('AllowedQuality', ['ext', 'qualities'])
|
||||||
|
|
||||||
ALLOWED_QUALITIES = (
|
ALLOWED_QUALITIES = (
|
||||||
('webm', ('high',)),
|
AllowedQuality('webm', ('high',)),
|
||||||
('mp4', ('low', 'medium', 'high',)),
|
AllowedQuality('mp4', ('low', 'medium', 'high',)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self._downloader.params.get('listformats', False):
|
||||||
|
allowed_qualities = ALLOWED_QUALITIES
|
||||||
|
else:
|
||||||
|
def guess_allowed_qualities():
|
||||||
|
req_format = self._downloader.params.get('format') or 'best'
|
||||||
|
req_format_split = req_format.split('-')
|
||||||
|
if len(req_format_split) > 1:
|
||||||
|
req_ext, req_quality = req_format_split
|
||||||
|
for allowed_quality in ALLOWED_QUALITIES:
|
||||||
|
if req_ext == allowed_quality.ext and req_quality in allowed_quality.qualities:
|
||||||
|
return (AllowedQuality(req_ext, (req_quality, )), )
|
||||||
|
req_ext = 'webm' if self._downloader.params.get('prefer_free_formats') else 'mp4'
|
||||||
|
return (AllowedQuality(req_ext, ('high', )), )
|
||||||
|
allowed_qualities = guess_allowed_qualities()
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for ext, qualities in ALLOWED_QUALITIES:
|
for ext, qualities in allowed_qualities:
|
||||||
for quality in qualities:
|
for quality in qualities:
|
||||||
f = QUALITIES[quality].copy()
|
f = QUALITIES[quality].copy()
|
||||||
clip_post = {
|
clip_post = {
|
||||||
|
|
Loading…
Reference in a new issue