1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-12-02 06:57:44 +00:00
youtube-dl/youtube_dl/extractor/tasvideos.py

88 lines
2.7 KiB
Python
Raw Normal View History

# coding: utf-8
2020-12-25 17:59:26 +00:00
from __future__ import unicode_literals
2020-12-28 01:10:07 +00:00
import re
2020-12-25 17:59:26 +00:00
from .common import InfoExtractor
2020-12-25 17:59:26 +00:00
class TASVideosIE(InfoExtractor):
2020-12-25 17:59:26 +00:00
_VALID_URL = r'http://tasvideos.org/(?P<id>\d+M)\.html'
_TEST = {
'url': 'http://tasvideos.org/4352M.html',
2020-12-30 02:28:35 +00:00
'md5': '8dced25a575e853cec5533a887a8dcfc',
2020-12-25 17:59:26 +00:00
'info_dict': {
'id': '4352M',
'ext': 'mp4',
2020-12-25 17:59:26 +00:00
'title': 'C64 L\'Abbaye des Morts',
}
}
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
2020-12-28 01:10:07 +00:00
video_urls = re.findall(
2020-12-25 21:41:11 +00:00
r'<a [^>]+(?P<URL>archive\.org\/download[^<]+\.(?:mkv|mp4|avi))[^<]+<\/a>',
2020-12-28 01:10:07 +00:00
webpage)
2020-12-25 17:59:26 +00:00
title = self._search_regex(
r'<span title="Movie[^"]+">(?P<TITLE>[^<]+)<\/span>', webpage,
'title')
2020-12-28 01:10:07 +00:00
formats = []
2020-12-28 01:10:07 +00:00
for url in video_urls:
format_entry = {'url': 'http://www.' + url}
2020-12-28 01:10:07 +00:00
formats.append(format_entry)
self._sort_formats(formats)
2020-12-25 17:59:26 +00:00
return {
'id': video_id,
'title': title,
2020-12-28 01:10:07 +00:00
'formats': formats,
2020-12-25 17:59:26 +00:00
}
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>[^<]*)</title>', webpage, 'title')
video_entries = re.findall(
r'((?s)<table class="item".*?archive.*?<\/table)>', webpage)
entries = []
for entry in video_entries:
video_urls = re.findall(
r'<a [^>]+(?P<URL>archive\.org\/download[^<]+\.(?:mkv|mp4|avi))[^<]+<\/a>',
entry)
title = self._search_regex(
r'<span title="Movie[^"]+">(?P<title>[^<]+)<\/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)