projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ca0e7a2
)
[nosvideo] Make more robust against missing metadata
author
Naglis Jonaitis
<njonaitis@gmail.com>
Mon, 15 Sep 2014 13:59:03 +0000
(16:59 +0300)
committer
Naglis Jonaitis
<njonaitis@gmail.com>
Mon, 15 Sep 2014 13:59:03 +0000
(16:59 +0300)
youtube_dl/extractor/nosvideo.py
patch
|
blob
|
history
diff --git
a/youtube_dl/extractor/nosvideo.py
b/youtube_dl/extractor/nosvideo.py
index 8c2c428fc1f90a9f09f8bf4dad262fec1818a2cb..f3be8f552c3764995057acf18b74514537960d4e 100644
(file)
--- a/
youtube_dl/extractor/nosvideo.py
+++ b/
youtube_dl/extractor/nosvideo.py
@@
-8,11
+8,11
@@
from ..utils import (
ExtractorError,
compat_urllib_request,
urlencode_postdata,
ExtractorError,
compat_urllib_request,
urlencode_postdata,
+ xpath_text,
xpath_with_ns,
)
_x = lambda p: xpath_with_ns(p, {'xspf': 'http://xspf.org/ns/0/'})
xpath_with_ns,
)
_x = lambda p: xpath_with_ns(p, {'xspf': 'http://xspf.org/ns/0/'})
-_find = lambda el, p: el.find(_x(p)).text.strip()
class NosVideoIE(InfoExtractor):
class NosVideoIE(InfoExtractor):
@@
-53,9
+53,15
@@
class NosVideoIE(InfoExtractor):
playlist = self._download_xml(playlist_url, video_id)
track = playlist.find(_x('.//xspf:track'))
playlist = self._download_xml(playlist_url, video_id)
track = playlist.find(_x('.//xspf:track'))
- title = _find(track, './xspf:title')
- url = _find(track, './xspf:file')
- thumbnail = _find(track, './xspf:image')
+ if track is None:
+ raise ExtractorError(
+ 'XML playlist is missing the \'track\' element',
+ expected=True)
+ title = xpath_text(track, _x('./xspf:title'), 'title')
+ url = xpath_text(track, _x('./xspf:file'), 'URL', fatal=True)
+ thumbnail = xpath_text(track, _x('./xspf:image'), 'thumbnail')
+ if title is not None:
+ title = title.strip()
formats = [{
'format_id': 'sd',
formats = [{
'format_id': 'sd',