1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-24 01:14:32 +01:00

finished dropout extractor

This commit is contained in:
Thomas Tsiakalakis 2019-02-20 18:58:00 +01:00
parent f749ac67ab
commit 7781e2710d

View File

@ -1,14 +1,13 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
from .common import InfoExtractor
from .vimeo import VHXEmbedIE from .vimeo import VHXEmbedIE
from ..utils import ( from ..utils import (
ExtractorError, ExtractorError,
sanitized_Request, sanitized_Request,
urlencode_postdata urlencode_postdata,
RegexNotFoundError
) )
import re import re
@ -31,9 +30,10 @@ import re
class IntlDropoutIE(VHXEmbedIE): class IntlDropoutIE(VHXEmbedIE):
IE_DESC = 'International Dropout.tv'
_LOGIN_URL = 'https://intl.dropout.tv/login' _LOGIN_URL = 'https://intl.dropout.tv/login'
_LOGOUT_URL = 'https://intl.dropout.tv/logout' _LOGOUT_URL = 'https://intl.dropout.tv/logout'
_VALID_URL = r'https://intl\.dropout\.tv/(?P<id>[^/]+/.+)' _VALID_URL = r'https://intl\.dropout\.tv/(?P<id>.+)'
_TEST = { _TEST = {
'url': 'https://intl.dropout.tv/um-actually/season:1/videos/c-3po-s-origins-hp-lovecraft-the-food-album-with-weird-al-yankovic', 'url': 'https://intl.dropout.tv/um-actually/season:1/videos/c-3po-s-origins-hp-lovecraft-the-food-album-with-weird-al-yankovic',
'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', 'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)',
@ -59,16 +59,16 @@ class IntlDropoutIE(VHXEmbedIE):
if self._downloader.params.get('cookiefile') is None: if self._downloader.params.get('cookiefile') is None:
raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True) raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
return True return True
login_page = self._download_webpage( login_page = self._download_webpage(
self._LOGIN_URL, None, self._LOGIN_URL, None,
note='Downloading login page', note='Downloading login page',
errnote='unable to fetch login page', fatal=False errnote='unable to fetch login page', fatal=False
) )
if login_page is False: if login_page is False:
return return
login_form = self._hidden_inputs(login_page) login_form = self._hidden_inputs(login_page)
login_form.update({ login_form.update({
@ -76,7 +76,7 @@ class IntlDropoutIE(VHXEmbedIE):
'email': email, 'email': email,
'password': password 'password': password
}) })
request = sanitized_Request( request = sanitized_Request(
self._LOGIN_URL, urlencode_postdata(login_form)) self._LOGIN_URL, urlencode_postdata(login_form))
request.add_header('Content-Type', 'application/x-www-form-urlencoded') request.add_header('Content-Type', 'application/x-www-form-urlencoded')
@ -84,18 +84,15 @@ class IntlDropoutIE(VHXEmbedIE):
self._download_webpage(request, None, 'Logging in') self._download_webpage(request, None, 'Logging in')
except Exception: except Exception:
print('error') print('error')
def _real_extract(self, url): def _real_extract(self, url):
webpage = self._download_webpage(url, None) webpage = self._download_webpage(url, None)
embed = self._html_search_regex(r'<iframe[^>]+"(?P<embed>https://embed.vhx.tv/videos/[0-9]+[^"]*)"[^>]*>', webpage, 'embed') try:
video = self._html_search_regex(r'<iframe[^>]+"(?P<embed>https://embed.vhx.tv/videos/[0-9]+[^"]*)"[^>]*>', webpage, 'embed')
print(embed) except RegexNotFoundError:
items = re.findall(r'<a href="(?P<url>https://intl.dropout.tv/videos/[^"]+)"', webpage)
self._download_webpage( playlist_id = self._search_regex(r'https://intl.dropout.tv/(?P<id>.+)', url, 'id')
self._LOGOUT_URL, None, playlist_title = self._html_search_regex(r'<h1 class="[^"]*collection-title[^"]*"[^>]*>(?P<title>[^<]+)<', webpage, 'title')
note='logging out', return self.playlist_from_matches(items, playlist_id=playlist_id, playlist_title=playlist_title)
errnote='unable to logout', fatal=False
)
return self.url_result(embed)
return self.url_result(video)