From 14309551921d475442997b15f5be65614784764a Mon Sep 17 00:00:00 2001 From: wernerkarlheisenberg Date: Wed, 24 Jan 2018 21:26:03 +0100 Subject: [PATCH] cognito and vier coding guidelines update --- youtube_dl/extractor/cognito.py | 17 ++++++++--------- youtube_dl/extractor/vier.py | 19 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/youtube_dl/extractor/cognito.py b/youtube_dl/extractor/cognito.py index 70cca2c7c..ab0075659 100755 --- a/youtube_dl/extractor/cognito.py +++ b/youtube_dl/extractor/cognito.py @@ -1,14 +1,13 @@ from .common import InfoExtractor from ..utils import ExtractorError -class CognitoBaseIE(InfoExtractor): +class CognitoBaseIE(InfoExtractor): def _cognito_login(self, auth_data): try: import boto3 - from warrant import Cognito from warrant.aws_srp import AWSSRP except ImportError: raise ExtractorError('%s depends on boto3 and warrant.' % self.IE_NAME) @@ -16,15 +15,15 @@ class CognitoBaseIE(InfoExtractor): region = auth_data['PoolId'].split('_')[0] client = boto3.client( 'cognito-idp', - region_name = region, - aws_access_key_id = 'SomeNonsenseValue', - aws_secret_access_key = 'YetAnotherNonsenseValue' + region_name=region, + aws_access_key_id='SomeNonsenseValue', + aws_secret_access_key='YetAnotherNonsenseValue' ) aws = AWSSRP( - username = auth_data['Username'], - password = auth_data['Password'], - pool_id = auth_data['PoolId'], - client_id = auth_data['ClientId'], + username=auth_data['Username'], + password=auth_data['Password'], + pool_id=auth_data['PoolId'], + client_id=auth_data['ClientId'], client=client ) return aws.authenticate_user() diff --git a/youtube_dl/extractor/vier.py b/youtube_dl/extractor/vier.py index 1fe5cde5b..75bf2f1cb 100755 --- a/youtube_dl/extractor/vier.py +++ b/youtube_dl/extractor/vier.py @@ -13,6 +13,7 @@ from ..utils import ( from .cognito import CognitoBaseIE + class VierVijfKijkOnlineIE(CognitoBaseIE): IE_NAME = 'viervijfkijkonline' IE_DESC = 'vier.be and vijf.be - Kijk Online' @@ -24,7 +25,7 @@ class VierVijfKijkOnlineIE(CognitoBaseIE): 'ext': 'mp4', 'title': 'Hotel Römantiek - Seizoen 1 - Aflevering 1', 'series': 'Hotel Römantiek', - 'season_number' : 1, + 'season_number': 1, 'episode_number': 1, }, 'skip': 'This video is only available for registered users' @@ -39,7 +40,6 @@ class VierVijfKijkOnlineIE(CognitoBaseIE): _POOL_ID = 'eu-west-1_dViSsKM5Y' _CLIENT_ID = '6s1h851s8uplco5h6mqh1jac8m' - def _real_initialize(self): self._logged_in = False self.id_token = '' @@ -51,8 +51,8 @@ class VierVijfKijkOnlineIE(CognitoBaseIE): self.raise_login_required() auth_data = { - 'PoolId' : self._POOL_ID, - 'ClientId' : self._CLIENT_ID, + 'PoolId': self._POOL_ID, + 'ClientId': self._CLIENT_ID, 'Username': username, 'Password': password, } @@ -62,9 +62,6 @@ class VierVijfKijkOnlineIE(CognitoBaseIE): self._logged_in = True def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) - site = mobj.group('site') - if not self._logged_in: self._login() @@ -89,12 +86,12 @@ class VierVijfKijkOnlineIE(CognitoBaseIE): api_url = 'https://api.viervijfzes.be/content/%s' % (video_id) api_headers = { - 'authorization' : self.id_token, + 'authorization': self.id_token, } api = self._download_json( api_url, None, note='Peforming API Call', errnote='API Call Failed', - headers = api_headers, + headers=api_headers, ) formats = [] @@ -106,11 +103,12 @@ class VierVijfKijkOnlineIE(CognitoBaseIE): 'id': video_id, 'title': title, 'series': series, - 'season_number' : int_or_none(season), + 'season_number': int_or_none(season), 'episode_number': int_or_none(episode), 'formats': formats, } + class VierIE(InfoExtractor): IE_NAME = 'vier' IE_DESC = 'vier.be and vijf.be' @@ -295,6 +293,7 @@ class VierIE(InfoExtractor): 'formats': formats, } + class VierVideosIE(InfoExtractor): IE_NAME = 'vier:videos' _VALID_URL = r'https?://(?:www\.)?(?Pvier|vijf)\.be/(?P[^/]+)/videos(?:\?.*\bpage=(?P\d+)|$)'