From df4f82c389476fc1ea029c789fa6a27181dfa513 Mon Sep 17 00:00:00 2001 From: AndersVittrup Date: Sat, 4 Jan 2020 19:26:23 +0100 Subject: [PATCH 1/7] Added temp fix for better audio selection normally to 160 --- youtube_dl/extractor/dplay.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/dplay.py b/youtube_dl/extractor/dplay.py index a7b9db568..5b80a12bb 100644 --- a/youtube_dl/extractor/dplay.py +++ b/youtube_dl/extractor/dplay.py @@ -183,10 +183,19 @@ class DPlayIE(InfoExtractor): formats.extend(self._extract_mpd_formats( format_url, display_id, mpd_id='dash', fatal=False)) elif format_id == 'hls' or ext == 'm3u8': - formats.extend(self._extract_m3u8_formats( + temp_formats = self._extract_m3u8_formats( format_url, display_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', - fatal=False)) + fatal=False) + + for f in temp_formats: + if f['ext'] == 'mp4' and f['vcodec'] == 'none' and 'mp4a' in f['format_id']: + for i in f['format_id'].split('-'): + if 'mp4a' in i: + splitted_format = i.split('mp4a') + f['acodec'] = 'mp4a' + splitted_format[1] + f['tbr'] = int(splitted_format[0])/1000 + formats.extend(temp_formats) else: formats.append({ 'url': format_url, From 88199bf54c0941f5dec50fe08c9d3297bbe62c19 Mon Sep 17 00:00:00 2001 From: AndersVittrup Date: Sat, 4 Jan 2020 19:26:48 +0100 Subject: [PATCH 2/7] Added playlist both from series and season --- youtube_dl/extractor/drtv.py | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/youtube_dl/extractor/drtv.py b/youtube_dl/extractor/drtv.py index 390e79f8c..786150e95 100644 --- a/youtube_dl/extractor/drtv.py +++ b/youtube_dl/extractor/drtv.py @@ -21,6 +21,8 @@ from ..utils import ( unified_timestamp, update_url_query, url_or_none, + base_url, + urljoin ) @@ -295,6 +297,74 @@ class DRTVIE(InfoExtractor): 'release_year': int_or_none(data.get('ProductionYear')), } +class DRTVPlaylistIE(InfoExtractor): + _VALID_URL = r'''(?x) + https?:// + (?: + (?:www\.)?(?:dr\.dk)/drtv/(?:serie|saeson)/ + ) + (?P[\da-z_-]+) + ''' + _TEST = { + 'url': 'https://www.dr.dk/drtv/serie/spise-med-price_43537', + 'info_dict': { + 'id': 'spise-med-price', + 'title': 'Spise med Price' + }, + 'playlist_mincount': 6, + } + + @classmethod + def suitable(cls, url): + return False if DRTVIE.suitable(url) else super( + DRTVPlaylistIE, cls).suitable(url) + + def _extract_series(self, url): + display_id = self._match_id(url) + webpage = self._download_webpage(url, display_id) + + episodes = [] + for season in re.finditer(r'href="(?P/drtv/saeson/.+?)"', webpage): + season_url = urljoin(base_url(url), season.group('url')) + episodes = episodes + self._extract_episode_from_season(season_url) + + return episodes + + def _extract_episode_from_season(self, url): + display_id = self._match_id(url) + webpage = self._download_webpage(url, display_id) + + episodes = [] + + for episode in re.finditer(r'href="(?P/drtv/se/.+?)"', webpage): + episode_url = urljoin(base_url(url), episode.group('url')) + episodes.append(episode_url) + + return episodes + + + + def _real_extract(self, url): + playlist_id = self._match_id(url) + webpage = self._download_webpage(url, playlist_id) + + title = self._html_search_regex( + r'

(.+?)

', webpage, + 'title', default=None) + + if title: + title = re.sub(r'\s*\|\s*.+?$', '', title) + + episodes = [] + if 'serie' in url: + episodes = self._extract_series(url) + elif 'saeson' in url: + episodes = self._extract_episode_from_season(url) + + entries = [self.url_result(ep, ie=DRTVIE.ie_key()) for ep in episodes] + + return self.playlist_result(entries, playlist_id, title) + class DRTVLiveIE(InfoExtractor): IE_NAME = 'drtv:live' From 22f7414a46d6929e546ded74edc003c67fbc2c2f Mon Sep 17 00:00:00 2001 From: AndersVittrup Date: Sat, 4 Jan 2020 19:27:12 +0100 Subject: [PATCH 3/7] Added playlist --- youtube_dl/extractor/discoverynetworks.py | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/youtube_dl/extractor/discoverynetworks.py b/youtube_dl/extractor/discoverynetworks.py index 607a54948..505f6d529 100644 --- a/youtube_dl/extractor/discoverynetworks.py +++ b/youtube_dl/extractor/discoverynetworks.py @@ -3,8 +3,13 @@ from __future__ import unicode_literals import re +from .common import InfoExtractor from .dplay import DPlayIE +from ..utils import ( + urljoin +) + class DiscoveryNetworksDeIE(DPlayIE): _VALID_URL = r'https?://(?:www\.)?(?P(?:tlc|dmax)\.de|dplay\.co\.uk)/(?:programme|show)/(?P[^/]+)/video/(?P[^/]+)' @@ -38,3 +43,45 @@ class DiscoveryNetworksDeIE(DPlayIE): return self._get_disco_api_info( url, '%s/%s' % (programme, alternate_id), 'sonic-eu1-prod.disco-api.com', realm, country) + + +class DiscoveryNetworksDePlaylistIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?(?P(?:tlc|dmax)\.de|dplay\.co\.uk)/(?Pprogramme|show)/(?P[^/]+)' + + _TESTS = [{ + 'url': 'https://www.dplay.co.uk/show/hairy-bikers-mississippi-adventure', + 'only_matching': True + },{ + 'url': 'https://www.dmax.de/programme/naked-survival', + 'only_matching': True + }] + + @classmethod + def suitable(cls, url): + return False if DiscoveryNetworksDeIE.suitable(url) else super( + DiscoveryNetworksDePlaylistIE, cls).suitable(url) + + def _extract_episodes(self, url, webpage, _type, program): + episodes = [] + for episode in re.finditer(r'"path":"' + program + r'(?P/.+?)"', webpage): + episode_url = urljoin( url, '/' + _type + '/' + program + '/video' + episode.group('episode')) + if episode_url not in episodes: + episodes.append(episode_url) + return episodes + + def _real_extract(self, url): + domain, _type, programme = re.match(self._VALID_URL, url).groups() + webpage = self._download_webpage(url, programme) + + title = self._html_search_regex( + r'
(.+?)
', webpage, + 'title', default=None) + + if title: + title = re.sub(r'\s*\|\s*.+?$', '', title) + + episodes = self._extract_episodes(url, webpage, _type, programme) + + entries = [self.url_result(ep, ie=DiscoveryNetworksDeIE.ie_key()) for ep in episodes] + + return self.playlist_result(entries, programme, title) From 03f0f7c4375722e9525ecc64c6554f0132c94097 Mon Sep 17 00:00:00 2001 From: AndersVittrup Date: Sat, 4 Jan 2020 19:27:37 +0100 Subject: [PATCH 4/7] Imported drtv and discoverynetworks playlists --- youtube_dl/extractor/extractors.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 7b05f5410..327025c5d 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -277,6 +277,7 @@ from .drbonanza import DRBonanzaIE from .drtuber import DrTuberIE from .drtv import ( DRTVIE, + DRTVPlaylistIE, DRTVLiveIE, ) from .dtube import DTubeIE @@ -288,7 +289,10 @@ from .discoverygo import ( DiscoveryGoIE, DiscoveryGoPlaylistIE, ) -from .discoverynetworks import DiscoveryNetworksDeIE +from .discoverynetworks import ( + DiscoveryNetworksDeIE, + DiscoveryNetworksDePlaylistIE +) from .discoveryvr import DiscoveryVRIE from .disney import DisneyIE from .dispeak import DigitallySpeakingIE From 1eab6d337cdc1db5398ec39ec3383277cee1eba4 Mon Sep 17 00:00:00 2001 From: AndersVittrup Date: Wed, 8 Jan 2020 21:56:49 +0100 Subject: [PATCH 5/7] fixed flake8 warnings --- youtube_dl/extractor/drtv.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/drtv.py b/youtube_dl/extractor/drtv.py index 786150e95..9f0df5350 100644 --- a/youtube_dl/extractor/drtv.py +++ b/youtube_dl/extractor/drtv.py @@ -297,6 +297,7 @@ class DRTVIE(InfoExtractor): 'release_year': int_or_none(data.get('ProductionYear')), } + class DRTVPlaylistIE(InfoExtractor): _VALID_URL = r'''(?x) https?:// @@ -308,10 +309,10 @@ class DRTVPlaylistIE(InfoExtractor): _TEST = { 'url': 'https://www.dr.dk/drtv/serie/spise-med-price_43537', 'info_dict': { - 'id': 'spise-med-price', + 'id': 'spise-med-price_43537', 'title': 'Spise med Price' }, - 'playlist_mincount': 6, + 'playlist_mincount': 2, } @classmethod @@ -329,7 +330,7 @@ class DRTVPlaylistIE(InfoExtractor): episodes = episodes + self._extract_episode_from_season(season_url) return episodes - + def _extract_episode_from_season(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) @@ -342,15 +343,13 @@ class DRTVPlaylistIE(InfoExtractor): return episodes - - def _real_extract(self, url): playlist_id = self._match_id(url) webpage = self._download_webpage(url, playlist_id) title = self._html_search_regex( r'

(.+?)

', webpage, - 'title', default=None) + 'title', default=None) if title: title = re.sub(r'\s*\|\s*.+?$', '', title) From bfc3ae6107bcf941b3a5171b9553223c8a1162fc Mon Sep 17 00:00:00 2001 From: AndersVittrup Date: Thu, 9 Jan 2020 21:55:35 +0100 Subject: [PATCH 6/7] Fixed test and flake8 --- youtube_dl/extractor/discoverynetworks.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/discoverynetworks.py b/youtube_dl/extractor/discoverynetworks.py index 505f6d529..82e078e60 100644 --- a/youtube_dl/extractor/discoverynetworks.py +++ b/youtube_dl/extractor/discoverynetworks.py @@ -50,10 +50,18 @@ class DiscoveryNetworksDePlaylistIE(InfoExtractor): _TESTS = [{ 'url': 'https://www.dplay.co.uk/show/hairy-bikers-mississippi-adventure', - 'only_matching': True - },{ + 'info_dict': { + 'id': 'hairy-bikers-mississippi-adventure', + 'title': 'Hairy Bikers\' Mississippi Adventure' + }, + 'playlist_mincount': 2 + }, { 'url': 'https://www.dmax.de/programme/naked-survival', - 'only_matching': True + 'info_dict': { + 'id': 'naked-survival', + 'title': 'Naked Survival' + }, + 'playlist_mincount': 2 }] @classmethod @@ -64,7 +72,7 @@ class DiscoveryNetworksDePlaylistIE(InfoExtractor): def _extract_episodes(self, url, webpage, _type, program): episodes = [] for episode in re.finditer(r'"path":"' + program + r'(?P/.+?)"', webpage): - episode_url = urljoin( url, '/' + _type + '/' + program + '/video' + episode.group('episode')) + episode_url = urljoin(url, '/' + _type + '/' + program + '/video' + episode.group('episode')) if episode_url not in episodes: episodes.append(episode_url) return episodes From 19f5991c3468e3c8eae99a46838f1590c20f0540 Mon Sep 17 00:00:00 2001 From: AndersVittrup Date: Fri, 10 Jan 2020 18:08:11 +0100 Subject: [PATCH 7/7] Added more tests --- youtube_dl/extractor/discoverynetworks.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/youtube_dl/extractor/discoverynetworks.py b/youtube_dl/extractor/discoverynetworks.py index 82e078e60..e2d8a465a 100644 --- a/youtube_dl/extractor/discoverynetworks.py +++ b/youtube_dl/extractor/discoverynetworks.py @@ -55,6 +55,13 @@ class DiscoveryNetworksDePlaylistIE(InfoExtractor): 'title': 'Hairy Bikers\' Mississippi Adventure' }, 'playlist_mincount': 2 + }, { + 'url': 'https://www.dplay.co.uk/show/diners-drive-ins-and-dives', + 'info_dict': { + 'id': 'diners-drive-ins-and-dives', + 'title': 'Diners, Drive-Ins, And Dives' + }, + 'playlist_mincount': 2 }, { 'url': 'https://www.dmax.de/programme/naked-survival', 'info_dict': {