Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tvnow] bugfix & download whole serie #15837

Closed
wants to merge 11 commits into from
1 change: 1 addition & 0 deletions youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@
from .tvnow import (
TVNowIE,
TVNowListIE,
TVNowListChannelIE,
)
from .tvp import (
TVPEmbedIE,
Expand Down
67 changes: 54 additions & 13 deletions youtube_dl/extractor/tvnow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ def _call_api(self, path, video_id, query):
'https://api.tvnow.de/v3/' + path,
video_id, query=query)

def _extend_query(self, show, season, video=None):
fields = []
fields.extend(show)
fields.extend('formatTabs.%s' % field for field in season)
if video:
fields.extend(
'formatTabs.formatTabPages.container.movies.%s' % field
for field in video)

return fields

def _tvnow_list_info(self, list_id, show_id, fields):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used in single video extractor thus should not be here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is fixed

return self._call_api(
'formats/seo', list_id, query={
'fields': ','.join(fields),
'name': show_id + '.php'
})

def _extract_video(self, info, display_id):
video_id = compat_str(info['id'])
title = info['title']
Expand Down Expand Up @@ -152,18 +170,8 @@ class TVNowListIE(TVNowBaseIE):
def _real_extract(self, url):
base_url, show_id, season_id = re.match(self._VALID_URL, url).groups()

fields = []
fields.extend(self._SHOW_FIELDS)
fields.extend('formatTabs.%s' % field for field in self._SEASON_FIELDS)
fields.extend(
'formatTabs.formatTabPages.container.movies.%s' % field
for field in self._VIDEO_FIELDS)

list_info = self._call_api(
'formats/seo', season_id, query={
'fields': ','.join(fields),
'name': show_id + '.php'
})
fields = self._extend_query(self._SHOW_FIELDS, self._SEASON_FIELDS, self._VIDEO_FIELDS)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code duplication 173, 213. There is no sense to extract fields explicitly.

list_info = self._tvnow_list_info(season_id, show_id, fields)

season = next(
season for season in list_info['formatTabs']['items']
Expand All @@ -178,7 +186,40 @@ def _real_extract(self, url):
if not seo_url:
continue
entries.append(self.url_result(
base_url + seo_url + '/player', 'TVNow', info.get('id')))
base_url + seo_url + '/player', 'TVNow', str(info.get('id'))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing changed.


return self.playlist_result(
entries, compat_str(season.get('id') or season_id), title)


class TVNowListChannelIE(TVNowBaseIE):
_VALID_URL = r'(?P<base_url>https?://(?:www\.)?tvnow\.(?:de|at|ch)/(?:rtl(?:2|plus)?|nitro|superrtl|ntv|vox)/(?P<show_id>[^/]+)$)'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've already pointed out: no trailing $. Override suitable instead.


_SHOW_FIELDS = ('id', 'title', )
_SEASON_FIELDS = ('id', 'headline', 'seoheadline', )

_TESTS = [{
'url': 'https://www.tvnow.at/vox/ab-ins-beet',
'info_dict': {
'id': 172,
'title': 'Ab ins Beet!',
},
'playlist_mincount': 1,
}]

def _real_extract(self, url):
base_url, show_id = re.match(self._VALID_URL, url).groups()

fields = self._extend_query(self._SHOW_FIELDS, self._SEASON_FIELDS, self._VIDEO_FIELDS)
list_info = self._tvnow_list_info(show_id, show_id, fields)

entries = []
for season_info in list_info['formatTabs']['items']:
season_url = season_info.get('seoheadline')
if not season_url:
continue
entries.append(self.url_result(
base_url + "/list/" + season_url, 'TVNowList', compat_str(season_info.get('id')), season_info.get('headline')))

return self.playlist_result(
entries, list_info['id'], list_info['title'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playlist id and title should not be fatal.