Compare commits

...

5 Commits

Author SHA1 Message Date
Amir Y. Perehodnik
5d135d8a06
Improve regex
Co-authored-by: garret <garret1317@yandex.com>
2023-10-19 15:46:40 +03:00
Amir Y. Perehodnik
b2d51158a2
Use relative imports
Co-authored-by: garret <garret1317@yandex.com>
2023-10-19 15:43:41 +03:00
Amir Y. Perehodnik
b35a981154
remove single-use variable
Co-authored-by: garret <garret1317@yandex.com>
2023-10-19 15:43:17 +03:00
Amir Y. Perehodnik
f1fbfc8199
remove single-use variable
Co-authored-by: garret <garret1317@yandex.com>
2023-10-19 15:42:51 +03:00
Amir Y. Perehodnik
e8e9a11ae5
Use inline styling when needed
Co-authored-by: garret <garret1317@yandex.com>
2023-10-19 15:41:08 +03:00

View File

@ -1,4 +1,4 @@
from yt_dlp.extractor.common import InfoExtractor from .common import InfoExtractor
import re import re
@ -17,8 +17,7 @@ class MaarivIE(InfoExtractor):
@staticmethod @staticmethod
def extract_resolution(url): def extract_resolution(url):
pattern = r'(\d{2,4}x\d{2,4})\.mp4$' match = re.search(r'(\d{2,4}x\d{2,4})\.mp4$', url)
match = re.search(pattern, url)
return match.group(1) if match else None return match.group(1) if match else None
def _real_extract(self, url): def _real_extract(self, url):
@ -26,13 +25,13 @@ class MaarivIE(InfoExtractor):
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
# Find the correct iframes # Find the correct iframes
video_urls = re.findall(r'<iframe .*?poster="(.*?)" src="(.*?)"', webpage) video_urls = re.findall(r'<iframe [^>]?poster="([^"]+)"[^>]+ src="([^"]+)"', webpage)
video_info_list = [] video_info_list = []
for thumbnail, src in video_urls: for thumbnail, src in video_urls:
media_param = re.search(r'media=(\d+)', src).group(1) media_param = re.search(r'media=(\d+)', src).group(1)
info_url = f"https://dal.walla.co.il/media/{media_param}?origin=player.maariv.co.il" info_json = self._download_json(f"https://dal.walla.co.il/media/{media_param}?origin=player.maariv.co.il",
info_json = self._download_json(info_url, video_id) video_id)
data = info_json['data'] data = info_json['data']
main_video_to_download_filename = data['video']['file_name'] main_video_to_download_filename = data['video']['file_name']
main_video_to_download_url = data['video']['url'] main_video_to_download_url = data['video']['url']
@ -48,13 +47,11 @@ class MaarivIE(InfoExtractor):
for format_id, stream_url_object in enumerate(data['video']['stream_urls'], start=1): for format_id, stream_url_object in enumerate(data['video']['stream_urls'], start=1):
stream_url = stream_url_object['stream_url'] stream_url = stream_url_object['stream_url']
resolution = self.extract_resolution(stream_url) format_list.append({
format_info = {
'format_id': str(format_id), 'format_id': str(format_id),
'url': stream_url, 'url': stream_url,
'resolution': resolution, 'resolution': self.extract_resolution(stream_url),
} })
format_list.append(format_info)
video_info = { video_info = {
'id': media_param, 'id': media_param,