1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-12-11 09:27:55 +01:00
youtube-dl/youtube_dl/extractor/trutv.py

77 lines
2.7 KiB
Python
Raw Normal View History

2016-09-06 16:48:51 +02:00
# coding: utf-8
from __future__ import unicode_literals
import re
from .turner import TurnerBaseIE
2019-02-06 19:38:10 +01:00
from ..utils import (
int_or_none,
)
2016-09-06 16:48:51 +02:00
class TruTVIE(TurnerBaseIE):
2020-03-24 23:42:15 +01:00
# 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-]+)'
2016-09-06 16:48:51 +02:00
_TEST = {
2020-03-24 23:42:15 +01:00
'url': 'https://www.trutv.com/shows/impractical-jokers/season-8/episode-2/the-closer',
2016-09-06 16:48:51 +02:00
'info_dict': {
2020-03-24 23:42:15 +01:00
'id': '0b90803a0d4bba757085a61cc25be505358cd8b5',
2016-09-06 16:48:51 +02:00
'ext': 'mp4',
2020-03-24 23:42:15 +01:00
'title': 'The Closer',
'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,
2019-02-06 19:38:10 +01:00
},
'params': {
# m3u8 download
'skip_download': True,
},
2016-09-06 16:48:51 +02:00
}
def _real_extract(self, url):
2020-03-24 23:42:15 +01:00
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)
2019-02-06 19:38:10 +01:00
2020-03-24 23:42:15 +01:00
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)
eps = data['turner_playlist']
2019-02-06 19:38:10 +01:00
2020-03-24 23:42:15 +01:00
for ep in eps:
if ep['url'] in url:
video_data = ep
media_id = video_data['mediaID']
2019-02-06 19:38:10 +01:00
title = video_data['title'].strip()
info = self._extract_ngtv_info(
media_id, {}, {
'url': url,
'site_name': 'truTV',
2020-03-24 23:42:15 +01:00
'auth_required': video_data.get('authRequired'),
2016-09-06 16:48:51 +02:00
})
2019-02-06 19:38:10 +01:00
thumbnails = []
2020-03-24 23:42:15 +01:00
for images in meta.get('image', []):
for image in images:
if not image:
continue
thumbnails.append({
'url': image,
})
2019-02-06 19:38:10 +01:00
info.update({
'id': media_id,
2020-03-24 23:42:15 +01:00
'display_id': video_data.get('videoId'),
2019-02-06 19:38:10 +01:00
'title': title,
2020-03-24 23:42:15 +01:00
'description': video_data.get('shortDescription'),
2019-02-06 19:38:10 +01:00
'thumbnails': thumbnails,
2020-03-24 23:42:15 +01:00
'series': meta.get('partOfSeries').get('name'),
'season_number': int_or_none(meta.get('partOfSeason').get('seasonNumber')),
'episode_number': int_or_none(meta.get('episodeNumber')),
2019-02-06 19:38:10 +01:00
})
return info