--- /dev/null
+# 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