3 from .common
import InfoExtractor
4 from .vimeo
import VHXEmbedIE
12 get_elements_html_by_class
,
20 class DropoutIE(InfoExtractor
):
21 _LOGIN_URL
= 'https://www.dropout.tv/login'
22 _NETRC_MACHINE
= 'dropout'
24 _VALID_URL
= r
'https?://(?:www\.)?dropout\.tv/(?:[^/]+/)*videos/(?P<id>[^/]+)/?$'
27 'url': 'https://www.dropout.tv/game-changer/season:2/videos/yes-or-no',
28 'note': 'Episode in a series',
29 'md5': '5e000fdfd8d8fa46ff40456f1c2af04a',
32 'display_id': 'yes-or-no',
35 'description': 'Ally, Brennan, and Zac are asked a simple question, but is there a correct answer?',
36 'release_date': '20200508',
37 'thumbnail': 'https://vhx.imgix.net/chuncensoredstaging/assets/351e3f24-c4a3-459a-8b79-dc80f1e5b7fd.jpg',
38 'series': 'Game Changer',
42 'episode': 'Yes or No',
44 'uploader_id': 'user80538407',
45 'uploader_url': 'https://vimeo.com/user80538407',
46 'uploader': 'OTT Videos',
48 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'],
51 'url': 'https://www.dropout.tv/dimension-20-fantasy-high/season:1/videos/episode-1',
52 'note': 'Episode in a series (missing release_date)',
53 'md5': '712caf7c191f1c47c8f1879520c2fa5c',
56 'display_id': 'episode-1',
58 'title': 'The Beginning Begins',
59 'description': 'The cast introduces their PCs, including a neurotic elf, a goblin PI, and a corn-worshipping cleric.',
60 'thumbnail': 'https://vhx.imgix.net/chuncensoredstaging/assets/4421ed0d-f630-4c88-9004-5251b2b8adfa.jpg',
61 'series': 'Dimension 20: Fantasy High',
65 'episode': 'The Beginning Begins',
67 'uploader_id': 'user80538407',
68 'uploader_url': 'https://vimeo.com/user80538407',
69 'uploader': 'OTT Videos',
71 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'],
74 'url': 'https://www.dropout.tv/videos/misfits-magic-holiday-special',
75 'note': 'Episode not in a series',
76 'md5': 'c30fa18999c5880d156339f13c953a26',
79 'display_id': 'misfits-magic-holiday-special',
81 'title': 'Misfits & Magic Holiday Special',
82 'description': 'The magical misfits spend Christmas break at Gowpenny, with an unwelcome visitor.',
83 'release_date': '20211215',
84 'thumbnail': 'https://vhx.imgix.net/chuncensoredstaging/assets/d91ea8a6-b250-42ed-907e-b30fb1c65176-8e24b8e5.jpg',
86 'uploader_id': 'user80538407',
87 'uploader_url': 'https://vimeo.com/user80538407',
88 'uploader': 'OTT Videos',
90 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'],
94 def _get_authenticity_token(self
, display_id
):
95 signin_page
= self
._download
_webpage
(
96 self
._LOGIN
_URL
, display_id
, note
='Getting authenticity token')
97 return self
._html
_search
_regex
(
98 r
'name=["\']authenticity_token
["\'] value=["\'](.+?
)["\']',
99 signin_page, 'authenticity_token')
101 def _login(self, display_id):
102 username, password = self._get_login_info()
106 response = self._download_webpage(
107 self._LOGIN_URL, display_id, note='Logging in', fatal=False,
108 data=urlencode_postdata({
110 'password': password,
111 'authenticity_token': self._get_authenticity_token(display_id),
115 user_has_subscription = self._search_regex(
116 r'user_has_subscription:\s*["\'](.+?
)["\']', response, 'subscription status', default='none')
117 if user_has_subscription.lower() == 'true':
119 elif user_has_subscription.lower() == 'false':
120 return 'Account is not subscribed'
122 return 'Incorrect username/password'
124 def _real_extract(self, url):
125 display_id = self._match_id(url)
128 if self._get_cookies('https://www.dropout.tv').get('_session'):
129 webpage = self._download_webpage(url, display_id)
130 if not webpage or '<div id="watch
-unauthorized
"' in webpage:
131 login_err = self._login(display_id)
132 webpage = self._download_webpage(url, display_id)
133 if login_err and '<div id="watch
-unauthorized
"' in webpage:
134 if login_err is True:
135 self.raise_login_required(method='any')
136 raise ExtractorError(login_err, expected=True)
138 embed_url = self._search_regex(r'embed_url:\s*["\'](.+?
)["\']', webpage, 'embed url')
139 thumbnail = self._og_search_thumbnail(webpage)
140 watch_info = get_element_by_id('watch-info', webpage) or ''
142 title = clean_html(get_element_by_class('video-title', watch_info))
143 season_episode = get_element_by_class(
144 'site-font-secondary-color', get_element_by_class('text', watch_info))
145 episode_number = int_or_none(self._search_regex(
146 r'Episode (\d+)', season_episode or '', 'episode', default=None))
149 '_type': 'url_transparent',
150 'ie_key': VHXEmbedIE.ie_key(),
151 'url': VHXEmbedIE._smuggle_referrer(embed_url, 'https://www.dropout.tv'),
152 'id': self._search_regex(r'embed\.vhx\.tv/videos/(.+?)\?', embed_url, 'id'),
153 'display_id': display_id,
155 'description': self._html_search_meta('description', webpage, fatal=False),
156 'thumbnail': thumbnail.split('?')[0] if thumbnail else None, # Ignore crop/downscale
157 'series': clean_html(get_element_by_class('series-title', watch_info)),
158 'episode_number': episode_number,
159 'episode': title if episode_number else None,
160 'season_number': int_or_none(self._search_regex(
161 r'Season (\d+),', season_episode or '', 'season', default=None)),
162 'release_date': unified_strdate(self._search_regex(
163 r'data-meta-field-name=["\']release_dates
["\'] data-meta-field-value=["\'](.+?
)["\']',
164 watch_info, 'release date', default=None)),
168 class DropoutSeasonIE(InfoExtractor):
170 _VALID_URL = r'https?://(?:www\.)?dropout\.tv/(?P<id>[^\/$&?#]+)(?:/?$|/season:(?P<season>[0-9]+)/?$)'
173 'url': 'https://www.dropout.tv/dimension-20-fantasy-high/season:1',
174 'note': 'Multi-season series with the season in the url',
175 'playlist_count': 24,
177 'id': 'dimension-20-fantasy-high-season-1',
178 'title': 'Dimension 20 Fantasy High - Season 1',
182 'url': 'https://www.dropout.tv/dimension-20-fantasy-high',
183 'note': 'Multi-season series with the season not in the url',
184 'playlist_count': 24,
186 'id': 'dimension-20-fantasy-high-season-1',
187 'title': 'Dimension 20 Fantasy High - Season 1',
191 'url': 'https://www.dropout.tv/dimension-20-shriek-week',
192 'note': 'Single-season series',
195 'id': 'dimension-20-shriek-week-season-1',
196 'title': 'Dimension 20 Shriek Week - Season 1',
200 'url': 'https://www.dropout.tv/breaking-news-no-laugh-newsroom/season:3',
201 'note': 'Multi-season series with season in the url that requires pagination',
202 'playlist_count': 25,
204 'id': 'breaking-news-no-laugh-newsroom-season-3',
205 'title': 'Breaking News No Laugh Newsroom - Season 3',
210 def _fetch_page(self, url, season_id, page):
212 webpage = self._download_webpage(
213 f'{url}?page={page}', season_id, note=f'Downloading page {page}', expected_status={400})
214 yield from [self.url_result(item_url, DropoutIE) for item_url in traverse_obj(
215 get_elements_html_by_class('browse-item-link', webpage), (..., {extract_attributes}, 'href'))]
217 def _real_extract(self, url):
218 season_id = self._match_id(url)
219 season_num = self._match_valid_url(url).group('season') or 1
220 season_title = season_id.replace('-', ' ').title()
222 return self.playlist_result(
223 OnDemandPagedList(functools.partial(self._fetch_page, url, season_id), self._PAGE_SIZE),
224 f'{season_id}-season-{season_num}', f'{season_title} - Season {season_num}')