mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-03 04:55:25 +02:00
[mtv] imporove duration extraction
This commit is contained in:
parent
8765151c8a
commit
04cbc4980d
@ -111,7 +111,8 @@ def _get_video_info(self, itemdoc):
|
|||||||
uri = itemdoc.find('guid').text
|
uri = itemdoc.find('guid').text
|
||||||
video_id = self._id_from_uri(uri)
|
video_id = self._id_from_uri(uri)
|
||||||
self.report_extraction(video_id)
|
self.report_extraction(video_id)
|
||||||
mediagen_url = itemdoc.find('%s/%s' % (_media_xml_tag('group'), _media_xml_tag('content'))).attrib['url']
|
content_el = itemdoc.find('%s/%s' % (_media_xml_tag('group'), _media_xml_tag('content')))
|
||||||
|
mediagen_url = content_el.attrib['url']
|
||||||
# Remove the templates, like &device={device}
|
# Remove the templates, like &device={device}
|
||||||
mediagen_url = re.sub(r'&[^=]*?={.*?}(?=(&|$))', '', mediagen_url)
|
mediagen_url = re.sub(r'&[^=]*?={.*?}(?=(&|$))', '', mediagen_url)
|
||||||
if 'acceptMethods' not in mediagen_url:
|
if 'acceptMethods' not in mediagen_url:
|
||||||
@ -159,9 +160,6 @@ def _get_video_info(self, itemdoc):
|
|||||||
if mtvn_id_node is not None:
|
if mtvn_id_node is not None:
|
||||||
mtvn_id = mtvn_id_node.text
|
mtvn_id = mtvn_id_node.text
|
||||||
|
|
||||||
content_el = find_xpath_attr(itemdoc, self._xpath_ns('.//content', 'http://search.yahoo.com/mrss/'), 'duration')
|
|
||||||
duration = float_or_none(content_el.attrib.get('duration')) if content_el is not None else None
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'title': title,
|
'title': title,
|
||||||
'formats': self._extract_video_formats(mediagen_doc, mtvn_id),
|
'formats': self._extract_video_formats(mediagen_doc, mtvn_id),
|
||||||
@ -169,7 +167,7 @@ def _get_video_info(self, itemdoc):
|
|||||||
'id': video_id,
|
'id': video_id,
|
||||||
'thumbnail': self._get_thumbnail_url(uri, itemdoc),
|
'thumbnail': self._get_thumbnail_url(uri, itemdoc),
|
||||||
'description': description,
|
'description': description,
|
||||||
'duration': duration,
|
'duration': float_or_none(content_el.attrib.get('duration')),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_feed_query(self, uri):
|
def _get_feed_query(self, uri):
|
||||||
|
Loading…
Reference in New Issue
Block a user