From d0215aa23882d0d8c63cfaf856f6e8e7b73d4b1b Mon Sep 17 00:00:00 2001 From: David Zhuang Date: Mon, 1 Aug 2016 05:39:38 -0400 Subject: [PATCH] [Bigthink]Add Bigthink --- src/you_get/common.py | 1 + src/you_get/extractors/__init__.py | 1 + src/you_get/extractors/bigthink.py | 76 ++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) mode change 100644 => 100755 src/you_get/extractors/__init__.py create mode 100644 src/you_get/extractors/bigthink.py diff --git a/src/you_get/common.py b/src/you_get/common.py index a9b12b08..3cbee373 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -8,6 +8,7 @@ SITES = { 'baidu' : 'baidu', 'bandcamp' : 'bandcamp', 'baomihua' : 'baomihua', + 'bigthink' : 'bigthink', 'bilibili' : 'bilibili', 'cctv' : 'cntv', 'cntv' : 'cntv', diff --git a/src/you_get/extractors/__init__.py b/src/you_get/extractors/__init__.py old mode 100644 new mode 100755 index 2f148aca..97ab0b41 --- a/src/you_get/extractors/__init__.py +++ b/src/you_get/extractors/__init__.py @@ -5,6 +5,7 @@ from .alive import * from .archive import * from .baidu import * from .bandcamp import * +from .bigthink import * from .bilibili import * from .cbs import * from .ckplayer import * diff --git a/src/you_get/extractors/bigthink.py b/src/you_get/extractors/bigthink.py new file mode 100644 index 00000000..1dd196d5 --- /dev/null +++ b/src/you_get/extractors/bigthink.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python + +from ..common import * +from ..extractor import VideoExtractor + +import json + +class Bigthink(VideoExtractor): + name = "Bigthink" + + stream_types = [ #this is just a sample. Will make it in prepare() + # {'id': '1080'}, + # {'id': '720'}, + # {'id': '360'}, + # {'id': '288'}, + # {'id': '190'}, + # {'id': '180'}, + + ] + + @staticmethod + def get_streams_by_id(account_number, video_id): + """ + int, int->list + + Get the height of the videos. + + Since brightcove is using 3 kinds of links: rtmp, http and https, + we will be using the HTTPS one to make it secure. + + If somehow akamaihd.net is blocked by the Great Fucking Wall, + change the "startswith https" to http. + """ + endpoint = 'https://edge.api.brightcove.com/playback/v1/accounts/{account_number}/videos/{video_id}'.format(account_number = account_number, video_id = video_id) + fake_header_id = fake_headers + #is this somehow related to the time? Magic.... + fake_header_id['Accept'] ='application/json;pk=BCpkADawqM1cc6wmJQC2tvoXZt4mrB7bFfi6zGt9QnOzprPZcGLE9OMGJwspQwKfuFYuCjAAJ53JdjI8zGFx1ll4rxhYJ255AXH1BQ10rnm34weknpfG-sippyQ' + + html = get_content(endpoint, headers= fake_header_id) + html_json = json.loads(html) + + link_list = [] + + for i in html_json['sources']: + if 'src' in i: #to avoid KeyError + if i['src'].startswith('https'): + link_list.append((str(i['height']), i['src'])) + + return link_list + + def prepare(self, **kwargs): + + html = get_content(self.url) + + self.title = match1(html, r'