From 3ebec36fb973314d33b8578f4c5700ab95a17e31 Mon Sep 17 00:00:00 2001 From: Douglas Christman Date: Fri, 19 Oct 2018 22:24:27 -0400 Subject: [PATCH 1/2] [line] Relax _VALID_URL --- youtube_dl/extractor/line.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/line.py b/youtube_dl/extractor/line.py index 7f5fa446e..8ef9c22c3 100644 --- a/youtube_dl/extractor/line.py +++ b/youtube_dl/extractor/line.py @@ -8,12 +8,12 @@ from ..utils import js_to_json class LineTVIE(InfoExtractor): - _VALID_URL = r'https?://tv\.line\.me/v/(?P\d+)_[^/]+-(?Pep\d+-\d+)' + _VALID_URL = r'https?://tv\.line\.me/v/(?P\d+)_[^/]+' _TESTS = [{ 'url': 'https://tv.line.me/v/793123_goodbye-mrblack-ep1-1/list/69246', 'info_dict': { - 'id': '793123_ep1-1', + 'id': '793123', 'ext': 'mp4', 'title': 'Goodbye Mr.Black | EP.1-1', 'thumbnail': r're:^https?://.*\.jpg$', @@ -23,12 +23,13 @@ class LineTVIE(InfoExtractor): }, { 'url': 'https://tv.line.me/v/2587507_%E6%B4%BE%E9%81%A3%E5%A5%B3%E9%86%ABx-ep1-02/list/185245', 'only_matching': True, + }, { + 'url': 'https://tv.line.me/v/1730228_%E6%A5%B5%E5%93%81%E7%B5%95%E9%85%8D-%E6%9B%9D%E9%9C%B2%E7%AF%87-%E5%8A%87%E6%83%85%E9%A0%90%E5%91%8A/list/132023', + 'only_matching': True, }] def _real_extract(self, url): - series_id, segment = re.match(self._VALID_URL, url).groups() - video_id = '%s_%s' % (series_id, segment) - + video_id = re.match(self._VALID_URL, url).group('id') webpage = self._download_webpage(url, video_id) player_params = self._parse_json(self._search_regex( From 9a1ddf75d281416b59964fdbf155762f05c7cf9b Mon Sep 17 00:00:00 2001 From: Douglas Christman Date: Fri, 19 Oct 2018 22:26:08 -0400 Subject: [PATCH 2/2] [line] Add playlist support --- youtube_dl/extractor/extractors.py | 5 +++- youtube_dl/extractor/line.py | 46 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 17b576df3..16adb8b45 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -568,7 +568,10 @@ from .limelight import ( LimelightChannelIE, LimelightChannelListIE, ) -from .line import LineTVIE +from .line import ( + LineTVIE, + LineTVPlaylistIE, +) from .litv import LiTVIE from .liveleak import ( LiveLeakIE, diff --git a/youtube_dl/extractor/line.py b/youtube_dl/extractor/line.py index 8ef9c22c3..608b569e0 100644 --- a/youtube_dl/extractor/line.py +++ b/youtube_dl/extractor/line.py @@ -89,3 +89,49 @@ class LineTVIE(InfoExtractor): for thumbnail in video_info.get('thumbnails', {}).get('list', [])], 'view_count': video_info.get('meta', {}).get('count'), } + + +class LineTVPlaylistIE(InfoExtractor): + _VALID_URL = r'https?://tv\.line\.me/v/(?P[0-9]+)/list/(?P[0-9]+)' + + _TEST = { + 'url': 'https://tv.line.me/v/1736524/list/132427', + 'info_dict': { + 'id': '132427', + 'title': '極品絕配 EP01' + }, + 'playlist_count': 7, + } + + def _real_extract(self, url): + url_re = re.compile(self._VALID_URL) + m = url_re.match(url) + playlist_id = m.group('id') + segment_id = m.group('segment') + + webpage = self._download_webpage(url, playlist_id) + playlist_title = self._search_regex( + r']+class="_playlist_name"[^>]*>([^<]+)', + webpage, 'playlist_title') + series_title = self._search_regex( + r"'vpt.title',\s*'([^']+)", + webpage, 'series_title') + + playlist = self._download_webpage( + 'https://tv.line.me/api/%s/playlist/%s/%s/false/false' % (segment_id, series_title, playlist_id), + playlist_id) + segment_paths = re.findall( + r']+class="vod_item3"[^>]*>[^<]*]+href="(/v/[^/]+/list/[^"]+)', + playlist) + segment_titles = re.findall( + r']+title="([^"]+)', + playlist) + + entries = [ + self.url_result( + 'https://tv.line.me' + segment_path, + ie='LineTV', video_title=segment_title) + for segment_path, segment_title in zip(segment_paths, segment_titles) + ] + + return self.playlist_result(entries, playlist_id, playlist_title)