Skip to content

Commit

Permalink
[orf:tvthek] Improve extraction and remove unused code (closes #17956,
Browse files Browse the repository at this point in the history
…closes #18024)
  • Loading branch information
dstftw committed Nov 2, 2018
1 parent c620694 commit 4b6aca1
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions youtube_dl/extractor/orf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
strip_jsonp,
unescapeHTML,
unified_strdate,
url_or_none,
)


Expand Down Expand Up @@ -68,12 +69,6 @@ def _real_extract(self, url):
webpage, 'playlist', group='json'),
playlist_id, transform_source=unescapeHTML)['playlist']['videos']

def quality_to_int(s):
m = re.search('([0-9]+)', s)
if m is None:
return -1
return int(m.group(1))

entries = []
for sd in data_jsb:
video_id, title = sd.get('id'), sd.get('title')
Expand All @@ -82,14 +77,27 @@ def quality_to_int(s):
video_id = compat_str(video_id)
formats = []
for fd in sd['sources']:
format_id = '%s-%s-%s' % (
fd['delivery'], fd['quality'], fd['quality_string'])
src = url_or_none(fd.get('src'))
if not src:
continue
format_id_list = []
for key in ('delivery', 'quality', 'quality_string'):
value = fd.get(key)
if value:
format_id_list.append(value)
format_id = '-'.join(format_id_list)
if determine_ext(fd['src']) == 'm3u8':
formats.extend(self._extract_m3u8_formats(
fd['src'], video_id, 'mp4', m3u8_id=format_id))
elif determine_ext(fd['src']) == 'f4m':
formats.extend(self._extract_f4m_formats(
fd['src'], video_id, f4m_id=format_id))
else:
formats.append({
'format_id': format_id,
'url': src,
'protocol': fd.get('protocol'),
})

# Check for geoblocking.
# There is a property is_geoprotection, but that's always false
Expand Down

0 comments on commit 4b6aca1

Please sign in to comment.