From 319b057bb027d94252c15e7074290c6e357235f8 Mon Sep 17 00:00:00 2001 From: rag-hav Date: Mon, 4 May 2020 20:22:24 +0530 Subject: [PATCH] cache working host to class field --- youtube_dl/extractor/xvideos.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/xvideos.py b/youtube_dl/extractor/xvideos.py index 9e6311570..d320a1a50 100644 --- a/youtube_dl/extractor/xvideos.py +++ b/youtube_dl/extractor/xvideos.py @@ -84,16 +84,21 @@ class XVideosIE(InfoExtractor): 'only_matching': True }] + HOSTS = ['xvideos', 'xvideos2', 'xvideos3'] + def _real_extract(self, url): video_id = self._match_id(url) - HOSTS = ('xvideos', 'xvideos2', 'xvideos3') self.report_download_webpage(video_id) - for host in HOSTS: + for i, host in enumerate(self.HOSTS): + print(host) webpage = self._download_webpage( 'https://www.' + host + '.com/video%s/' % video_id, video_id, - note=False, fatal=host == HOSTS[-1], errnote=host == HOSTS[-1]) + note=False, fatal=host == self.HOSTS[-1], errnote=host == self.HOSTS[-1]) if webpage: + temp_host=self.HOSTS[0] + self.HOSTS[0]=host + self.HOSTS[i]=temp_host break mobj = re.search(r'

(.+?)

', webpage)