6
6
from .common import InfoExtractor
7
7
from ..utils import (
8
8
determine_ext ,
9
- js_to_json ,
9
+ int_or_none ,
10
+ url_or_none ,
10
11
)
11
12
12
13
13
14
class APAIE (InfoExtractor ):
14
- _VALID_URL = r'https?://[^/]+\.apa\.at/embed/(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
15
+ _VALID_URL = r'(?P<base_url> https?://[^/]+\.apa\.at) /embed/(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
15
16
_TESTS = [{
16
17
'url' : 'http://uvp.apa.at/embed/293f6d17-692a-44e3-9fd5-7b178f3a1029' ,
17
18
'md5' : '2b12292faeb0a7d930c778c7a5b4759b' ,
@@ -41,9 +42,11 @@ def _extract_urls(webpage):
41
42
webpage )]
42
43
43
44
def _real_extract (self , url ):
44
- video_id = self ._match_id (url )
45
+ mobj = re .match (self ._VALID_URL , url )
46
+ video_id , base_url = mobj .group ('id' , 'base_url' )
45
47
46
- webpage = self ._download_webpage ('https://uvp.apa.at/player/%s' % video_id , video_id )
48
+ webpage = self ._download_webpage (
49
+ '%s/player/%s' % (base_url , video_id ), video_id )
47
50
48
51
jwplatform_id = self ._search_regex (
49
52
r'media[iI]d\s*:\s*["\'](?P<id>[a-zA-Z0-9]{8})' , webpage ,
@@ -54,30 +57,39 @@ def _real_extract(self, url):
54
57
'jwplatform:' + jwplatform_id , ie = 'JWPlatform' ,
55
58
video_id = video_id )
56
59
57
- sources = self ._parse_json ("{" + self ._search_regex (
58
- r'("hls"\s*:\s*"[^"]+"\s*,\s*"progressive"\s*:\s*"[^"]+")' , webpage , 'sources' )
59
- + "}" , video_id , transform_source = js_to_json )
60
+ def extract (field , name = None ):
61
+ return self ._search_regex (
62
+ r'\b%s["\']\s*:\s*(["\'])(?P<value>(?:(?!\1).)+)\1' % field ,
63
+ webpage , name or field , default = None , group = 'value' )
64
+
65
+ title = extract ('title' ) or video_id
66
+ description = extract ('description' )
67
+ thumbnail = extract ('poster' , 'thumbnail' )
60
68
61
69
formats = []
62
- for (format , source_url ) in sources .items ():
70
+ for format_id in ('hls' , 'progressive' ):
71
+ source_url = url_or_none (extract (format_id ))
72
+ if not source_url :
73
+ continue
63
74
ext = determine_ext (source_url )
64
75
if ext == 'm3u8' :
65
76
formats .extend (self ._extract_m3u8_formats (
66
77
source_url , video_id , 'mp4' , entry_protocol = 'm3u8_native' ,
67
78
m3u8_id = 'hls' , fatal = False ))
68
79
else :
80
+ height = int_or_none (self ._search_regex (
81
+ r'(\d+)\.mp4' , source_url , 'height' , default = None ))
69
82
formats .append ({
70
83
'url' : source_url ,
84
+ 'format_id' : format_id ,
85
+ 'height' : height ,
71
86
})
72
87
self ._sort_formats (formats )
73
88
74
- thumbnail = self ._search_regex (
75
- r'"poster"\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1' , webpage ,
76
- 'thumbnail' , fatal = False , group = 'url' )
77
-
78
89
return {
79
90
'id' : video_id ,
80
- 'title' : video_id ,
91
+ 'title' : title ,
92
+ 'description' : description ,
81
93
'thumbnail' : thumbnail ,
82
94
'formats' : formats ,
83
95
}
0 commit comments