mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-14 13:25:38 +00:00
[mtv] Check for geo-blocked videos in the xml document, not in the xml’s string
Allows to use the `_download_xml` method
This commit is contained in:
parent
ef9f2ba7af
commit
e4f320a4d0
1 changed files with 5 additions and 7 deletions
|
@ -1,7 +1,6 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import xml.etree.ElementTree
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
@ -36,10 +35,9 @@ class MTVServicesInfoExtractor(InfoExtractor):
|
||||||
else:
|
else:
|
||||||
return thumb_node.attrib['url']
|
return thumb_node.attrib['url']
|
||||||
|
|
||||||
def _extract_video_formats(self, metadataXml):
|
def _extract_video_formats(self, mdoc):
|
||||||
if '/error_country_block.swf' in metadataXml:
|
if re.match(r'.*/error_country_block\.swf$', mdoc.find('.//src').text) is not None:
|
||||||
raise ExtractorError('This video is not available from your country.', expected=True)
|
raise ExtractorError('This video is not available from your country.', expected=True)
|
||||||
mdoc = xml.etree.ElementTree.fromstring(metadataXml.encode('utf-8'))
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for rendition in mdoc.findall('.//rendition'):
|
for rendition in mdoc.findall('.//rendition'):
|
||||||
|
@ -65,7 +63,7 @@ class MTVServicesInfoExtractor(InfoExtractor):
|
||||||
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:
|
||||||
mediagen_url += '&acceptMethods=fms'
|
mediagen_url += '&acceptMethods=fms'
|
||||||
mediagen_page = self._download_webpage(mediagen_url, video_id,
|
mediagen_doc = self._download_xml(mediagen_url, video_id,
|
||||||
'Downloading video urls')
|
'Downloading video urls')
|
||||||
|
|
||||||
description_node = itemdoc.find('description')
|
description_node = itemdoc.find('description')
|
||||||
|
@ -76,7 +74,7 @@ class MTVServicesInfoExtractor(InfoExtractor):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'title': itemdoc.find('title').text,
|
'title': itemdoc.find('title').text,
|
||||||
'formats': self._extract_video_formats(mediagen_page),
|
'formats': self._extract_video_formats(mediagen_doc),
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'thumbnail': self._get_thumbnail_url(uri, itemdoc),
|
'thumbnail': self._get_thumbnail_url(uri, itemdoc),
|
||||||
'description': description,
|
'description': description,
|
||||||
|
|
Loading…
Reference in a new issue