mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-26 09:11:25 +01:00
Compare commits
7 Commits
a51aab35fc
...
cd058ada17
Author | SHA1 | Date | |
---|---|---|---|
|
cd058ada17 | ||
|
f2a4983df7 | ||
|
bacc31b05a | ||
|
311dc3d438 | ||
|
620d721779 | ||
|
6d23661542 | ||
|
d816fb28dc |
|
@ -2083,6 +2083,10 @@ from .theplatform import (
|
||||||
from .thestar import TheStarIE
|
from .thestar import TheStarIE
|
||||||
from .thesun import TheSunIE
|
from .thesun import TheSunIE
|
||||||
from .theweatherchannel import TheWeatherChannelIE
|
from .theweatherchannel import TheWeatherChannelIE
|
||||||
|
from .thirtydaysinger import (
|
||||||
|
ThirtyDaySingerIE,
|
||||||
|
ThirtyDaySingerPlaylistIE
|
||||||
|
)
|
||||||
from .thisamericanlife import ThisAmericanLifeIE
|
from .thisamericanlife import ThisAmericanLifeIE
|
||||||
from .thisoldhouse import ThisOldHouseIE
|
from .thisoldhouse import ThisOldHouseIE
|
||||||
from .thisvid import (
|
from .thisvid import (
|
||||||
|
|
|
@ -205,6 +205,26 @@ class ArchiveOrgIE(InfoExtractor):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
}, {
|
||||||
|
# The reviewbody is None for one of the reviews; just need to extract data without crashing
|
||||||
|
'url': 'https://archive.org/details/gd95-04-02.sbd.11622.sbeok.shnf/gd95-04-02d1t04.shn',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'gd95-04-02.sbd.11622.sbeok.shnf/gd95-04-02d1t04.shn',
|
||||||
|
'ext': 'mp3',
|
||||||
|
'title': 'Stuck Inside of Mobile with the Memphis Blues Again',
|
||||||
|
'creators': ['Grateful Dead'],
|
||||||
|
'duration': 338.31,
|
||||||
|
'track': 'Stuck Inside of Mobile with the Memphis Blues Again',
|
||||||
|
'description': 'md5:764348a470b986f1217ffd38d6ac7b72',
|
||||||
|
'display_id': 'gd95-04-02d1t04.shn',
|
||||||
|
'location': 'Pyramid Arena',
|
||||||
|
'uploader': 'jon@archive.org',
|
||||||
|
'album': '1995-04-02 - Pyramid Arena',
|
||||||
|
'upload_date': '20040519',
|
||||||
|
'track_number': 4,
|
||||||
|
'release_date': '19950402',
|
||||||
|
'timestamp': 1084927901,
|
||||||
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -335,7 +355,7 @@ class ArchiveOrgIE(InfoExtractor):
|
||||||
info['comments'].append({
|
info['comments'].append({
|
||||||
'id': review.get('review_id'),
|
'id': review.get('review_id'),
|
||||||
'author': review.get('reviewer'),
|
'author': review.get('reviewer'),
|
||||||
'text': str_or_none(review.get('reviewtitle'), '') + '\n\n' + review.get('reviewbody'),
|
'text': join_nonempty('reviewtitle', 'reviewbody', from_dict=review, delim='\n\n'),
|
||||||
'timestamp': unified_timestamp(review.get('createdate')),
|
'timestamp': unified_timestamp(review.get('createdate')),
|
||||||
'parent': 'root'})
|
'parent': 'root'})
|
||||||
|
|
||||||
|
|
|
@ -563,13 +563,13 @@ class FacebookIE(InfoExtractor):
|
||||||
return extract_video_data(try_get(
|
return extract_video_data(try_get(
|
||||||
js_data, lambda x: x['jsmods']['instances'], list) or [])
|
js_data, lambda x: x['jsmods']['instances'], list) or [])
|
||||||
|
|
||||||
def extract_dash_manifest(video, formats):
|
def extract_dash_manifest(vid_data, formats, mpd_url=None):
|
||||||
dash_manifest = traverse_obj(
|
dash_manifest = traverse_obj(
|
||||||
video, 'dash_manifest', 'playlist', 'dash_manifest_xml_string', expected_type=str)
|
vid_data, 'dash_manifest', 'playlist', 'dash_manifest_xml_string', 'manifest_xml', expected_type=str)
|
||||||
if dash_manifest:
|
if dash_manifest:
|
||||||
formats.extend(self._parse_mpd_formats(
|
formats.extend(self._parse_mpd_formats(
|
||||||
compat_etree_fromstring(urllib.parse.unquote_plus(dash_manifest)),
|
compat_etree_fromstring(urllib.parse.unquote_plus(dash_manifest)),
|
||||||
mpd_url=url_or_none(video.get('dash_manifest_url'))))
|
mpd_url=url_or_none(video.get('dash_manifest_url')) or mpd_url))
|
||||||
|
|
||||||
def process_formats(info):
|
def process_formats(info):
|
||||||
# Downloads with browser's User-Agent are rate limited. Working around
|
# Downloads with browser's User-Agent are rate limited. Working around
|
||||||
|
@ -619,9 +619,12 @@ class FacebookIE(InfoExtractor):
|
||||||
video = video['creation_story']
|
video = video['creation_story']
|
||||||
video['owner'] = traverse_obj(video, ('short_form_video_context', 'video_owner'))
|
video['owner'] = traverse_obj(video, ('short_form_video_context', 'video_owner'))
|
||||||
video.update(reel_info)
|
video.update(reel_info)
|
||||||
fmt_data = traverse_obj(video, ('videoDeliveryLegacyFields', {dict})) or video
|
|
||||||
formats = []
|
formats = []
|
||||||
q = qualities(['sd', 'hd'])
|
q = qualities(['sd', 'hd'])
|
||||||
|
|
||||||
|
# Legacy formats extraction
|
||||||
|
fmt_data = traverse_obj(video, ('videoDeliveryLegacyFields', {dict})) or video
|
||||||
for key, format_id in (('playable_url', 'sd'), ('playable_url_quality_hd', 'hd'),
|
for key, format_id in (('playable_url', 'sd'), ('playable_url_quality_hd', 'hd'),
|
||||||
('playable_url_dash', ''), ('browser_native_hd_url', 'hd'),
|
('playable_url_dash', ''), ('browser_native_hd_url', 'hd'),
|
||||||
('browser_native_sd_url', 'sd')):
|
('browser_native_sd_url', 'sd')):
|
||||||
|
@ -629,7 +632,7 @@ class FacebookIE(InfoExtractor):
|
||||||
if not playable_url:
|
if not playable_url:
|
||||||
continue
|
continue
|
||||||
if determine_ext(playable_url) == 'mpd':
|
if determine_ext(playable_url) == 'mpd':
|
||||||
formats.extend(self._extract_mpd_formats(playable_url, video_id))
|
formats.extend(self._extract_mpd_formats(playable_url, video_id, fatal=False))
|
||||||
else:
|
else:
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': format_id,
|
'format_id': format_id,
|
||||||
|
@ -638,6 +641,28 @@ class FacebookIE(InfoExtractor):
|
||||||
'url': playable_url,
|
'url': playable_url,
|
||||||
})
|
})
|
||||||
extract_dash_manifest(fmt_data, formats)
|
extract_dash_manifest(fmt_data, formats)
|
||||||
|
|
||||||
|
# New videoDeliveryResponse formats extraction
|
||||||
|
fmt_data = traverse_obj(video, ('videoDeliveryResponseFragment', 'videoDeliveryResponseResult'))
|
||||||
|
mpd_urls = traverse_obj(fmt_data, ('dash_manifest_urls', ..., 'manifest_url', {url_or_none}))
|
||||||
|
dash_manifests = traverse_obj(fmt_data, ('dash_manifests', lambda _, v: v['manifest_xml']))
|
||||||
|
for idx, dash_manifest in enumerate(dash_manifests):
|
||||||
|
extract_dash_manifest(dash_manifest, formats, mpd_url=traverse_obj(mpd_urls, idx))
|
||||||
|
if not dash_manifests:
|
||||||
|
# Only extract from MPD URLs if the manifests are not already provided
|
||||||
|
for mpd_url in mpd_urls:
|
||||||
|
formats.extend(self._extract_mpd_formats(mpd_url, video_id, fatal=False))
|
||||||
|
for prog_fmt in traverse_obj(fmt_data, ('progressive_urls', lambda _, v: v['progressive_url'])):
|
||||||
|
format_id = traverse_obj(prog_fmt, ('metadata', 'quality', {str.lower}))
|
||||||
|
formats.append({
|
||||||
|
'format_id': format_id,
|
||||||
|
# sd, hd formats w/o resolution info should be deprioritized below DASH
|
||||||
|
'quality': q(format_id) - 3,
|
||||||
|
'url': prog_fmt['progressive_url'],
|
||||||
|
})
|
||||||
|
for m3u8_url in traverse_obj(fmt_data, ('hls_playlist_urls', ..., 'hls_playlist_url', {url_or_none})):
|
||||||
|
formats.extend(self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', fatal=False, m3u8_id='hls'))
|
||||||
|
|
||||||
if not formats:
|
if not formats:
|
||||||
# Do not append false positive entry w/o any formats
|
# Do not append false positive entry w/o any formats
|
||||||
return
|
return
|
||||||
|
|
107
yt_dlp/extractor/thirtydaysinger.py
Normal file
107
yt_dlp/extractor/thirtydaysinger.py
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
import re
|
||||||
|
|
||||||
|
from .wistia import WistiaBaseIE
|
||||||
|
from ..utils import (
|
||||||
|
clean_html,
|
||||||
|
get_elements_html_by_class
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ThirtyDaySingerBase(WistiaBaseIE):
|
||||||
|
_INDEX_EXTRACTION_RE = r'/tutorial/[\w-]+/(?P<index>[\w-]+)'
|
||||||
|
|
||||||
|
def _extract_for_url(self, url):
|
||||||
|
lesson_index = re.search(self._INDEX_EXTRACTION_RE, url).group('index')
|
||||||
|
webpage = self._download_webpage(url, lesson_index)
|
||||||
|
match = next(self._extract_wistia_async_embed(webpage))
|
||||||
|
embed_config = self._download_embed_config('medias', match.group('id'), url)
|
||||||
|
|
||||||
|
embed_infojson = self._extract_media(embed_config)
|
||||||
|
webpage_infojson = self._extract_webpage_data(webpage)
|
||||||
|
|
||||||
|
return {**embed_infojson, **webpage_infojson}
|
||||||
|
|
||||||
|
def _extract_webpage_data(self, webpage):
|
||||||
|
title = self._html_search_regex(r'<h1>([^<]+)</h1>', webpage, 'title')
|
||||||
|
fallback_title = self._html_extract_title(webpage)
|
||||||
|
description = self._html_search_meta('description', webpage, fatal=False)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'title': title or fallback_title,
|
||||||
|
'description': clean_html(self._format_html_list(description))
|
||||||
|
}
|
||||||
|
|
||||||
|
# The site makes extensive use of HTML lists for formatting and `clean_html`
|
||||||
|
# doesn't handle them well. This is needed to keep lists readable.
|
||||||
|
def _format_html_list(self, html):
|
||||||
|
replacements = {
|
||||||
|
'<ul>': '<br>',
|
||||||
|
'</ul': '<br>',
|
||||||
|
'<li>': '<br>- ',
|
||||||
|
'</li>': ''
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v in replacements.items():
|
||||||
|
html = html.replace(k, v)
|
||||||
|
|
||||||
|
return html
|
||||||
|
|
||||||
|
|
||||||
|
class ThirtyDaySingerIE(ThirtyDaySingerBase):
|
||||||
|
_VALID_URL = r'https?://www\.30daysinger\.com/tutorial/[\w-]+/[\w-]+'
|
||||||
|
|
||||||
|
_TESTS = [{
|
||||||
|
'url': 'https://www.30daysinger.com/tutorial/30-day-beginner-course-with-jonathan-estabrooks/1',
|
||||||
|
'md5': '56bb11529b9777899b27b599d4b16cf6',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'tegd38l3d5',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'thumbnail': 'http://embed.wistia.com/deliveries/c26a85cb98e32efa8a5e12a0576e63355af66230.jpg',
|
||||||
|
'upload_date': '20190608',
|
||||||
|
'description': 'md5:d3291de8988be57b1d3e411126ba4d33',
|
||||||
|
'duration': 344.22,
|
||||||
|
'timestamp': 1559952526,
|
||||||
|
'title': 'Welcome to 30 Day Singer'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
return self._extract_for_url(url)
|
||||||
|
|
||||||
|
|
||||||
|
class ThirtyDaySingerPlaylistIE(ThirtyDaySingerBase):
|
||||||
|
_URI_BASE = 'https://www.30daysinger.com'
|
||||||
|
_VALID_URL = r'https?://www\.30daysinger\.com/tutorial/(?P<playlist_id>[\w-]+)/?(?:$|[#?])'
|
||||||
|
|
||||||
|
_TESTS = [{
|
||||||
|
'url': 'https://www.30daysinger.com/tutorial/30-day-beginner-course-with-jonathan-estabrooks',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '30-day-beginner-course-with-jonathan-estabrooks',
|
||||||
|
'description': 'md5:8cf6d6c7c377895653c9cde9dfc4104f',
|
||||||
|
'title': '30 Day Beginner Course with Jonathan Estabrooks',
|
||||||
|
},
|
||||||
|
'playlist_count': 1,
|
||||||
|
'expected_warnings': ['This video is for premium members only']
|
||||||
|
}]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
playlist_id = self._match_valid_url(url).group('playlist_id')
|
||||||
|
webpage = self._download_webpage(url, playlist_id)
|
||||||
|
playlist_attrs = self._extract_webpage_data(webpage)
|
||||||
|
|
||||||
|
entries = []
|
||||||
|
for html_element in get_elements_html_by_class('playlist-item-link', webpage):
|
||||||
|
href = self._search_regex(r'href="([^"]+)"', html_element, 'href')
|
||||||
|
|
||||||
|
if not href:
|
||||||
|
continue
|
||||||
|
# Often _some_ content is free so we should still download that but warn the user
|
||||||
|
# when we encounter premium content.
|
||||||
|
# NOTE: this only applies to the playlist extractor, not the single video extractor
|
||||||
|
if 'upgrade' in href:
|
||||||
|
self.report_warning('This video is for premium members only')
|
||||||
|
continue
|
||||||
|
|
||||||
|
entries.append(self._extract_for_url(self._URI_BASE + href))
|
||||||
|
|
||||||
|
return self.playlist_result(entries, playlist_id, playlist_attrs['title'], playlist_attrs['description'])
|
Loading…
Reference in New Issue
Block a user