]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/elonet.py
2 from __future__
import unicode_literals
6 from . common
import InfoExtractor
12 from .. compat
import compat_str
15 class ElonetIE ( InfoExtractor
):
16 _VALID_URL
= r
'https?://elonet\.finna\.fi/Record/kavi\.elonet_elokuva_(?P<id>[0-9]+)'
19 'url' : 'https://elonet.finna.fi/Record/kavi.elonet_elokuva_107867' ,
20 'md5' : '8efc954b96c543711707f87de757caea' ,
24 'title' : 'Valkoinen peura' ,
25 'description' : 'Valkoinen peura (1952) on Erik Blombergin ohjaama ja yhdessä Mirjami Kuosmasen kanssa käsikirjoittama tarunomainen kertomus valkoisen peuran hahmossa lii...' ,
26 'thumbnail' : 'https://elonet.finna.fi/Cover/Show?id=kavi.elonet_elokuva_107867&index=0&size=large' ,
30 'url' : 'https://elonet.finna.fi/Record/kavi.elonet_elokuva_116539' ,
34 'title' : 'Minulla on tiikeri' ,
35 'description' : 'Pienellä pojalla, joka asuu kerrostalossa, on kotieläimenä tiikeri. Se on kuitenkin salaisuus. Kerrostalon räpätäti on Kotilaisen täti, joka on aina vali...' ,
36 'thumbnail' : 'https://elonet.finna.fi/Cover/Show?id=kavi.elonet_elokuva_116539&index=0&size=large&source=Solr' ,
40 def _real_extract ( self
, url
):
41 video_id
= self
._ match
_ id
( url
)
42 webpage
= self
._ download
_ webpage
( url
, video_id
)
44 title
= self
._ html
_ search
_ regex
(
45 r
'<meta .*property="og:title" .*content="(.+?)"' , webpage
, 'title' )
46 description
= self
._ html
_ search
_ regex
(
47 r
'<meta .*property="og:description" .*content="(.+?)"' , webpage
, 'description' )
48 thumbnail
= self
._ html
_ search
_ regex
(
49 r
'<meta .*property="og:image" .*content="(.+?)"' , webpage
, 'thumbnail' )
51 json_s
= self
._ html
_ search
_ regex
(
52 r
'data-video-sources="(.+?)"' , webpage
, 'json' )
54 self
._ parse
_ json
( json_s
, video_id
),
55 lambda x
: x
[ 0 ][ "src" ], compat_str
)
58 if re
. search ( r
'\.m3u8\??' , src
):
59 res
= self
._ download
_ webpage
_ handle
(
60 # elonet servers have certificate problems
61 src
. replace ( 'https:' , 'http:' ), video_id
,
62 note
= 'Downloading m3u8 information' ,
63 errnote
= 'Failed to download m3u8 information' )
67 formats
, subtitles
= self
._ parse
_ m
3u8_ formats
_ and
_ subtitles
( doc
, url
)
70 elif re
. search ( r
'\.mpd\??' , src
):
71 res
= self
._ download
_ xml
_ handle
(
73 note
= 'Downloading MPD manifest' ,
74 errnote
= 'Failed to download MPD manifest' )
77 url
= base_url ( urlh
. geturl ())
78 formats
, subtitles
= self
._ parse
_ mpd
_ formats
_ and
_ subtitles
( doc
, mpd_base_url
= url
)
80 raise ExtractorError ( "Unknown streaming format" )
85 'description' : description
,
86 'thumbnail' : thumbnail
,
88 'subtitles' : subtitles
,