From ee1b02ab83bfaea7f343c89c6607f975357bd5da Mon Sep 17 00:00:00 2001 From: SpiderRider067 <36859584+SpiderRider067@users.noreply.github.com> Date: Wed, 30 Dec 2020 20:21:37 -0500 Subject: [PATCH] Added playlist extraction functionality --- youtube_dl/extractor/tasvideos.py | 57 ++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/tasvideos.py b/youtube_dl/extractor/tasvideos.py index 8f12cf70b..e8c82f9c6 100644 --- a/youtube_dl/extractor/tasvideos.py +++ b/youtube_dl/extractor/tasvideos.py @@ -1,8 +1,10 @@ +# coding: utf-8 from __future__ import unicode_literals -from .common import InfoExtractor import re +from .common import InfoExtractor + class TASVideosIE(InfoExtractor): _VALID_URL = r'http://tasvideos.org/(?P\d+M)\.html' @@ -11,7 +13,7 @@ class TASVideosIE(InfoExtractor): 'md5': '8dced25a575e853cec5533a887a8dcfc', 'info_dict': { 'id': '4352M', - 'ext': 'mkv', + 'ext': 'mp4', 'title': 'C64 L\'Abbaye des Morts', } } @@ -25,12 +27,11 @@ class TASVideosIE(InfoExtractor): title = self._search_regex( r'(?P[^<]+)<\/span>', webpage, 'title') + formats = [] - for url in video_urls: - format_entry = {'url': "http://www." + url} + format_entry = {'url': 'http://www.' + url} formats.append(format_entry) - self._sort_formats(formats) return { @@ -38,3 +39,49 @@ class TASVideosIE(InfoExtractor): 'title': title, 'formats': formats, } + + +class TASVideosPlaylistIE(InfoExtractor): + _VALID_URL = r'http://tasvideos.org/(?P<id>Movies-[^\.]*?)\.html' + _TEST = { + 'url': 'http://tasvideos.org/Movies-Stars.html', + 'info_dict': { + 'id': 'Movies-Stars', + 'title': 'TASVideos movies: Tier Stars', + }, + 'playlist_count': 114, + } + + def _real_extract(self, url): + playlist_id = self._match_id(url) + webpage = self._download_webpage(url, playlist_id) + playlist_title = self._search_regex( + r'<title>(?P<title>[^<]*)', webpage, 'title') + video_entries = re.findall( + r'((?s)', webpage) + entries = [] + for entry in video_entries: + video_urls = re.findall( + r']+(?Parchive\.org\/download[^<]+\.(?:mkv|mp4|avi))[^<]+<\/a>', + entry) + title = self._search_regex( + r'(?P[^<]+)<\/span>', entry, + 'title') + video_id = self._search_regex( + r'id="movie_(?P<id>\d+)', entry, 'video id') + 'M' + + formats = [] + for url in video_urls: + format_entry = {'url': "http://www." + url} + formats.append(format_entry) + + self._sort_formats(formats) + + formats = { + 'id': video_id, + 'title': title, + 'formats': formats, + } + entries.append(formats) + + return self.playlist_result(entries, playlist_id, playlist_title)