2014-09-28 01:28:01 +08:00
# coding: utf-8
from __future__ import unicode_literals
from . common import InfoExtractor
from . . utils import (
2014-11-05 06:14:16 +08:00
determine_ext ,
2014-10-27 08:33:49 +08:00
int_or_none ,
2014-09-28 01:28:01 +08:00
parse_iso8601 ,
)
class HeiseIE ( InfoExtractor ) :
2014-09-28 16:40:49 +08:00
_VALID_URL = r ''' (?x)
https ? : / / ( ? : www \. ) ? heise \. de / video / artikel /
. + ? ( ? P < id > [ 0 - 9 ] + ) \. html ( ? : $ | [ ? #])
'''
2014-09-28 01:28:01 +08:00
_TEST = {
' url ' : (
2014-09-28 16:40:49 +08:00
' http://www.heise.de/video/artikel/Podcast-c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2404147.html '
2014-09-28 01:28:01 +08:00
) ,
' md5 ' : ' ffed432483e922e88545ad9f2f15d30e ' ,
' info_dict ' : {
' id ' : ' 2404147 ' ,
' ext ' : ' mp4 ' ,
' title ' : (
2014-09-28 16:40:49 +08:00
" Podcast: c ' t uplink 3.3 – Owncloud / Tastaturen / Peilsender Smartphone "
2014-09-28 01:28:01 +08:00
) ,
2014-11-05 06:14:16 +08:00
' format_id ' : ' mp4_720p ' ,
2014-09-28 01:28:01 +08:00
' timestamp ' : 1411812600 ,
' upload_date ' : ' 20140927 ' ,
2014-09-28 16:49:12 +08:00
' description ' : ' In uplink-Episode 3.3 geht es darum, wie man sich von Cloud-Anbietern emanzipieren kann, worauf man beim Kauf einer Tastatur achten sollte und was Smartphones über uns verraten. ' ,
2014-11-05 06:14:16 +08:00
' thumbnail ' : ' re:^https?://.* \ .jpe?g$ ' ,
2014-09-28 01:28:01 +08:00
}
}
def _real_extract ( self , url ) :
2014-09-28 16:40:49 +08:00
video_id = self . _match_id ( url )
webpage = self . _download_webpage ( url , video_id )
2014-10-27 08:33:49 +08:00
container_id = self . _search_regex (
r ' <div class= " videoplayerjw " .*?data-container= " ([0-9]+) " ' ,
webpage , ' container ID ' )
sequenz_id = self . _search_regex (
r ' <div class= " videoplayerjw " .*?data-sequenz= " ([0-9]+) " ' ,
webpage , ' sequenz ID ' )
data_url = ' http://www.heise.de/videout/feed?container= %s &sequenz= %s ' % ( container_id , sequenz_id )
doc = self . _download_xml ( data_url , video_id )
2014-09-28 01:28:01 +08:00
info = {
2014-09-28 16:40:49 +08:00
' id ' : video_id ,
2014-10-27 08:33:49 +08:00
' thumbnail ' : self . _og_search_thumbnail ( webpage ) ,
2014-11-05 06:14:16 +08:00
' timestamp ' : parse_iso8601 (
self . _html_search_meta ( ' date ' , webpage ) ) ,
2014-09-28 16:49:12 +08:00
' description ' : self . _og_search_description ( webpage ) ,
2014-09-28 01:28:01 +08:00
}
2014-11-05 06:14:16 +08:00
title = self . _html_search_meta ( ' fulltitle ' , webpage )
2014-09-28 01:28:01 +08:00
if title :
info [ ' title ' ] = title
else :
2014-09-28 16:40:49 +08:00
info [ ' title ' ] = self . _og_search_title ( webpage )
2014-09-28 01:28:01 +08:00
formats = [ ]
2014-10-27 08:33:49 +08:00
for source_node in doc . findall ( ' .// { http://rss.jwpcdn.com/}source ' ) :
label = source_node . attrib [ ' label ' ]
height = int_or_none ( self . _search_regex (
r ' ^(.*?_)?([0-9]+)p$ ' , label , ' height ' , default = None ) )
2014-11-05 06:14:16 +08:00
video_url = source_node . attrib [ ' file ' ]
ext = determine_ext ( video_url , ' ' )
2014-10-27 08:33:49 +08:00
formats . append ( {
2014-11-05 06:14:16 +08:00
' url ' : video_url ,
2014-10-27 08:33:49 +08:00
' format_note ' : label ,
2014-11-05 06:14:16 +08:00
' format_id ' : ' %s _ %s ' % ( ext , label ) ,
2014-10-27 08:33:49 +08:00
' height ' : height ,
} )
2014-09-28 01:28:01 +08:00
self . _sort_formats ( formats )
info [ ' formats ' ] = formats
return info