1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-23 17:04:33 +01:00
youtube-dl/youtube_dl/extractor/intldropout.py
tsia 453750d3fb
quickfix to support www.dropout.tv
intl.dropout.tv has been discontinued
2020-01-29 13:13:02 +01:00

120 lines
5.0 KiB
Python

# coding: utf-8
from __future__ import unicode_literals
from .vimeo import VHXEmbedIE
from ..utils import ExtractorError
import re
class IntlDropoutIE(VHXEmbedIE):
IE_NAME = 'intldropout'
IE_DESC = 'International Dropout.tv'
_NETRC_MACHINE = 'intldropouttv'
_LOGIN_URL = 'https://www.dropout.tv/login'
_LOGOUT_URL = 'https://www.dropout.tv/logout'
_VALID_URL = r'https://www\.dropout\.tv/(?:[^/]+/season:[^/]+/)?videos/(?P<id>.+)'
_TESTS = [
{
'url': 'https://www.dropout.tv/um-actually/season:1/videos/c-3po-s-origins-hp-lovecraft-the-food-album-with-weird-al-yankovic',
'md5': '8beaac579b6ba762f63cd452fd28dcce',
'info_dict': {
'id': '397785',
'ext': 'mp4',
'title': "C-3PO's Origins, HP Lovecraft, the Food Album (with Weird Al Yankovic)",
'thumbnail': r're:^https://vhx.imgix.net/.*\.jpg$',
'description': 'Caldwell Tanner, Siobhan Thompson, and Nate Dern inspect guns and review the Diagon Alley bar scene.',
'upload_date': '20181206',
'timestamp': 1544117975,
}
},
{
'url': 'https://www.dropout.tv/videos/um-actually-behind-the-scenes',
'md5': 'b974927cd563423fe50945dbfdbb894c',
'info_dict': {
'id': '397943',
'ext': 'mp4',
'title': 'Um, Actually: Behind the Scenes',
'thumbnail': r're:^https://vhx.imgix.net/.*\.jpg$',
'description': 'What does it take to stump the nerdy? Mike Trapp and team pull back the curtain.',
'upload_date': '20181206',
'timestamp': 1544118409,
}
}
]
def _real_initialize(self):
self._login()
def _login(self):
email, password = self._get_login_info()
if (email is None or password is None) and self._downloader.params.get('cookiefile') is None:
raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
self._vhx_login(email, password, self._LOGIN_URL)
def _real_extract(self, url):
webpage = self._download_webpage(url, None)
if "The device limit for your account has been reached" in webpage:
raise ExtractorError('Device Limit reached', expected=True)
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)
video = self._html_search_regex(r'<iframe[^>]*"(?P<embed>https://embed.vhx.tv/videos/[0-9]+[^"]*)"[^>]*>', webpage, 'embed')
video_id = self._search_regex(r'https://embed.vhx.tv/videos/(?P<id>[0-9]+)', video, 'id')
video_title = self._html_search_regex(r'<h1 class="[^"]*video-title[^"]*"[^>]*>\s*<strong>(?P<title>[^<]+)<', webpage, 'title', fatal=False)
return self.url_result(video, video_id=video_id, video_title=video_title)
class IntlDropoutPlaylistIE(IntlDropoutIE):
IE_NAME = 'intldropout:playlist'
_VALID_URL = r'https://www\.dropout\.tv/(?P<id>.+)'
_TESTS = [
{
'url': 'https://www.dropout.tv/um-actually',
'md5': 'ebcd26ef54f546225e7cb96e79da31cc',
'playlist_count': 30,
'info_dict': {
'id': 'um-actually',
'title': 'Um, Actually',
}
},
{
'url': 'https://www.dropout.tv/new-releases',
'md5': 'ebcd26ef54f546225e7cb96e79da31cc',
'playlist_count': 31,
'info_dict': {
'id': 'new-releases',
'title': 'New Releases',
}
},
{
'url': 'https://www.dropout.tv/troopers-the-web-series/season:2',
'md5': 'ebcd26ef54f546225e7cb96e79da31cc',
'playlist_count': 10,
'info_dict': {
'id': 'troopers-the-web-series/season:2',
'title': 'Troopers: The Web Series',
}
}
]
@classmethod
def suitable(cls, url):
return False if IntlDropoutIE.suitable(url) else super(IntlDropoutPlaylistIE, cls).suitable(url)
def _real_extract(self, url):
playlist_id = self._match_id(url)
webpage = self._download_webpage(url, playlist_id)
playlist_title = self._html_search_regex(r'<h1 class="[^"]*collection-title[^"]*"[^>]*>(?P<title>[^<]+)<', webpage, 'title')
items = []
while True:
items.extend(re.findall(r'browse-item-title[^>]+>[^<]*<a href="(?P<url>https://www.dropout.tv/[^/]+/[^"]+)"', webpage))
next_page_url = self._search_regex(r'href="(/[^\?]+\?page=\d+)"', webpage, 'next page url', default=None)
if not next_page_url:
break
webpage = self._download_webpage('https://www.dropout.tv' + next_page_url, playlist_id)
return self.playlist_from_matches(items, playlist_id=playlist_id, playlist_title=playlist_title)