Skip to content

Commit

Permalink
[funk:channel] Improve byChannelAlias extraction (closes #17142)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey M․ committed Aug 3, 2018
1 parent cb1c3a3 commit af322eb
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions youtube_dl/extractor/funk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding: utf-8
from __future__ import unicode_literals

import itertools
import re

from .common import InfoExtractor
Expand Down Expand Up @@ -125,17 +126,31 @@ def _real_extract(self, url):
# Id-based channels are currently broken on their side: webplayer
# tries to process them via byChannelAlias endpoint and fails
# predictably.
by_channel_alias = self._download_json(
'https://www.funk.net/api/v3.1/webapp/videos/byChannelAlias/%s'
% channel_id,
'Downloading byChannelAlias JSON', headers=headers, query={
'size': 100,
}, fatal=False)
if by_channel_alias:
for page_num in itertools.count():
by_channel_alias = self._download_json(
'https://www.funk.net/api/v3.1/webapp/videos/byChannelAlias/%s'
% channel_id,
'Downloading byChannelAlias JSON page %d' % (page_num + 1),
headers=headers, query={
'filterFsk': 'false',
'sort': 'creationDate,desc',
'size': 100,
'page': page_num,
}, fatal=False)
if not by_channel_alias:
break
video_list = try_get(
by_channel_alias, lambda x: x['_embedded']['videoList'], list)
if video_list:
if not video_list:
break
try:
video = next(r for r in video_list if r.get('alias') == alias)
break
except StopIteration:
pass
if not try_get(
by_channel_alias, lambda x: x['_links']['next']):
break

if not video:
by_id_list = self._download_json(
Expand Down

0 comments on commit af322eb

Please sign in to comment.