From 4b4839cba64064d6da37f6e13b5e9468c2c1eb12 Mon Sep 17 00:00:00 2001 From: aapjez Date: Fri, 2 Oct 2020 03:13:09 +0200 Subject: [PATCH] Reduce amount of variables --- youtube_dl/extractor/boundhub.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/youtube_dl/extractor/boundhub.py b/youtube_dl/extractor/boundhub.py index b489bae0d..b675d1051 100644 --- a/youtube_dl/extractor/boundhub.py +++ b/youtube_dl/extractor/boundhub.py @@ -28,48 +28,36 @@ class BoundHubIE(InfoExtractor): } def _real_extract(self, url): - video_id = self._match_id(url) - webpage = self._download_webpage(url, video_id) + webpage = self._download_webpage(url, self._match_id(url)) # Parse duration duration_text = self._search_regex(r'\s*Duration:\s*([\w ]*)', webpage, 'duration_text', fatal=False) minutes = self._html_search_regex(r'(\d*)min', duration_text, 'minutes', fatal=False) seconds = self._html_search_regex(r'(\d*)sec', duration_text, 'seconds', fatal=False) - duration = (int(minutes) * 60) + int(seconds) - # Parse views - views_text = self._search_regex(r'\s*Views:\s*([\w ]*)', webpage, 'views_text', fatal=False) - views = int_or_none(views_text.replace(' ', '')) - - # Get uploader url and id + # Get uploader url uploader_url = self._search_regex(r'\s*([\s\S]+?)', webpage, 'html_screenshots', fatal=False) - regex_screenshots = r'([\s\S]+?)', webpage, 'html_screenshots', fatal=False)): img = dict() img['url'] = match.rstrip('/') img['id'] = int_or_none(os.path.splitext(os.path.basename(img['url']))[0]) thumbnails.append(img) return { - 'id': video_id, + 'id': self._match_id(url), 'title': self._search_regex(r'\s*

(.*)

', webpage, 'title', default=None) or self._og_search_title(webpage), 'url': self._search_regex(r'video_url: [\"\']([^\"\']*)[\"\']', webpage, 'url'), 'description': self._search_regex(r'\s*Description:\s*(.*)<\/em>', webpage, 'description', fatal=False), 'display_id': self._html_search_regex(r'https?://(?:www\.)?boundhub\.com/videos/[0-9]+/([\w-]*)', url, 'display_id', fatal=False), - 'duration': duration, + 'duration': (int(minutes) * 60) + int(seconds), 'ext': self._html_search_regex(r'postfix:\s*[\"\']\.([^\"\']*)[\"\']', webpage, 'ext', fatal=False), 'thumbnail': self._html_search_regex(r'preview_url:\s*[\"\']([^\"\']*)[\"\']', webpage, 'thumbnail', fatal=False), 'thumbnails': thumbnails, 'uploader': self._search_regex(r'\s*\s*(.*)\s*
', webpage, 'uploader', fatal=False), - 'uploader_id': uploader_id, + 'uploader_id': int_or_none(self._html_search_regex(r'https?://(?:www\.)?boundhub\.com/members/(\d+)', uploader_url, 'uploader_id', fatal=False)), 'uploader_url': uploader_url, - 'views': views, + 'views': int_or_none(self._search_regex(r'\s*Views:\s*([\w ]*)', webpage, 'views_text', fatal=False).replace(' ', '')), }