]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/dropout.py
1 from .common
import InfoExtractor
2 from .vimeo
import VHXEmbedIE
16 class DropoutIE(InfoExtractor
):
17 _LOGIN_URL
= 'https://www.dropout.tv/login'
18 _NETRC_MACHINE
= 'dropout'
20 _VALID_URL
= r
'https?://(?:www\.)?dropout\.tv/(?:[^/]+/)*videos/(?P<id>[^/]+)/?$'
23 'url': 'https://www.dropout.tv/game-changer/season:2/videos/yes-or-no',
24 'note': 'Episode in a series',
25 'md5': '5e000fdfd8d8fa46ff40456f1c2af04a',
28 'display_id': 'yes-or-no',
31 'description': 'Ally, Brennan, and Zac are asked a simple question, but is there a correct answer?',
32 'release_date': '20200508',
33 'thumbnail': 'https://vhx.imgix.net/chuncensoredstaging/assets/351e3f24-c4a3-459a-8b79-dc80f1e5b7fd.jpg',
34 'series': 'Game Changer',
38 'episode': 'Yes or No',
40 'uploader_id': 'user80538407',
41 'uploader_url': 'https://vimeo.com/user80538407',
42 'uploader': 'OTT Videos'
44 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest']
47 'url': 'https://www.dropout.tv/dimension-20-fantasy-high/season:1/videos/episode-1',
48 'note': 'Episode in a series (missing release_date)',
49 'md5': '712caf7c191f1c47c8f1879520c2fa5c',
52 'display_id': 'episode-1',
54 'title': 'The Beginning Begins',
55 'description': 'The cast introduces their PCs, including a neurotic elf, a goblin PI, and a corn-worshipping cleric.',
56 'thumbnail': 'https://vhx.imgix.net/chuncensoredstaging/assets/4421ed0d-f630-4c88-9004-5251b2b8adfa.jpg',
57 'series': 'Dimension 20: Fantasy High',
61 'episode': 'The Beginning Begins',
63 'uploader_id': 'user80538407',
64 'uploader_url': 'https://vimeo.com/user80538407',
65 'uploader': 'OTT Videos'
67 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest']
70 'url': 'https://www.dropout.tv/videos/misfits-magic-holiday-special',
71 'note': 'Episode not in a series',
72 'md5': 'c30fa18999c5880d156339f13c953a26',
75 'display_id': 'misfits-magic-holiday-special',
77 'title': 'Misfits & Magic Holiday Special',
78 'description': 'The magical misfits spend Christmas break at Gowpenny, with an unwelcome visitor.',
79 'release_date': '20211215',
80 'thumbnail': 'https://vhx.imgix.net/chuncensoredstaging/assets/d91ea8a6-b250-42ed-907e-b30fb1c65176-8e24b8e5.jpg',
82 'uploader_id': 'user80538407',
83 'uploader_url': 'https://vimeo.com/user80538407',
84 'uploader': 'OTT Videos'
86 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest']
90 def _get_authenticity_token(self
, display_id
):
91 signin_page
= self
._download
_webpage
(
92 self
._LOGIN
_URL
, display_id
, note
='Getting authenticity token')
93 return self
._html
_search
_regex
(
94 r
'name=["\']authenticity_token
["\'] value=["\'](.+?
)["\']',
95 signin_page, 'authenticity_token')
97 def _login(self, display_id):
98 username, password = self._get_login_info()
102 response = self._download_webpage(
103 self._LOGIN_URL, display_id, note='Logging in', fatal=False,
104 data=urlencode_postdata({
106 'password': password,
107 'authenticity_token': self._get_authenticity_token(display_id),
111 user_has_subscription = self._search_regex(
112 r'user_has_subscription:\s*["\'](.+?
)["\']', response, 'subscription status', default='none')
113 if user_has_subscription.lower() == 'true':
115 elif user_has_subscription.lower() == 'false':
116 return 'Account is not subscribed'
118 return 'Incorrect username/password'
120 def _real_extract(self, url):
121 display_id = self._match_id(url)
124 if self._get_cookies('https://www.dropout.tv').get('_session'):
125 webpage = self._download_webpage(url, display_id)
126 if not webpage or '<div id="watch
-unauthorized
"' in webpage:
127 login_err = self._login(display_id)
128 webpage = self._download_webpage(url, display_id)
129 if login_err and '<div id="watch
-unauthorized
"' in webpage:
130 if login_err is True:
131 self.raise_login_required(method='any')
132 raise ExtractorError(login_err, expected=True)
134 embed_url = self._search_regex(r'embed_url:\s*["\'](.+?
)["\']', webpage, 'embed url')
135 thumbnail = self._og_search_thumbnail(webpage)
136 watch_info = get_element_by_id('watch-info', webpage) or ''
138 title = clean_html(get_element_by_class('video-title', watch_info))
139 season_episode = get_element_by_class(
140 'site-font-secondary-color', get_element_by_class('text', watch_info))
141 episode_number = int_or_none(self._search_regex(
142 r'Episode (\d+)', season_episode or '', 'episode', default=None))
145 '_type': 'url_transparent',
146 'ie_key': VHXEmbedIE.ie_key(),
147 'url': VHXEmbedIE._smuggle_referrer(embed_url, 'https://www.dropout.tv'),
148 'id': self._search_regex(r'embed\.vhx\.tv/videos/(.+?)\?', embed_url, 'id'),
149 'display_id': display_id,
151 'description': self._html_search_meta('description', webpage, fatal=False),
152 'thumbnail': thumbnail.split('?')[0] if thumbnail else None, # Ignore crop/downscale
153 'series': clean_html(get_element_by_class('series-title', watch_info)),
154 'episode_number': episode_number,
155 'episode': title if episode_number else None,
156 'season_number': int_or_none(self._search_regex(
157 r'Season (\d+),', season_episode or '', 'season', default=None)),
158 'release_date': unified_strdate(self._search_regex(
159 r'data-meta-field-name=["\']release_dates
["\'] data-meta-field-value=["\'](.+?
)["\']',
160 watch_info, 'release date', default=None)),
164 class DropoutSeasonIE(InfoExtractor):
165 _VALID_URL = r'https?://(?:www\.)?dropout\.tv/(?P<id>[^\/$&?#]+)(?:/?$|/season:[0-9]+/?$)'
168 'url': 'https://www.dropout.tv/dimension-20-fantasy-high/season:1',
169 'note': 'Multi-season series with the season in the url',
170 'playlist_count': 17,
172 'id': 'dimension-20-fantasy-high-season-1',
173 'title': 'Dimension 20 Fantasy High - Season 1'
177 'url': 'https://www.dropout.tv/dimension-20-fantasy-high',
178 'note': 'Multi-season series with the season not in the url',
179 'playlist_count': 17,
181 'id': 'dimension-20-fantasy-high-season-1',
182 'title': 'Dimension 20 Fantasy High - Season 1'
186 'url': 'https://www.dropout.tv/dimension-20-shriek-week',
187 'note': 'Single-season series',
190 'id': 'dimension-20-shriek-week-season-1',
191 'title': 'Dimension 20 Shriek Week - Season 1'
196 def _real_extract(self, url):
197 season_id = self._match_id(url)
198 season_title = season_id.replace('-', ' ').title()
199 webpage = self._download_webpage(url, season_id)
203 url=self._search_regex(r'<a href=["\'](.+?
)["\'] class=["\']browse
-item
-link
["\']',
205 ie=DropoutIE.ie_key()
206 ) for item in get_elements_by_class('js-collection-item', webpage)
209 seasons = (get_element_by_class('select-dropdown-wrapper', webpage) or '').strip().replace('\n', '')
210 current_season = self._search_regex(r'<option[^>]+selected>([^<]+)</option>',
211 seasons, 'current_season', default='').strip()
215 'id': join_nonempty(season_id, current_season.lower().replace(' ', '-')),
216 'title': join_nonempty(season_title, current_season, delim=' - '),