2019-02-20 10:42:59 +01:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from .vimeo import VHXEmbedIE
|
|
|
|
|
2019-05-08 16:51:08 +02:00
|
|
|
from ..utils import ExtractorError
|
2019-02-20 10:42:59 +01:00
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
2020-03-01 17:48:42 +01:00
|
|
|
class DropoutIE(VHXEmbedIE):
|
|
|
|
IE_NAME = 'dropout'
|
|
|
|
IE_DESC = 'Dropout.tv'
|
|
|
|
_NETRC_MACHINE = 'dropouttv'
|
2020-01-29 13:13:02 +01:00
|
|
|
_LOGIN_URL = 'https://www.dropout.tv/login'
|
|
|
|
_LOGOUT_URL = 'https://www.dropout.tv/logout'
|
2020-03-01 18:28:06 +01:00
|
|
|
_VALID_URL = r'https://www\.dropout\.tv/(?:[^/]+/(?:season:[^/]/)?)?videos/(?P<id>.+)'
|
2019-02-22 18:15:02 +01:00
|
|
|
_TESTS = [
|
|
|
|
{
|
2020-03-01 17:48:42 +01:00
|
|
|
'url': 'https://www.dropout.tv/dimension-20-tiny-heist/season:1/videos/big-little-crimes',
|
|
|
|
'md5': '46edf4c6d632e2771a42a235f920b8f7',
|
2019-02-22 18:15:02 +01:00
|
|
|
'info_dict': {
|
2020-03-01 17:48:42 +01:00
|
|
|
'id': '382486557',
|
2019-02-22 18:15:02 +01:00
|
|
|
'ext': 'mp4',
|
2020-03-01 17:48:42 +01:00
|
|
|
'uploader': 'OTT Videos',
|
|
|
|
'uploader_id': 'user80538407',
|
|
|
|
'title': "Untitled",
|
|
|
|
'thumbnail': r're:^https://i.vimeocdn.com/.*\.jpg$',
|
2019-02-22 18:15:02 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2020-01-29 13:13:02 +01:00
|
|
|
'url': 'https://www.dropout.tv/videos/um-actually-behind-the-scenes',
|
2020-03-01 17:48:42 +01:00
|
|
|
'md5': '7fd342c652a86b996bae2920695593af',
|
2019-02-22 18:15:02 +01:00
|
|
|
'info_dict': {
|
2020-03-01 17:48:42 +01:00
|
|
|
'id': '265656116',
|
2019-02-22 18:15:02 +01:00
|
|
|
'ext': 'mp4',
|
2020-03-01 17:48:42 +01:00
|
|
|
'uploader': 'OTT Videos',
|
|
|
|
'uploader_id': 'user80538407',
|
2019-02-22 18:15:02 +01:00
|
|
|
'title': 'Um, Actually: Behind the Scenes',
|
2020-03-01 17:48:42 +01:00
|
|
|
'thumbnail': r're:^https://i.vimeocdn.com/.*\.jpg$',
|
2019-02-22 18:15:02 +01:00
|
|
|
}
|
2019-02-20 10:42:59 +01:00
|
|
|
}
|
2019-02-22 18:15:02 +01:00
|
|
|
]
|
2019-02-20 10:42:59 +01:00
|
|
|
|
|
|
|
def _real_initialize(self):
|
|
|
|
self._login()
|
|
|
|
|
|
|
|
def _login(self):
|
|
|
|
email, password = self._get_login_info()
|
2019-04-26 19:19:22 +02:00
|
|
|
if (email is None or password is None) and self._downloader.params.get('cookiefile') is None:
|
2019-02-20 10:42:59 +01:00
|
|
|
raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
|
2019-05-08 16:51:08 +02:00
|
|
|
self._vhx_login(email, password, self._LOGIN_URL)
|
2019-02-20 18:58:00 +01:00
|
|
|
|
2019-02-20 10:42:59 +01:00
|
|
|
def _real_extract(self, url):
|
2019-02-24 18:12:08 +01:00
|
|
|
webpage = self._download_webpage(url, None)
|
2019-04-25 10:48:39 +02:00
|
|
|
if "The device limit for your account has been reached" in webpage:
|
|
|
|
raise ExtractorError('Device Limit reached', expected=True)
|
2019-04-26 19:19:22 +02:00
|
|
|
if "Start your free trial" in webpage or "Start Free Trial" in webpage or "Sign in" in webpage:
|
|
|
|
raise ExtractorError('You don\'t seem to be logged in', expected=True)
|
|
|
|
|
2019-02-22 18:15:02 +01:00
|
|
|
video = self._html_search_regex(r'<iframe[^>]*"(?P<embed>https://embed.vhx.tv/videos/[0-9]+[^"]*)"[^>]*>', webpage, 'embed')
|
2019-02-21 18:22:42 +01:00
|
|
|
video_id = self._search_regex(r'https://embed.vhx.tv/videos/(?P<id>[0-9]+)', video, 'id')
|
2019-10-11 17:28:32 +02:00
|
|
|
video_title = self._html_search_regex(r'<h1 class="[^"]*video-title[^"]*"[^>]*>\s*<strong>(?P<title>[^<]+)<', webpage, 'title', fatal=False)
|
2019-02-21 18:22:42 +01:00
|
|
|
return self.url_result(video, video_id=video_id, video_title=video_title)
|
2019-02-22 18:15:02 +01:00
|
|
|
|
|
|
|
|
2020-03-01 17:48:42 +01:00
|
|
|
class DropoutPlaylistIE(DropoutIE):
|
|
|
|
IE_NAME = 'dropout:playlist'
|
2020-01-29 13:13:02 +01:00
|
|
|
_VALID_URL = r'https://www\.dropout\.tv/(?P<id>.+)'
|
2019-02-22 18:15:02 +01:00
|
|
|
_TESTS = [
|
|
|
|
{
|
2020-01-29 13:13:02 +01:00
|
|
|
'url': 'https://www.dropout.tv/um-actually',
|
2019-02-22 18:15:02 +01:00
|
|
|
'md5': 'ebcd26ef54f546225e7cb96e79da31cc',
|
2020-03-01 17:48:42 +01:00
|
|
|
'playlist_count': 33,
|
2019-02-22 18:15:02 +01:00
|
|
|
'info_dict': {
|
2019-05-08 17:14:35 +02:00
|
|
|
'id': 'um-actually',
|
|
|
|
'title': 'Um, Actually',
|
2019-02-22 18:15:02 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2020-01-29 13:13:02 +01:00
|
|
|
'url': 'https://www.dropout.tv/new-releases',
|
2019-02-22 18:15:02 +01:00
|
|
|
'md5': 'ebcd26ef54f546225e7cb96e79da31cc',
|
2020-03-01 17:48:42 +01:00
|
|
|
'playlist_count': 15,
|
2019-02-22 18:15:02 +01:00
|
|
|
'info_dict': {
|
|
|
|
'id': 'new-releases',
|
|
|
|
'title': 'New Releases',
|
|
|
|
}
|
2019-02-24 18:58:03 +01:00
|
|
|
},
|
|
|
|
{
|
2020-01-29 13:13:02 +01:00
|
|
|
'url': 'https://www.dropout.tv/troopers-the-web-series/season:2',
|
2019-02-24 18:58:03 +01:00
|
|
|
'md5': 'ebcd26ef54f546225e7cb96e79da31cc',
|
|
|
|
'playlist_count': 10,
|
|
|
|
'info_dict': {
|
2019-05-08 17:14:35 +02:00
|
|
|
'id': 'troopers-the-web-series/season:2',
|
|
|
|
'title': 'Troopers: The Web Series',
|
2019-02-24 18:58:03 +01:00
|
|
|
}
|
2019-02-22 18:15:02 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2019-02-24 18:58:03 +01:00
|
|
|
@classmethod
|
|
|
|
def suitable(cls, url):
|
2020-03-01 17:48:42 +01:00
|
|
|
return False if DropoutIE.suitable(url) else super(DropoutPlaylistIE, cls).suitable(url)
|
2019-02-24 18:58:03 +01:00
|
|
|
|
2019-02-22 18:15:02 +01:00
|
|
|
def _real_extract(self, url):
|
2019-03-18 09:49:59 +01:00
|
|
|
playlist_id = self._match_id(url)
|
2019-02-24 18:12:08 +01:00
|
|
|
webpage = self._download_webpage(url, playlist_id)
|
2019-05-08 17:14:35 +02:00
|
|
|
playlist_title = self._html_search_regex(r'<h1 class="[^"]*collection-title[^"]*"[^>]*>(?P<title>[^<]+)<', webpage, 'title')
|
|
|
|
|
|
|
|
items = []
|
|
|
|
while True:
|
2020-01-29 13:13:02 +01:00
|
|
|
items.extend(re.findall(r'browse-item-title[^>]+>[^<]*<a href="(?P<url>https://www.dropout.tv/[^/]+/[^"]+)"', webpage))
|
2020-03-01 17:49:09 +01:00
|
|
|
next_page_url = self._search_regex(r'href="([^"]+\?[^"]*(?:&|&)?page=\d+)"', webpage, 'next page url', default=None)
|
2019-05-08 17:14:35 +02:00
|
|
|
if not next_page_url:
|
|
|
|
break
|
2020-01-29 13:13:02 +01:00
|
|
|
webpage = self._download_webpage('https://www.dropout.tv' + next_page_url, playlist_id)
|
2019-05-08 17:14:35 +02:00
|
|
|
|
2019-02-22 18:15:02 +01:00
|
|
|
return self.playlist_from_matches(items, playlist_id=playlist_id, playlist_title=playlist_title)
|