[ora] Revert extraction to regexes
It's less fragile than using js_to_json with ora js
This commit is contained in:
		| @@ -6,15 +6,14 @@ from .common import InfoExtractor | |||||||
| from ..compat import compat_urlparse | from ..compat import compat_urlparse | ||||||
| from ..utils import ( | from ..utils import ( | ||||||
|     get_element_by_attribute, |     get_element_by_attribute, | ||||||
|     js_to_json, |  | ||||||
|     qualities, |     qualities, | ||||||
|     unescapeHTML, |     unescapeHTML, | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  |  | ||||||
| class OraTVIE(InfoExtractor): | class OraTVIE(InfoExtractor): | ||||||
|     _VALID_URL = r'https?://(?:www\.)?(ora\.tv|unsafespeech\.com)/([^/]+/)*(?P<id>[^/\?#]+)' |     _VALID_URL = r'https?://(?:www\.)?(?:ora\.tv|unsafespeech\.com)/([^/]+/)*(?P<id>[^/\?#]+)' | ||||||
|     _TEST = { |     _TESTS = [{ | ||||||
|         'url': 'https://www.ora.tv/larrykingnow/2015/12/16/vine-youtube-stars-zach-king-king-bach-on-their-viral-videos-0_36jupg6090pq', |         'url': 'https://www.ora.tv/larrykingnow/2015/12/16/vine-youtube-stars-zach-king-king-bach-on-their-viral-videos-0_36jupg6090pq', | ||||||
|         'md5': 'fa33717591c631ec93b04b0e330df786', |         'md5': 'fa33717591c631ec93b04b0e330df786', | ||||||
|         'info_dict': { |         'info_dict': { | ||||||
| @@ -23,19 +22,19 @@ class OraTVIE(InfoExtractor): | |||||||
|             'title': 'Vine & YouTube Stars Zach King & King Bach On Their Viral Videos!', |             'title': 'Vine & YouTube Stars Zach King & King Bach On Their Viral Videos!', | ||||||
|             'description': 'md5:ebbc5b1424dd5dba7be7538148287ac1', |             'description': 'md5:ebbc5b1424dd5dba7be7538148287ac1', | ||||||
|         } |         } | ||||||
|     } |     }, { | ||||||
|  |         'url': 'http://www.unsafespeech.com/video/2016/5/10/student-self-censorship-and-the-thought-police-on-university-campuses-0_6622bnkppw4d', | ||||||
|  |         'only_matching': True, | ||||||
|  |     }] | ||||||
|  |  | ||||||
|     def _real_extract(self, url): |     def _real_extract(self, url): | ||||||
|         display_id = self._match_id(url) |         display_id = self._match_id(url) | ||||||
|         webpage = self._download_webpage(url, display_id) |         webpage = self._download_webpage(url, display_id) | ||||||
|  |  | ||||||
|         ora_meta = self._parse_json(self._search_regex( |         video_data = self._search_regex( | ||||||
|             r'(?s);\s*ora_meta = ({.*?});</script>', webpage, 'ora_meta'), display_id, |             r'"(?:video|current)"\s*:\s*({[^}]+?})', webpage, 'current video') | ||||||
|             transform_source=lambda data: js_to_json(re.sub('":(document|\().*?(:false|\(\)),', '":null,', data))) |         m3u8_url = self._search_regex( | ||||||
|  |             r'hls_stream"?\s*:\s*"([^"]+)', video_data, 'm3u8 url', None) | ||||||
|         video_data = ora_meta.get('video', ora_meta.get('current')) |  | ||||||
|         m3u8_url = video_data['hls_stream'] |  | ||||||
|  |  | ||||||
|         if m3u8_url: |         if m3u8_url: | ||||||
|             formats = self._extract_m3u8_formats( |             formats = self._extract_m3u8_formats( | ||||||
|                 m3u8_url, display_id, 'mp4', 'm3u8_native', |                 m3u8_url, display_id, 'mp4', 'm3u8_native', | ||||||
| @@ -64,11 +63,13 @@ class OraTVIE(InfoExtractor): | |||||||
|                 r'"youtube_id"\s*:\s*"([^"]+)', webpage, 'youtube id'), 'Youtube') |                 r'"youtube_id"\s*:\s*"([^"]+)', webpage, 'youtube id'), 'Youtube') | ||||||
|  |  | ||||||
|         return { |         return { | ||||||
|             'id': video_data.get('id', display_id), |             'id': self._search_regex( | ||||||
|  |                 r'"id"\s*:\s*(\d+)', video_data, 'video id', default=display_id), | ||||||
|             'display_id': display_id, |             'display_id': display_id, | ||||||
|             'title': unescapeHTML(self._og_search_title(webpage)), |             'title': unescapeHTML(self._og_search_title(webpage)), | ||||||
|             'description': get_element_by_attribute( |             'description': get_element_by_attribute( | ||||||
|                 'class', 'video_txt_decription', webpage), |                 'class', 'video_txt_decription', webpage), | ||||||
|             'thumbnail': self._proto_relative_url(video_data.get('thumb')), |             'thumbnail': self._proto_relative_url(self._search_regex( | ||||||
|  |                 r'"thumb"\s*:\s*"([^"]+)', video_data, 'thumbnail', None)), | ||||||
|             'formats': formats, |             'formats': formats, | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sergey M․
					Sergey M․