Beispiel #1
0
    def __init__(self,
                 content=None,
                 base_path=None,
                 base_uri=None,
                 strict=False,
                 custom_tags_parser=None):
        if content is not None:
            self.data = parse(content, strict, custom_tags_parser)
        else:
            self.data = {}
        self._base_uri = base_uri
        if self._base_uri:
            if not self._base_uri.endswith('/'):
                self._base_uri += '/'

        # define the interface
        self.is_variant = INITIAL
        self.is_endlist = INITIAL
        self.is_i_frames_only = INITIAL
        self.target_duration = INITIAL
        self.media_sequence = INITIAL
        self.program_date_time = INITIAL
        self.is_independent_segments = INITIAL
        self.version = INITIAL
        self.allow_cache = INITIAL
        self.playlist_type = INITIAL
        self.discontinuity_sequence = INITIAL

        self._initialize_attributes()
        self.base_path = base_path
Beispiel #2
0
 def __init__(self, content=None, base_path=None, base_uri=None):
     if content is not None:
         self.data = parser.parse(content)
     else:
         self.data = {}
     self._base_uri = base_uri
     self._initialize_attributes()
     self.base_path = base_path
Beispiel #3
0
    def __init__(self, content=None, base_path=None, base_uri=None, strict=False, custom_tags_parser=None):
        if content is not None:
            self.data = parse(content, strict, custom_tags_parser)
        else:
            self.data = {}
        self._base_uri = base_uri
        if self._base_uri:
            if not self._base_uri.endswith('/'):
                self._base_uri += '/'

        self._initialize_attributes()
        self.base_path = base_path
Beispiel #4
0
    def __init__(self, content=None, base_path=None, base_uri=None, strict=False):
        if content is not None:
            self.data = parser.parse(content, strict)
        else:
            self.data = {}
        self._base_uri = base_uri
        if self._base_uri:
            if not self._base_uri.endswith('/'):
                self._base_uri += '/'

        self._initialize_attributes()
        self.base_path = base_path
Beispiel #5
0
    def __init__(self,
                 content=None,
                 base_path=None,
                 base_uri=None,
                 strict=False):
        if content is not None:
            self.data = parser.parse(content, strict)
        else:
            self.data = {}
        self._base_uri = base_uri
        if self._base_uri:
            if not self._base_uri.endswith('/'):
                self._base_uri += '/'

        self._initialize_attributes()
        self.base_path = base_path
        self._output_absolute_uris = False
 config.read('config.cfg')
 userAgent = config.get('http', 'user_agent')
 referer = config.get('http', 'referer')
 with open('data.json') as f:
     dataConfig = json.load(f)
 headers = {}
 headers['User-Agent'] = userAgent
 headers['Referer'] = referer
 for item in dataConfig['urls']:
     url = item['url']
     output = item['output']
     fp = open(output, 'wb')
     prefix = '/'.join(url.split('/')[0:-1]) + '/'
     r = requests.get(url, headers=headers)
     r.encode = 'utf-8'
     playList = parser.parse(r.text)
     i = 0
     count = len(playList['segments'])
     print 'starting...'
     print 'total segments:%d' % (count)
     for item in playList['segments']:
         print 'downloading segments %d' % (i)
         i += 1
         url = prefix + item['uri']
         r = requests.get(url, headers=headers)
         data = r.content
         keyUrl = item['key']['uri']
         k = requests.get(keyUrl, headers=headers)
         key = k.content
         cryptor = AES.new(key, AES.MODE_CBC, key)
         data = cryptor.decrypt(data)