mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2025-01-08 14:17:54 +01:00
[trutv] fix extraction + downloading
This commit is contained in:
parent
049c0486bb
commit
8dd2b6a5ef
@ -6,19 +6,22 @@ import re
|
|||||||
from .turner import TurnerBaseIE
|
from .turner import TurnerBaseIE
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_iso8601,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TruTVIE(TurnerBaseIE):
|
class TruTVIE(TurnerBaseIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?trutv\.com/(?:shows|full-episodes)/(?P<series_slug>[0-9A-Za-z-]+)/(?:videos/(?P<clip_slug>[0-9A-Za-z-]+)|(?P<id>\d+))'
|
# https://www.trutv.com/shows/impractical-jokers/season-8/episode-2/the-closer
|
||||||
|
_VALID_URL = r'https?://(?:www\.)?trutv\.com/shows/[0-9A-Za-z-]+/season-\d+/episode-\d+/(?P<id>[0-9A-Za-z-]+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://www.trutv.com/shows/the-carbonaro-effect/videos/sunlight-activated-flower.html',
|
'url': 'https://www.trutv.com/shows/impractical-jokers/season-8/episode-2/the-closer',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'f16c03beec1e84cd7d1a51f11d8fcc29124cc7f1',
|
'id': '0b90803a0d4bba757085a61cc25be505358cd8b5',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Sunlight-Activated Flower',
|
'title': 'The Closer',
|
||||||
'description': "A customer is stunned when he sees Michael's sunlight-activated flower.",
|
'description': 'Q, Joe, Sal and Murr get tech help from some confused tutors, then play Hot Potato in a shoe store. Plus, the big loser wishes he could press escape during a brutal coffee shop punishment.',
|
||||||
|
'series': 'Impractical Jokers',
|
||||||
|
'season_number': 8,
|
||||||
|
'episode_number': 2,
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
# m3u8 download
|
# m3u8 download
|
||||||
@ -27,49 +30,47 @@ class TruTVIE(TurnerBaseIE):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
series_slug, clip_slug, video_id = re.match(self._VALID_URL, url).groups()
|
episode_slug = self._match_id(url)
|
||||||
|
|
||||||
|
webpage = self._download_webpage(url, episode_slug)
|
||||||
|
|
||||||
|
meta = self._parse_json(self._html_search_regex(r'<script type="application/ld\+json">(.+)</script>', webpage, episode_slug), episode_slug)
|
||||||
|
|
||||||
if video_id:
|
data = self._parse_json(self._html_search_regex(r'<script type="application/json" data-drupal-selector="drupal-settings-json">(.+)</script>', webpage, episode_slug), episode_slug)
|
||||||
path = 'episode'
|
|
||||||
display_id = video_id
|
eps = data['turner_playlist']
|
||||||
else:
|
|
||||||
path = 'series/clip'
|
|
||||||
display_id = clip_slug
|
|
||||||
|
|
||||||
data = self._download_json(
|
for ep in eps:
|
||||||
'https://api.trutv.com/v2/web/%s/%s/%s' % (path, series_slug, display_id),
|
if ep['url'] in url:
|
||||||
display_id)
|
video_data = ep
|
||||||
video_data = data['episode'] if video_id else data['info']
|
|
||||||
media_id = video_data['mediaId']
|
media_id = video_data['mediaID']
|
||||||
title = video_data['title'].strip()
|
title = video_data['title'].strip()
|
||||||
|
|
||||||
info = self._extract_ngtv_info(
|
info = self._extract_ngtv_info(
|
||||||
media_id, {}, {
|
media_id, {}, {
|
||||||
'url': url,
|
'url': url,
|
||||||
'site_name': 'truTV',
|
'site_name': 'truTV',
|
||||||
'auth_required': video_data.get('isAuthRequired'),
|
'auth_required': video_data.get('authRequired'),
|
||||||
})
|
})
|
||||||
|
|
||||||
thumbnails = []
|
thumbnails = []
|
||||||
for image in video_data.get('images', []):
|
for images in meta.get('image', []):
|
||||||
image_url = image.get('srcUrl')
|
for image in images:
|
||||||
if not image_url:
|
if not image:
|
||||||
continue
|
continue
|
||||||
thumbnails.append({
|
thumbnails.append({
|
||||||
'url': image_url,
|
'url': image,
|
||||||
'width': int_or_none(image.get('width')),
|
})
|
||||||
'height': int_or_none(image.get('height')),
|
|
||||||
})
|
|
||||||
|
|
||||||
info.update({
|
info.update({
|
||||||
'id': media_id,
|
'id': media_id,
|
||||||
'display_id': display_id,
|
'display_id': video_data.get('videoId'),
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': video_data.get('description'),
|
'description': video_data.get('shortDescription'),
|
||||||
'thumbnails': thumbnails,
|
'thumbnails': thumbnails,
|
||||||
'timestamp': parse_iso8601(video_data.get('publicationDate')),
|
'series': meta.get('partOfSeries').get('name'),
|
||||||
'series': video_data.get('showTitle'),
|
'season_number': int_or_none(meta.get('partOfSeason').get('seasonNumber')),
|
||||||
'season_number': int_or_none(video_data.get('seasonNum')),
|
'episode_number': int_or_none(meta.get('episodeNumber')),
|
||||||
'episode_number': int_or_none(video_data.get('episodeNum')),
|
|
||||||
})
|
})
|
||||||
return info
|
return info
|
||||||
|
@ -196,8 +196,8 @@ class TurnerBaseIE(AdobePassIE):
|
|||||||
|
|
||||||
def _extract_ngtv_info(self, media_id, tokenizer_query, ap_data=None):
|
def _extract_ngtv_info(self, media_id, tokenizer_query, ap_data=None):
|
||||||
streams_data = self._download_json(
|
streams_data = self._download_json(
|
||||||
'http://medium.ngtv.io/media/%s/tv' % media_id,
|
'http://medium.ngtv.io/media/%s/desktop' % media_id,
|
||||||
media_id)['media']['tv']
|
media_id)['media']['desktop']
|
||||||
duration = None
|
duration = None
|
||||||
chapters = []
|
chapters = []
|
||||||
formats = []
|
formats = []
|
||||||
|
Loading…
Reference in New Issue
Block a user