1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-01-23 03:02:58 +08:00

[tv8] add support for chapters

This commit is contained in:
Enes 2018-12-19 18:40:49 +03:00
parent f9e54710ad
commit 795aea8120

View File

@ -1,17 +1,22 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import (
int_or_none,
)
class TV8IE(InfoExtractor): class TV8IE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?tv8\.com\.tr/[^/]+/(?P<id>[^?#&]+)-video\.htm' _VALID_URL = r'https?://(?:www\.)?tv8\.com\.tr/[^/]+/(?P<id>[^?#&]+-video-?(?P<chapter>[0-9]+)?)\.htm'
IE_NAME = 'tv8' IE_NAME = 'tv8'
_TESTS = [{ _TESTS = [{
'url': 'https://www.tv8.com.tr/yemekteyiz/yemekteyiz-281-bolum-13122018-52578-video.htm', 'url': 'https://www.tv8.com.tr/yemekteyiz/yemekteyiz-281-bolum-13122018-52578-video.htm',
'md5': '73be7e69708d37eb77643c12e8598b35', 'md5': '73be7e69708d37eb77643c12e8598b35',
'info_dict': { 'info_dict': {
'id': 'yemekteyiz-281-bolum-13122018-52578', 'id': 'yemekteyiz-281-bolum-13122018-52578-video',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Yemekteyiz 281. bölüm (13/12/2018)', 'title': 'Yemekteyiz 281. bölüm (13/12/2018)',
'description': 'md5:01a9cc2115550dfa3b51772239082f6a', 'description': 'md5:01a9cc2115550dfa3b51772239082f6a',
@ -20,16 +25,24 @@ class TV8IE(InfoExtractor):
'timestamp': 1544780098, 'timestamp': 1544780098,
'upload_date': '20181214', 'upload_date': '20181214',
}, },
},
{
'url': 'https://www.tv8.com.tr/masterchef-turkiye/masterchef-turkiye-30-bolum-11122018-52440-video-3.htm',
'only_matching': True
}] }]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url)
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
chapter_number = int_or_none(mobj.group('chapter')) or 1
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
webpage = webpage.replace('URL', 'Url') webpage = webpage.replace('URL', 'Url')
info = { info = {
'id': video_id, 'id': video_id,
'chapter_number': chapter_number,
} }
json_ld = self._search_regex( json_ld = self._search_regex(