Skip to content

Commit 5063bc4

Browse files
authored
Merge pull request #18 from oleksis/master
Update youtube-dl 2020.12.12
2 parents bb899ff + bf266d8 commit 5063bc4

18 files changed

+874
-583
lines changed

youtube_dl/YoutubeDL.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2410,7 +2410,7 @@ def _write_thumbnails(self, info_dict, filename):
24102410
thumb_ext = determine_ext(t['url'], 'jpg')
24112411
suffix = '_%s' % t['id'] if len(thumbnails) > 1 else ''
24122412
thumb_display_id = '%s ' % t['id'] if len(thumbnails) > 1 else ''
2413-
t['filename'] = thumb_filename = os.path.splitext(filename)[0] + suffix + '.' + thumb_ext
2413+
t['filename'] = thumb_filename = replace_extension(filename + suffix, thumb_ext, info_dict.get('ext'))
24142414

24152415
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(thumb_filename)):
24162416
self.to_screen('[%s] %s: Thumbnail %sis already present' %

youtube_dl/extractor/amcnetworks.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# coding: utf-8
22
from __future__ import unicode_literals
33

4+
import re
5+
46
from .theplatform import ThePlatformIE
57
from ..utils import (
68
int_or_none,
@@ -11,25 +13,22 @@
1113

1214

1315
class AMCNetworksIE(ThePlatformIE):
14-
_VALID_URL = r'https?://(?:www\.)?(?:amc|bbcamerica|ifc|(?:we|sundance)tv)\.com/(?:movies|shows(?:/[^/]+)+)/(?P<id>[^/?#]+)'
16+
_VALID_URL = r'https?://(?:www\.)?(?P<site>amc|bbcamerica|ifc|(?:we|sundance)tv)\.com/(?P<id>(?:movies|shows(?:/[^/]+)+)/[^/?#&]+)'
1517
_TESTS = [{
16-
'url': 'http://www.ifc.com/shows/maron/season-04/episode-01/step-1',
17-
'md5': '',
18+
'url': 'https://www.bbcamerica.com/shows/the-graham-norton-show/videos/tina-feys-adorable-airline-themed-family-dinner--51631',
1819
'info_dict': {
19-
'id': 's3MX01Nl4vPH',
20+
'id': '4Lq1dzOnZGt0',
2021
'ext': 'mp4',
21-
'title': 'Maron - Season 4 - Step 1',
22-
'description': 'In denial about his current situation, Marc is reluctantly convinced by his friends to enter rehab. Starring Marc Maron and Constance Zimmer.',
23-
'age_limit': 17,
24-
'upload_date': '20160505',
25-
'timestamp': 1462468831,
22+
'title': "The Graham Norton Show - Season 28 - Tina Fey's Adorable Airline-Themed Family Dinner",
23+
'description': "It turns out child stewardesses are very generous with the wine! All-new episodes of 'The Graham Norton Show' premiere Fridays at 11/10c on BBC America.",
24+
'upload_date': '20201120',
25+
'timestamp': 1605904350,
2626
'uploader': 'AMCN',
2727
},
2828
'params': {
2929
# m3u8 download
3030
'skip_download': True,
3131
},
32-
'skip': 'Requires TV provider accounts',
3332
}, {
3433
'url': 'http://www.bbcamerica.com/shows/the-hunt/full-episodes/season-1/episode-01-the-hardest-challenge',
3534
'only_matching': True,
@@ -55,32 +54,33 @@ class AMCNetworksIE(ThePlatformIE):
5554
'url': 'https://www.sundancetv.com/shows/riviera/full-episodes/season-1/episode-01-episode-1',
5655
'only_matching': True,
5756
}]
57+
_REQUESTOR_ID_MAP = {
58+
'amc': 'AMC',
59+
'bbcamerica': 'BBCA',
60+
'ifc': 'IFC',
61+
'sundancetv': 'SUNDANCE',
62+
'wetv': 'WETV',
63+
}
5864

5965
def _real_extract(self, url):
60-
display_id = self._match_id(url)
61-
webpage = self._download_webpage(url, display_id)
66+
site, display_id = re.match(self._VALID_URL, url).groups()
67+
requestor_id = self._REQUESTOR_ID_MAP[site]
68+
properties = self._download_json(
69+
'https://content-delivery-gw.svc.ds.amcn.com/api/v2/content/amcn/%s/url/%s' % (requestor_id.lower(), display_id),
70+
display_id)['data']['properties']
6271
query = {
6372
'mbr': 'true',
6473
'manifest': 'm3u',
6574
}
66-
media_url = self._search_regex(
67-
r'window\.platformLinkURL\s*=\s*[\'"]([^\'"]+)',
68-
webpage, 'media url')
69-
theplatform_metadata = self._download_theplatform_metadata(self._search_regex(
70-
r'link\.theplatform\.com/s/([^?]+)',
71-
media_url, 'theplatform_path'), display_id)
75+
tp_path = 'M_UwQC/media/' + properties['videoPid']
76+
media_url = 'https://link.theplatform.com/s/' + tp_path
77+
theplatform_metadata = self._download_theplatform_metadata(tp_path, display_id)
7278
info = self._parse_theplatform_metadata(theplatform_metadata)
7379
video_id = theplatform_metadata['pid']
7480
title = theplatform_metadata['title']
7581
rating = try_get(
7682
theplatform_metadata, lambda x: x['ratings'][0]['rating'])
77-
auth_required = self._search_regex(
78-
r'window\.authRequired\s*=\s*(true|false);',
79-
webpage, 'auth required')
80-
if auth_required == 'true':
81-
requestor_id = self._search_regex(
82-
r'window\.requestor_id\s*=\s*[\'"]([^\'"]+)',
83-
webpage, 'requestor id')
83+
if properties.get('videoCategory') == 'TVE-Auth':
8484
resource = self._get_mvpd_resource(
8585
requestor_id, title, video_id, rating)
8686
query['auth'] = self._extract_mvpd_auth(
Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
# coding: utf-8
22
from __future__ import unicode_literals
33

4+
import re
5+
46
from .common import InfoExtractor
57
from ..utils import (
68
clean_html,
7-
int_or_none,
8-
js_to_json,
99
try_get,
1010
unified_strdate,
1111
)
1212

1313

1414
class AmericasTestKitchenIE(InfoExtractor):
15-
_VALID_URL = r'https?://(?:www\.)?americastestkitchen\.com/(?:episode|videos)/(?P<id>\d+)'
15+
_VALID_URL = r'https?://(?:www\.)?(?:americastestkitchen|cooks(?:country|illustrated))\.com/(?P<resource_type>episode|videos)/(?P<id>\d+)'
1616
_TESTS = [{
1717
'url': 'https://www.americastestkitchen.com/episode/582-weeknight-japanese-suppers',
1818
'md5': 'b861c3e365ac38ad319cfd509c30577f',
1919
'info_dict': {
2020
'id': '5b400b9ee338f922cb06450c',
21-
'title': 'Weeknight Japanese Suppers',
21+
'title': 'Japanese Suppers',
2222
'ext': 'mp4',
23-
'description': 'md5:3d0c1a44bb3b27607ce82652db25b4a8',
23+
'description': 'md5:64e606bfee910627efc4b5f050de92b3',
2424
'thumbnail': r're:^https?://',
2525
'timestamp': 1523664000,
2626
'upload_date': '20180414',
27-
'release_date': '20180414',
27+
'release_date': '20180410',
2828
'series': "America's Test Kitchen",
2929
'season_number': 18,
30-
'episode': 'Weeknight Japanese Suppers',
30+
'episode': 'Japanese Suppers',
3131
'episode_number': 15,
3232
},
3333
'params': {
@@ -36,47 +36,31 @@ class AmericasTestKitchenIE(InfoExtractor):
3636
}, {
3737
'url': 'https://www.americastestkitchen.com/videos/3420-pan-seared-salmon',
3838
'only_matching': True,
39+
}, {
40+
'url': 'https://www.cookscountry.com/episode/564-when-only-chocolate-will-do',
41+
'only_matching': True,
42+
}, {
43+
'url': 'https://www.cooksillustrated.com/videos/4478-beef-wellington',
44+
'only_matching': True,
3945
}]
4046

4147
def _real_extract(self, url):
42-
video_id = self._match_id(url)
43-
44-
webpage = self._download_webpage(url, video_id)
48+
resource_type, video_id = re.match(self._VALID_URL, url).groups()
49+
is_episode = resource_type == 'episode'
50+
if is_episode:
51+
resource_type = 'episodes'
4552

46-
video_data = self._parse_json(
47-
self._search_regex(
48-
r'window\.__INITIAL_STATE__\s*=\s*({.+?})\s*;\s*</script>',
49-
webpage, 'initial context'),
50-
video_id, js_to_json)
51-
52-
ep_data = try_get(
53-
video_data,
54-
(lambda x: x['episodeDetail']['content']['data'],
55-
lambda x: x['videoDetail']['content']['data']), dict)
56-
ep_meta = ep_data.get('full_video', {})
57-
58-
zype_id = ep_data.get('zype_id') or ep_meta['zype_id']
59-
60-
title = ep_data.get('title') or ep_meta.get('title')
61-
description = clean_html(ep_meta.get('episode_description') or ep_data.get(
62-
'description') or ep_meta.get('description'))
63-
thumbnail = try_get(ep_meta, lambda x: x['photo']['image_url'])
64-
release_date = unified_strdate(ep_data.get('aired_at'))
65-
66-
season_number = int_or_none(ep_meta.get('season_number'))
67-
episode = ep_meta.get('title')
68-
episode_number = int_or_none(ep_meta.get('episode_number'))
53+
resource = self._download_json(
54+
'https://www.americastestkitchen.com/api/v6/%s/%s' % (resource_type, video_id), video_id)
55+
video = resource['video'] if is_episode else resource
56+
episode = resource if is_episode else resource.get('episode') or {}
6957

7058
return {
7159
'_type': 'url_transparent',
72-
'url': 'https://player.zype.com/embed/%s.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQ' % zype_id,
60+
'url': 'https://player.zype.com/embed/%s.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQ' % video['zypeId'],
7361
'ie_key': 'Zype',
74-
'title': title,
75-
'description': description,
76-
'thumbnail': thumbnail,
77-
'release_date': release_date,
78-
'series': "America's Test Kitchen",
79-
'season_number': season_number,
80-
'episode': episode,
81-
'episode_number': episode_number,
62+
'description': clean_html(video.get('description')),
63+
'release_date': unified_strdate(video.get('publishDate')),
64+
'series': try_get(episode, lambda x: x['show']['title']),
65+
'episode': episode.get('title'),
8266
}

youtube_dl/extractor/common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,9 +2517,9 @@ def _media_formats(src, cur_media_type, type_info={}):
25172517
# https://www.ampproject.org/docs/reference/components/amp-video)
25182518
# For dl8-* tags see https://delight-vr.com/documentation/dl8-video/
25192519
_MEDIA_TAG_NAME_RE = r'(?:(?:amp|dl8(?:-live)?)-)?(video|audio)'
2520-
media_tags = [(media_tag, media_type, '')
2521-
for media_tag, media_type
2522-
in re.findall(r'(?s)(<%s[^>]*/>)' % _MEDIA_TAG_NAME_RE, webpage)]
2520+
media_tags = [(media_tag, media_tag_name, media_type, '')
2521+
for media_tag, media_tag_name, media_type
2522+
in re.findall(r'(?s)(<(%s)[^>]*/>)' % _MEDIA_TAG_NAME_RE, webpage)]
25232523
media_tags.extend(re.findall(
25242524
# We only allow video|audio followed by a whitespace or '>'.
25252525
# Allowing more characters may end up in significant slow down (see

youtube_dl/extractor/extractors.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@
9191
BBCCoUkPlaylistIE,
9292
BBCIE,
9393
)
94-
from .beampro import (
95-
BeamProLiveIE,
96-
BeamProVodIE,
97-
)
9894
from .beeg import BeegIE
9995
from .behindkink import BehindKinkIE
10096
from .bellmedia import BellMediaIE
@@ -534,7 +530,10 @@
534530
EHFTVIE,
535531
ITTFIE,
536532
)
537-
from .lbry import LBRYIE
533+
from .lbry import (
534+
LBRYIE,
535+
LBRYChannelIE,
536+
)
538537
from .lci import LCIIE
539538
from .lcp import (
540539
LcpPlayIE,
@@ -1047,12 +1046,6 @@
10471046
from .slideshare import SlideshareIE
10481047
from .slideslive import SlidesLiveIE
10491048
from .slutload import SlutloadIE
1050-
from .smotri import (
1051-
SmotriIE,
1052-
SmotriCommunityIE,
1053-
SmotriUserIE,
1054-
SmotriBroadcastIE,
1055-
)
10561049
from .snotr import SnotrIE
10571050
from .sohu import SohuIE
10581051
from .sonyliv import SonyLIVIE
@@ -1157,6 +1150,7 @@
11571150
TeleQuebecSquatIE,
11581151
TeleQuebecEmissionIE,
11591152
TeleQuebecLiveIE,
1153+
TeleQuebecVideoIE,
11601154
)
11611155
from .teletask import TeleTaskIE
11621156
from .telewebion import TelewebionIE

0 commit comments

Comments
 (0)