3 from .common
import InfoExtractor
8 scale_thumbnails_to_max_format_width
,
12 class Ant1NewsGrBaseIE(InfoExtractor
):
13 def _download_and_extract_api_data(self
, video_id
, netloc
, cid
=None):
14 url
= f
'{self.http_scheme()}//{netloc}{self._API_PATH}'
15 info
= self
._download
_json
(url
, video_id
, query
={'cid': cid or video_id}
)
19 raise ExtractorError('no source found for %s' % video_id
)
20 formats
, subs
= (self
._extract
_m
3u8_formats
_and
_subtitles
(source
, video_id
, 'mp4')
21 if determine_ext(source
) == 'm3u8' else ([{'url': source}
], {}))
22 thumbnails
= scale_thumbnails_to_max_format_width(
23 formats
, [{'url': info['thumb']}
], r
'(?<=/imgHandler/)\d+')
26 'title': info
.get('title'),
27 'thumbnails': thumbnails
,
33 class Ant1NewsGrWatchIE(Ant1NewsGrBaseIE
):
34 IE_NAME
= 'ant1newsgr:watch'
35 IE_DESC
= 'ant1news.gr videos'
36 _VALID_URL
= r
'https?://(?P<netloc>(?:www\.)?ant1news\.gr)/watch/(?P<id>\d+)/'
37 _API_PATH
= '/templates/data/player'
40 'url': 'https://www.ant1news.gr/watch/1506168/ant1-news-09112021-stis-18-45',
41 'md5': '95925e6b32106754235f2417e0d2dfab',
45 'title': 'md5:0ad00fa66ecf8aa233d26ab0dba7514a',
46 'description': 'md5:18665af715a6dcfeac1d6153a44f16b0',
47 'thumbnail': 'https://ant1media.azureedge.net/imgHandler/640/26d46bf6-8158-4f02-b197-7096c714b2de.jpg',
51 def _real_extract(self
, url
):
52 video_id
, netloc
= self
._match
_valid
_url
(url
).group('id', 'netloc')
53 webpage
= self
._download
_webpage
(url
, video_id
)
54 info
= self
._download
_and
_extract
_api
_data
(video_id
, netloc
)
55 info
['description'] = self
._og
_search
_description
(webpage
)
59 class Ant1NewsGrArticleIE(Ant1NewsGrBaseIE
):
60 IE_NAME
= 'ant1newsgr:article'
61 IE_DESC
= 'ant1news.gr articles'
62 _VALID_URL
= r
'https?://(?:www\.)?ant1news\.gr/[^/]+/article/(?P<id>\d+)/'
65 'url': 'https://www.ant1news.gr/afieromata/article/549468/o-tzeims-mpont-sta-meteora-oi-apeiles-kai-o-xesikomos-ton-kalogeron',
66 'md5': '294f18331bb516539d72d85a82887dcc',
68 'id': '_xvg/m_cmbatw=',
70 'title': 'md5:a93e8ecf2e4073bfdffcb38f59945411',
71 'timestamp': 1603092840,
72 'upload_date': '20201019',
73 'thumbnail': 'https://ant1media.azureedge.net/imgHandler/640/756206d2-d640-40e2-b201-3555abdfc0db.jpg',
76 'url': 'https://ant1news.gr/Society/article/620286/symmoria-anilikon-dikigoros-thymaton-ithelan-na-toys-apoteleiosoyn',
79 'title': 'md5:91fe569e952e4d146485740ae927662b',
81 'playlist_mincount': 2,
83 'skip_download': True,
87 def _real_extract(self
, url
):
88 video_id
= self
._match
_id
(url
)
89 webpage
= self
._download
_webpage
(url
, video_id
)
90 info
= self
._search
_json
_ld
(webpage
, video_id
, expected_type
='NewsArticle')
91 embed_urls
= list(Ant1NewsGrEmbedIE
._extract
_embed
_urls
(url
, webpage
))
93 raise ExtractorError('no videos found for %s' % video_id
, expected
=True)
94 return self
.playlist_from_matches(
95 embed_urls
, video_id
, info
.get('title'), ie
=Ant1NewsGrEmbedIE
.ie_key(),
96 video_kwargs
={'url_transparent': True, 'timestamp': info.get('timestamp')}
)
99 class Ant1NewsGrEmbedIE(Ant1NewsGrBaseIE
):
100 IE_NAME
= 'ant1newsgr:embed'
101 IE_DESC
= 'ant1news.gr embedded videos'
102 _BASE_PLAYER_URL_RE
= r
'(?:https?:)?//(?:[a-zA-Z0-9\-]+\.)?(?:antenna|ant1news)\.gr/templates/pages/player'
103 _VALID_URL
= rf
'{_BASE_PLAYER_URL_RE}\?([^#]+&)?cid=(?P<id>[^#&]+)'
104 _EMBED_REGEX
= [rf
'<iframe[^>]+?src=(?P<_q1>["\'])(?P<url>{_BASE_PLAYER_URL_RE}\?(?:(?!(?P=_q1)).)+)(?P=_q1)']
105 _API_PATH
= '/news/templates/data/jsonPlayer'
108 'url': 'https://www.antenna.gr/templates/pages/player?cid=3f_li_c_az_jw_y_u=&w=670&h=377',
109 'md5': 'dfc58c3a11a5a9aad2ba316ed447def3',
111 'id': '3f_li_c_az_jw_y_u=',
113 'title': 'md5:a30c93332455f53e1e84ae0724f0adf7',
114 'thumbnail': 'https://ant1media.azureedge.net/imgHandler/640/bbe31201-3f09-4a4e-87f5-8ad2159fffe2.jpg',
118 def _real_extract(self
, url
):
119 video_id
= self
._match
_id
(url
)
121 canonical_url
= self
._request
_webpage
(
122 HEADRequest(url
), video_id
,
123 note
='Resolve canonical player URL',
124 errnote
='Could not resolve canonical player URL').geturl()
125 _
, netloc
, _
, _
, query
, _
= urllib
.parse
.urlparse(canonical_url
)
126 cid
= urllib
.parse
.parse_qs(query
)['cid'][0]
128 return self
._download
_and
_extract
_api
_data
(video_id
, netloc
, cid
=cid
)