clean code

This commit is contained in:
EGA-SUPREMO 2024-05-19 12:09:27 -04:00
parent 151b383fe1
commit ec01710224

View File

@ -1,48 +1,36 @@
from .common import InfoExtractor from .common import InfoExtractor
import re
class CableCastTVIE(InfoExtractor): class CableCastTVIE(InfoExtractor):
_VALID_URL = r'https://wctv\.wilmette\.com/CablecastPublicSite/show/(?P<id>\d+)' _VALID_URL = r'https://wctv\.wilmette\.com/CablecastPublicSite/show/(?P<id>\d+)'
_TESTS = [{ _TESTS = [{
'url': 'https://wctv.wilmette.com/CablecastPublicSite/show/532', 'url': 'https://wctv.wilmette.com/CablecastPublicSite/show/532',
'md5': 'fc12bce4a9c1335f153500c8fea6e1a8', 'md5': '17e7ed129582babf6d1ae5c3b9d70d18',
'info_dict': { 'info_dict': {
'id': '532', 'id': '532',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Village Board Meeting 4/24/24', 'title': 'Village Board Meeting 4/24/24',
}, },
}, {
'url': 'https://wctv.wilmette.com/CablecastPublicSite/show/53/',
'only_matching': True,
}] }]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
with open('output.txt', 'w', encoding='utf-8') as file: url_video_page = self._html_search_regex(r'<iframe[^>]*class=\"trms-player\"[^>]*src=\"([^\"]+)\"', webpage, 'url_video_webpage')
file.write(webpage) webpage_video = self._download_webpage(url_video_page, video_id)
url_video_webpage = self._html_search_regex(r'<iframe[^>]*class=\"trms-player\"[^>]*src=\"([^\"]+)\"', webpage, 'url_video_webpage')
webpage_video = self._download_webpage(url_video_webpage, video_id)
video_url = self._html_search_regex(r'"([^\"]*\.m3u8)"', webpage_video, 'video URL') video_url = self._html_search_regex(r'"([^\"]*\.m3u8)"', webpage_video, 'video URL')
print(video_url)
formats = [] formats = []
formats.extend(self._extract_m3u8_formats(video_url, video_id, ext='mp4', m3u8_id='hls')) formats.extend(self._extract_m3u8_formats(video_url, video_id, ext='mp4', m3u8_id='hls'))
print(formats)
#format_url = re.sub(r'\\', '', format_url)
title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title') title = self._og_search_title(webpage) or self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title')
# base_url = re.search(r'^(https?://[a-zA-Z0-9_-]+\.to)', url).group(1)
# http_headers = {'Referer': base_url}
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,
'formats': formats, 'formats': formats,
# 'http_headers': http_headers
} }