aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/nuevo.py
diff options
context:
space:
mode:
authorAndrew "Akari" Alexeyew <akari@dbc.1gb.ua>2015-12-02 06:00:47 +0200
committerSergey M․ <dstftw@gmail.com>2016-01-22 23:29:24 +0600
commitd570746e45cff3c0f89654bf748e44a5da75a924 (patch)
tree2100d351de4a4e310f7a9a454894369cd2a41de7 /youtube_dl/extractor/nuevo.py
parent4fcd9d147df9b06d954b8f8a1749b50609529ed4 (diff)
downloadyoutube-dl-d570746e45cff3c0f89654bf748e44a5da75a924.tar.xz
[nuevo] Generalize nuevo extractor and add support for trollvids
Supports only the nuevo player for now (most common). [trollvids] convert duration to an int [trollvids] added a test [trollvids] made flake8 shut up Generalized the Nuevo extractor Affects: anitube, trollvids, trutube [nuevo] Complied with the code comments.
Diffstat (limited to 'youtube_dl/extractor/nuevo.py')
-rw-r--r--youtube_dl/extractor/nuevo.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/youtube_dl/extractor/nuevo.py b/youtube_dl/extractor/nuevo.py
new file mode 100644
index 000000000..ccc697e4f
--- /dev/null
+++ b/youtube_dl/extractor/nuevo.py
@@ -0,0 +1,37 @@
+# encoding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from ..utils import (
+ float_or_none,
+ xpath_text
+)
+
+
+class NuevoBaseIE(InfoExtractor):
+ def _extract_nuevo(self, config_url, video_id):
+ tree = self._download_xml(config_url, video_id, transform_source=lambda s: s.strip())
+
+ title = xpath_text(tree, './title')
+ if title:
+ title = title.strip()
+
+ thumbnail = xpath_text(tree, './image')
+ duration = float_or_none(xpath_text(tree, './duration'))
+
+ formats = []
+ for element_name, format_id in (('file', 'sd'), ('filehd', 'hd')):
+ video_url = tree.find(element_name)
+ video_url is None or formats.append({
+ 'format_id': format_id,
+ 'url': video_url.text
+ })
+
+ return {
+ 'id': video_id,
+ 'title': title,
+ 'thumbnail': thumbnail,
+ 'duration': duration,
+ 'formats': formats
+ }