[joj] Add extractor
authorluboss <lubos.katrinec@gmail.com>
Fri, 2 Jun 2017 20:44:39 +0000 (22:44 +0200)
committerSergey M․ <dstftw@gmail.com>
Sun, 9 Jul 2017 12:17:38 +0000 (19:17 +0700)
youtube_dl/extractor/extractors.py
youtube_dl/extractor/joj.py [new file with mode: 0755]

index 4524fa68766721e24de0da1a669e4a391bd4855e..9ee080895071c1ccd5a56b2b0cdb764061a2ac50 100644 (file)
@@ -470,6 +470,7 @@ from .jamendo import (
 )
 from .jeuxvideo import JeuxVideoIE
 from .jove import JoveIE
+from .joj import JojIE
 from .jwplatform import JWPlatformIE
 from .jpopsukitv import JpopsukiIE
 from .kaltura import KalturaIE
diff --git a/youtube_dl/extractor/joj.py b/youtube_dl/extractor/joj.py
new file mode 100755 (executable)
index 0000000..2ebfec9
--- /dev/null
@@ -0,0 +1,56 @@
+# coding: utf-8\r
+from __future__ import unicode_literals\r
+\r
+from .common import InfoExtractor\r
+import re\r
+\r
+\r
+class JojIE(InfoExtractor):\r
+    _VALID_URL = r'https?://[a-z0-9]+\.joj\.sk/([^/]+/)*(?P<title_query>(?P<release_date>[0-9]{4}(-[0-9]{2}){2}).*)' # noqa\r
+    _TESTS = [{\r
+        'url': 'https://www.joj.sk/nove-byvanie/archiv/2017-05-28-nove-byvanie', # noqa\r
+        'info_dict': {\r
+            'id': 'a388ec4c-6019-4a4a-9312-b1bee194e932',\r
+            'ext': 'mp4',\r
+            'title': 'Nové Bývanie',\r
+            'release_date': '20170528'\r
+        }\r
+    }, {\r
+        'url': 'http://nasi.joj.sk/epizody/2016-09-06-stari-rodicia',\r
+        'info_dict': {\r
+            'id': 'f18b2c5f-9ea8-4941-a164-a814c53306ad',\r
+            'ext': 'mp4',\r
+            'title': 'Starí Rodičia',\r
+            'release_date': '20160906'\r
+        }\r
+    }]\r
+\r
+    media_src_url = 'http://n16.joj.sk/storage/'\r
+    xml_source_url = 'https://media.joj.sk/services/Video.php?clip='\r
+\r
+    def _real_extract(self, url):\r
+        mobj = re.match(self._VALID_URL, url)\r
+        release_date = mobj.group('release_date').replace('-', '')\r
+        webpage = self._download_webpage(url, 'id')\r
+        video_id = self._html_search_regex(\r
+            r'https?://([a-z0-9]+\.)joj\.sk/embed/(?P<video_id>[a-f0-9\-]+)',\r
+            webpage, 'id', group='video_id')\r
+        xml_playlist_url = self.xml_source_url + video_id\r
+        xml_playlist_et = self._download_xml(xml_playlist_url, 'XML playlist')\r
+        formats = []\r
+        for file_el in xml_playlist_et.findall('files/file'):\r
+            try:\r
+                height = int(file_el.attrib['id'].replace('p', ''))\r
+            except ValueError:\r
+                height = 0\r
+            formats.append({'height': height,\r
+                            'url': self.media_src_url + file_el.attrib['path'].replace(  # noqa\r
+                                'dat/', '', 1)})\r
+        self._sort_formats(formats)\r
+\r
+        return {\r
+            'id': video_id,\r
+            'title': self._og_search_title(webpage).title(),\r
+            'formats': formats,\r
+            'release_date': release_date\r
+        }\r