[Joj] Code cleanup
This commit is contained in:
parent
d24ace4c8f
commit
5f65d99ea2
@ -2,52 +2,55 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class JojIE(InfoExtractor):
|
class JojIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?P<prefix>[a-z0-9]+\.)joj\.sk/([^/]+/)*(?P<url_title>(?P<timestamp>[0-9]{4}(-[0-9]{2}){2}).*)' # noqa
|
_VALID_URL = r'https?://([a-z0-9]+\.)joj\.sk/([^/]+/)*(?P<title_query>(?P<release_date>[0-9]{4}(-[0-9]{2}){2}).*)' # noqa
|
||||||
_TESTS = [ {
|
_TESTS = [{
|
||||||
'url': 'https://www.joj.sk/nove-byvanie/archiv/2017-05-28-nove-byvanie', # noqa
|
'url': 'https://www.joj.sk/nove-byvanie/archiv/2017-05-28-nove-byvanie', # noqa
|
||||||
'md5': '731727f2caf35a3fcaf556853f92b6e1',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'a388ec4c-6019-4a4a-9312-b1bee194e932',
|
'id': 'a388ec4c-6019-4a4a-9312-b1bee194e932',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': '2017-05-28 - Nové Bývanie'
|
'title': 'Nové Bývanie',
|
||||||
|
'release_date': '20170528'
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://nasi.joj.sk/epizody/2016-09-06-stari-rodicia', # noqa
|
'url': 'http://nasi.joj.sk/epizody/2016-09-06-stari-rodicia',
|
||||||
'md5': '13626f2d9e237a17ea72bcaaf2738311',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'f18b2c5f-9ea8-4941-a164-a814c53306ad',
|
'id': 'f18b2c5f-9ea8-4941-a164-a814c53306ad',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': '2016-09-06 - Starí Rodičia'
|
'title': 'Starí Rodičia',
|
||||||
|
'release_date': '20160906'
|
||||||
}
|
}
|
||||||
} ]
|
}]
|
||||||
# http://nasi.joj.sk/epizody/2016-09-06-stari-rodicia
|
|
||||||
# https://velkenoviny.joj.sk/archiv/2017-05-29-noviny-tv-joj
|
media_src_url = 'http://n16.joj.sk/storage/'
|
||||||
|
xml_source_url = 'https://media.joj.sk/services/Video.php?clip='
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
title_query = self._search_regex(self._VALID_URL, url, 'title_query',
|
mobj = re.match(self._VALID_URL, url)
|
||||||
group='url_title')
|
title_query = mobj.group('title_query')
|
||||||
timestamp = self._search_regex(self._VALID_URL, url, 'timestamp',
|
release_date = mobj.group('release_date').replace('-', '')
|
||||||
group='timestamp', fatal=False)
|
webpage = self._download_webpage(url, 'video_id')
|
||||||
# timestamp = '2017-05-28'
|
|
||||||
webpage = self._download_webpage(url, title_query)
|
|
||||||
title_simple = self._og_search_title(webpage).title()
|
|
||||||
title = "{timestamp} - {title_simple}".format(**locals())
|
|
||||||
video_id = self._html_search_regex(
|
video_id = self._html_search_regex(
|
||||||
r'<iframe src="https://media.joj.sk/embed/(?P<id>[^\?]+)', webpage,
|
r'https?://([a-z0-9]+\.)joj\.sk/embed/(?P<video_id>[a-f0-9\-]+)', webpage,
|
||||||
'id')
|
'id', group='video_id', default=None)
|
||||||
xml_url = "https://media.joj.sk/services/Video.php?clip=" + video_id
|
print(video_id)
|
||||||
xml_playlist = self._download_webpage(xml_url, title)
|
xml_playlist_url = self.xml_source_url + video_id
|
||||||
path_to_media = self._html_search_regex(
|
xml_playlist_et = self._download_xml(xml_playlist_url, title_query)
|
||||||
r'label="720p" path="(?P<path_to_media>[^"]+)"/>', xml_playlist,
|
formats = []
|
||||||
'path_to_media', group='path_to_media')
|
for file_el in xml_playlist_et.iter('file'):
|
||||||
media_url = 'http://n16.joj.sk/storage/' + path_to_media.replace('dat/', '', 1) # noqa
|
formats.append({'height': file_el.attrib['id'].replace('p', ''),
|
||||||
|
'url': self.media_src_url + file_el.attrib['path'].replace( # noqa
|
||||||
|
'dat/', '', 1)})
|
||||||
|
|
||||||
|
def get_height(d):
|
||||||
|
return d.get('height')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': self._og_search_title(webpage).title(),
|
||||||
'url': media_url
|
'formats': sorted(formats, key=get_height),
|
||||||
# 'display_id': ''
|
'release_date': release_date
|
||||||
# 'description': self._og_search_description(webpage),
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user