Break everything to make them happy

This commit is contained in:
Dan Salmon 2016-12-20 23:11:27 -06:00
parent c8223f22fe
commit dd6a8301c8

View File

@ -3,18 +3,51 @@ from __future__ import unicode_literals
from .common import InfoExtractor from .common import InfoExtractor
import os.path import os.path
from .theplatform import ThePlatformFeedIE
# from .theplatform import ThePlatformBaseIE
from ..utils import ( from ..utils import (
sanitized_Request, sanitized_Request,
urlencode_postdata urlencode_postdata,
int_or_none
) )
class SeesoIE(InfoExtractor): class SeesoBaseIE(ThePlatformFeedIE):
def _extract_video_info(self, video_id, auth_token):
# print "extract_video_info - auth_token: ", auth_token
# _VIDEO_INFO_URL = 'https://feed.theplatform.com/f/NZILfC/nbcott-prod-all-media?byAvailabilityState=' \
# 'available&byId=%s&form=cjson'
# return self._extract_feed_info(
# 'NZILfC', 'nbcott-prod-all-media', ('byAvailabilityState=available&byId=%s' % video_id), lambda entry: {
# 'series': entry.get('nbc-chaos$show'),
# 'season_number': int_or_none(entry.get('nbc-chaos$seasonNumber')),
# 'episode': entry.get('nbc-chaos$shortTitle'),
# 'episode_number': int_or_none(entry.get('nbc-chaos$episodeNumber')),
# }, {
# 'StreamPack': {
# 'manifest': 'm3u',
# }
# })
return self._extract_feed_info(
'NZILfC', 'nbcott-prod-all-media', 'byId=' + video_id, lambda entry: {
'series': entry.get('nbc-chaos$show'),
'season_number': int_or_none(entry.get('nbc-chaos$shortTitle')),
'episode': entry.get('nbc-chaos$shortTitle'),
'episode_number': int_or_none(entry.get('nbc-chaos$episodeNumber')),
}, {
'Video': {
'auth': auth_token,
}
})
class SeesoIE(SeesoBaseIE):
_VALID_URL = r'https?://(?:www\.)?seeso\.com/view/episode/(?P<id>[0-9]+)' _VALID_URL = r'https?://(?:www\.)?seeso\.com/view/episode/(?P<id>[0-9]+)'
_TEST = { _TESTS = [{
'params': { 'params': {
'username': 'emailhere', 'username': '',
'password': 'passhere' 'password': ''
}, },
'url': 'https://www.seeso.com/view/episode/799241283849', 'url': 'https://www.seeso.com/view/episode/799241283849',
'info_dict': { 'info_dict': {
@ -26,7 +59,7 @@ class SeesoIE(InfoExtractor):
"and rival brokers Serge and Gio intimidate Glenn."), "and rival brokers Serge and Gio intimidate Glenn."),
'thumbnail': 'https://chaosic.akamaized.net/NBCOTT_-_Production/360/907/160831_3092487_Farsi_Lessons.jpg', 'thumbnail': 'https://chaosic.akamaized.net/NBCOTT_-_Production/360/907/160831_3092487_Farsi_Lessons.jpg',
} }
} }]
def _login(self): def _login(self):
username, password = self._get_login_info() username, password = self._get_login_info()
@ -54,34 +87,48 @@ class SeesoIE(InfoExtractor):
video_id = self._match_id(url) video_id = self._match_id(url)
auth_token = self._login() auth_token = self._login()
return self._extract_video_info(video_id, auth_token)
# Use the public unauthenticated API to get the video's info # Use the public unauthenticated API to get the video's info
_VIDEO_INFO_URL = 'https://feed.theplatform.com/f/NZILfC/nbcott-prod-all-media?byAvailabilityState=' \ # _VIDEO_INFO_URL = 'https://feed.theplatform.com/f/NZILfC/nbcott-prod-all-media?byAvailabilityState=' \
'available&byId=%s&form=cjson' # 'available&byId=%s&form=cjson'
request = sanitized_Request(_VIDEO_INFO_URL % video_id) # request = sanitized_Request(_VIDEO_INFO_URL % video_id)
json_data = self._download_json(request, video_id) # json_data = self._download_json(request, video_id)
# tpf = ThePlatformFeedIE(ThePlatformBaseIE())
# ThePlatformFeedIE._extract_feed_info(tpf, 'NZILfC', 'VxxJg8Ymh8sE', ('byId=' + video_id), video_id)
entry = json_data.get('entries')[0]
# Template fields # entry = json_data.get('entries')[0]
series = entry.get("nbc-chaos$show") # Show name
title = entry.get("nbc-chaos$shortTitle") # Episode Name
season_number = entry.get("nbc-chaos$seasonNumber")
episode_number = entry.get("nbc-chaos$episodeNumber")
thumbnail = entry.get("defaultThumbnailUrl")
description = entry.get("nbc-chaos$shortDescription")
# Got the show's public URL. Now we need to parse out the videoID # # DEBUG
public_url_id = os.path.split(entry.get("publicUrl"))[-1] # entry = {}
#
# # Template fields
# title = entry.get("nbc-chaos$shortTitle")
# series = entry.get("nbc-chaos$show")
# season_number = entry.get("nbc-chaos$seasonNumber")
# episode_number = entry.get("nbc-chaos$episodeNumber")
# thumbnail = entry.get("defaultThumbnailUrl")
# description = entry.get("nbc-chaos$shortDescription")
#
# # Got the show's public URL. Now we need to parse out the videoID
# public_url_id = os.path.split(entry.get("publicUrl"))[-1]
# Get the master m3u8 which lists formats # Get the master m3u8 which lists formats
m3u8_url = 'https://link.theplatform.com/s/NZILfC/media/{0}?feed=All%20Media%20Feed&auth={1}' \ # m3u8_url = 'https://link.theplatform.com/s/NZILfC/media/{0}?feed=All%20Media%20Feed&auth={1}' \
'&vpaid=script,flash&formats=m3u,mpeg4'.format(public_url_id, auth_token) # '&vpaid=script,flash&formats=m3u,mpeg4'.format(public_url_id, auth_token)
formats = [] # formats = []
# pie = ThePlatformIE()
# # pie._real_extract(m3u8_url)
# formats = pie._real_extract(m3u8_url)
for entry in self._extract_m3u8_formats(m3u8_url, video_id, m3u8_id='m3u8', ext='mp4'): for entry in self._extract_m3u8_formats(m3u8_url, video_id, m3u8_id='m3u8', ext='mp4'):
formats.append(entry) formats.append(entry)
self._sort_formats(formats) self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,