From 6cb9f4dd5bdc5f9473eea4907c6fce8caf0738e1 Mon Sep 17 00:00:00 2001 From: rag-hav Date: Sun, 3 May 2020 00:31:38 +0530 Subject: [PATCH 1/8] Add xvideos3 to regex --- youtube_dl/extractor/xvideos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/xvideos.py b/youtube_dl/extractor/xvideos.py index 8fc64914c..3e500c5ec 100644 --- a/youtube_dl/extractor/xvideos.py +++ b/youtube_dl/extractor/xvideos.py @@ -17,7 +17,7 @@ class XVideosIE(InfoExtractor): _VALID_URL = r'''(?x) https?:// (?: - (?:[^/]+\.)?xvideos2?\.com/video| + (?:[^/]+\.)?xvideos[23]?\.com/video| (?:www\.)?xvideos\.es/video| flashservice\.xvideos\.com/embedframe/| static-hw\.xvideos\.com/swf/xv-player\.swf\?.*?\bid_video= From 90f5bbf8cd02ab1258ba8f46068318c92ee12b4c Mon Sep 17 00:00:00 2001 From: rag-hav Date: Sun, 3 May 2020 13:02:20 +0530 Subject: [PATCH 2/8] Added Tests, retry with xvideos3 if xvideos fails --- youtube_dl/extractor/xvideos.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/xvideos.py b/youtube_dl/extractor/xvideos.py index 3e500c5ec..b2f2da13c 100644 --- a/youtube_dl/extractor/xvideos.py +++ b/youtube_dl/extractor/xvideos.py @@ -76,13 +76,23 @@ class XVideosIE(InfoExtractor): }, { 'url': 'https://de.xvideos.com/video4588838/biker_takes_his_girl', 'only_matching': True + }, { + 'url': 'https://www.xvideos2.com/video4588838/biker_takes_his_girl', + 'only_matching': True + }, { + 'url': 'https://www.xvideos3.com/video4588838/biker_takes_his_girl', + 'only_matching': True }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage( - 'https://www.xvideos.com/video%s/' % video_id, video_id) + 'https://www.xvideos.com/video%s/' % video_id, video_id, fatal=False) + + if webpage == False: + webpage = self._download_webpage( + 'https://www.xvideos3.com/video%s/' % video_id, video_id) mobj = re.search(r'

(.+?)

', webpage) if mobj: From 9b2e251a00924ad3c7eed29de06831e4fd790d0c Mon Sep 17 00:00:00 2001 From: rag-hav Date: Sun, 3 May 2020 13:27:33 +0530 Subject: [PATCH 3/8] Flake8 correction --- youtube_dl/extractor/xvideos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/xvideos.py b/youtube_dl/extractor/xvideos.py index b2f2da13c..74332c21b 100644 --- a/youtube_dl/extractor/xvideos.py +++ b/youtube_dl/extractor/xvideos.py @@ -90,7 +90,7 @@ class XVideosIE(InfoExtractor): webpage = self._download_webpage( 'https://www.xvideos.com/video%s/' % video_id, video_id, fatal=False) - if webpage == False: + if not webpage: webpage = self._download_webpage( 'https://www.xvideos3.com/video%s/' % video_id, video_id) From a9cef44c2939f3f468e3a236e3dc21d0a718e483 Mon Sep 17 00:00:00 2001 From: rag-hav Date: Sun, 3 May 2020 15:17:32 +0530 Subject: [PATCH 4/8] Try all hosts --- youtube_dl/extractor/xvideos.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/xvideos.py b/youtube_dl/extractor/xvideos.py index 74332c21b..224e711bc 100644 --- a/youtube_dl/extractor/xvideos.py +++ b/youtube_dl/extractor/xvideos.py @@ -87,12 +87,13 @@ class XVideosIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) - webpage = self._download_webpage( - 'https://www.xvideos.com/video%s/' % video_id, video_id, fatal=False) - - if not webpage: + HOSTS = ('xvideos', 'xvideos2', 'xvideos3') + self.report_download_webpage(video_id) + for host in HOSTS: webpage = self._download_webpage( - 'https://www.xvideos3.com/video%s/' % video_id, video_id) + 'https://www.' + host + '.com/video%s/' % video_id, video_id, note=False, fatal=host == HOSTS[-1], errnote=host == HOSTS[-1]) + if webpage: + break mobj = re.search(r'

(.+?)

', webpage) if mobj: From aaa81ca9ff771870e63802f2cebfd4542ec344f5 Mon Sep 17 00:00:00 2001 From: rag-hav Date: Mon, 4 May 2020 15:40:37 +0530 Subject: [PATCH 5/8] coding cnvention --- youtube_dl/extractor/xvideos.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/xvideos.py b/youtube_dl/extractor/xvideos.py index 224e711bc..9e6311570 100644 --- a/youtube_dl/extractor/xvideos.py +++ b/youtube_dl/extractor/xvideos.py @@ -91,7 +91,8 @@ class XVideosIE(InfoExtractor): self.report_download_webpage(video_id) for host in HOSTS: webpage = self._download_webpage( - 'https://www.' + host + '.com/video%s/' % video_id, video_id, note=False, fatal=host == HOSTS[-1], errnote=host == HOSTS[-1]) + 'https://www.' + host + '.com/video%s/' % video_id, video_id, + note=False, fatal=host == HOSTS[-1], errnote=host == HOSTS[-1]) if webpage: break From 319b057bb027d94252c15e7074290c6e357235f8 Mon Sep 17 00:00:00 2001 From: rag-hav Date: Mon, 4 May 2020 20:22:24 +0530 Subject: [PATCH 6/8] 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) From 1c361146ba5d189006ac9c902a856cd552662dbb Mon Sep 17 00:00:00 2001 From: rag-hav Date: Mon, 4 May 2020 22:09:01 +0530 Subject: [PATCH 7/8] coding conventions --- youtube_dl/extractor/xvideos.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/xvideos.py b/youtube_dl/extractor/xvideos.py index d320a1a50..54751d61a 100644 --- a/youtube_dl/extractor/xvideos.py +++ b/youtube_dl/extractor/xvideos.py @@ -96,9 +96,9 @@ class XVideosIE(InfoExtractor): 'https://www.' + host + '.com/video%s/' % video_id, video_id, 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 + temp_host = self.HOSTS[0] + self.HOSTS[0] = host + self.HOSTS[i] = temp_host break mobj = re.search(r'

(.+?)

', webpage) From 2f6051480d464345b92e16fea9e30bdd56396b97 Mon Sep 17 00:00:00 2001 From: rag-hav Date: Wed, 20 May 2020 18:35:46 +0530 Subject: [PATCH 8/8] clean up --- youtube_dl/extractor/xvideos.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/xvideos.py b/youtube_dl/extractor/xvideos.py index 54751d61a..6290bc171 100644 --- a/youtube_dl/extractor/xvideos.py +++ b/youtube_dl/extractor/xvideos.py @@ -91,7 +91,6 @@ class XVideosIE(InfoExtractor): self.report_download_webpage(video_id) 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 == self.HOSTS[-1], errnote=host == self.HOSTS[-1])