From 94cd0f84d0375075c2ca6d0ca942a058f2d059e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E5=AD=90?= <23428990+0x1f595@users.noreply.github.com> Date: Thu, 19 Aug 2021 20:30:56 -0600 Subject: [PATCH 1/3] [iwara] Add Iwara Playlist support --- youtube_dl/extractor/extractors.py | 5 +++- youtube_dl/extractor/iwara.py | 39 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 6e8fc3961..0ea3b7c9e 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -521,7 +521,10 @@ from .ivi import ( IviCompilationIE ) from .ivideon import IvideonIE -from .iwara import IwaraIE +from .iwara import ( + IwaraIE, + IwaraPlaylistIE, +) from .izlesene import IzleseneIE from .jamendo import ( JamendoIE, diff --git a/youtube_dl/extractor/iwara.py b/youtube_dl/extractor/iwara.py index 907d5fc8b..6a4cdb8a7 100644 --- a/youtube_dl/extractor/iwara.py +++ b/youtube_dl/extractor/iwara.py @@ -97,3 +97,42 @@ class IwaraIE(InfoExtractor): 'age_limit': age_limit, 'formats': formats, } + +class IwaraPlaylistIE(InfoExtractor): + IE_NAME = 'iwara:playlist' + _VALID_URL = r'https?://(?:www\.|ecchi\.)?iwara\.tv/playlist/(?P[a-zA-Z0-9-]+)' + _TEST = { + 'url': 'https://ecchi.iwara.tv/playlist/best-enf', + 'info_dict': { + 'title': 'Best enf', + 'uploader_id': 'Jared98112', + 'id': 'best-enf', + }, + 'playlist_mincount': 50, + } + + def _real_extract(self, url): + playlist_id = self._match_id(url) + + webpage, urlh = self._download_webpage_handle(url, playlist_id) + + hostname = compat_urllib_parse_urlparse(urlh.geturl()).hostname + age_limit = 18 if hostname.split('.')[0] == 'ecchi' else 0 + + title = self._html_search_regex(r'

]*?>(.*?)

', webpage, 'title') + uploader_id = self._html_search_regex( + r'
\s*

(.*?)

', + webpage, + 'uploader_id') + urls = re.findall( + r'

\s*', + webpage) + entries = [self.url_result(u) for u in urls] + + return { + '_type': 'playlist', + 'id': playlist_id, + 'uploader_id': uploader_id, + 'title': title, + 'entries': entries, + } From 975fb49d618705b715ddf097d642c265559b19f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E5=AD=90?= <23428990+0x1f595@users.noreply.github.com> Date: Thu, 19 Aug 2021 20:39:33 -0600 Subject: [PATCH 2/3] flake8 fixes --- youtube_dl/extractor/iwara.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/youtube_dl/extractor/iwara.py b/youtube_dl/extractor/iwara.py index 6a4cdb8a7..6c8b4ec9f 100644 --- a/youtube_dl/extractor/iwara.py +++ b/youtube_dl/extractor/iwara.py @@ -1,6 +1,8 @@ # coding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor from ..compat import compat_urllib_parse_urlparse from ..utils import ( @@ -98,6 +100,7 @@ class IwaraIE(InfoExtractor): 'formats': formats, } + class IwaraPlaylistIE(InfoExtractor): IE_NAME = 'iwara:playlist' _VALID_URL = r'https?://(?:www\.|ecchi\.)?iwara\.tv/playlist/(?P[a-zA-Z0-9-]+)' @@ -134,5 +137,6 @@ class IwaraPlaylistIE(InfoExtractor): 'id': playlist_id, 'uploader_id': uploader_id, 'title': title, + 'age_limit': age_limit, 'entries': entries, } From 4130d3b650d497db619f953c2921801b80622da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E5=AD=90?= <23428990+0x1f595@users.noreply.github.com> Date: Thu, 19 Aug 2021 20:42:45 -0600 Subject: [PATCH 3/3] Remove irrelevant playlist attribute --- youtube_dl/extractor/iwara.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/youtube_dl/extractor/iwara.py b/youtube_dl/extractor/iwara.py index 6c8b4ec9f..56e870f7c 100644 --- a/youtube_dl/extractor/iwara.py +++ b/youtube_dl/extractor/iwara.py @@ -117,10 +117,7 @@ class IwaraPlaylistIE(InfoExtractor): def _real_extract(self, url): playlist_id = self._match_id(url) - webpage, urlh = self._download_webpage_handle(url, playlist_id) - - hostname = compat_urllib_parse_urlparse(urlh.geturl()).hostname - age_limit = 18 if hostname.split('.')[0] == 'ecchi' else 0 + webpage = self._download_webpage(url, playlist_id) title = self._html_search_regex(r'

]*?>(.*?)

', webpage, 'title') uploader_id = self._html_search_regex( @@ -137,6 +134,5 @@ class IwaraPlaylistIE(InfoExtractor): 'id': playlist_id, 'uploader_id': uploader_id, 'title': title, - 'age_limit': age_limit, 'entries': entries, }