[kanal2]: Revert "[kanal2]: avoid shadowing variables from outer scope"
This reverts commits 4dc705f6d and 4dc705f6d
This commit is contained in:
parent
9ee6cd55b2
commit
f3bc82bcb7
@ -42,8 +42,25 @@ class Kanal2IE(InfoExtractor):
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
def _real_extract(self, url_):
|
def _real_extract(self, url):
|
||||||
def get_title(info):
|
video_id = self._match_id(url)
|
||||||
|
playlist = self.get_playlist(video_id)
|
||||||
|
|
||||||
|
# return a dict, description from here:
|
||||||
|
# https://github.com/rg3/youtube-dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extractor/common.py#L94-L303
|
||||||
|
info = {
|
||||||
|
'id': video_id,
|
||||||
|
'title': self.get_title(playlist['info']),
|
||||||
|
'description': playlist['info'].get('description'),
|
||||||
|
'webpage_url': playlist['data'].get('url'),
|
||||||
|
'thumbnail': playlist['data'].get('image'),
|
||||||
|
'formats': self.get_formats(playlist, video_id),
|
||||||
|
'timestamp': self.get_timestamp(playlist['info']['subtitle']),
|
||||||
|
}
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
|
def get_title(self, info):
|
||||||
title = info['title']
|
title = info['title']
|
||||||
|
|
||||||
if info['subtitle']:
|
if info['subtitle']:
|
||||||
@ -51,7 +68,7 @@ class Kanal2IE(InfoExtractor):
|
|||||||
|
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def get_timestamp(subtitle):
|
def get_timestamp(self, subtitle):
|
||||||
# Extract timestamp from:
|
# Extract timestamp from:
|
||||||
# "subtitle": "Osa 53 (05.08.2016 20:00)",
|
# "subtitle": "Osa 53 (05.08.2016 20:00)",
|
||||||
match = self._search_regex(self.SUBTITLE_DATE_RE, subtitle, 'dateandtime', default=None)
|
match = self._search_regex(self.SUBTITLE_DATE_RE, subtitle, 'dateandtime', default=None)
|
||||||
@ -64,9 +81,9 @@ class Kanal2IE(InfoExtractor):
|
|||||||
|
|
||||||
return int(unixtime)
|
return int(unixtime)
|
||||||
|
|
||||||
def get_formats(playlist, video_id):
|
def get_formats(self, playlist, video_id):
|
||||||
formats = []
|
formats = []
|
||||||
session = get_session(playlist['data']['path'], video_id)
|
session = self.get_session(playlist['data']['path'], video_id)
|
||||||
sid = session.get('session')
|
sid = session.get('session')
|
||||||
for stream in playlist['data']['streams']:
|
for stream in playlist['data']['streams']:
|
||||||
formats.append({
|
formats.append({
|
||||||
@ -79,7 +96,7 @@ class Kanal2IE(InfoExtractor):
|
|||||||
|
|
||||||
return formats
|
return formats
|
||||||
|
|
||||||
def get_playlist(video_id):
|
def get_playlist(self, video_id):
|
||||||
url = 'https://kanal2.postimees.ee/player/playlist/%(video_id)s?type=episodes' % {'video_id': video_id}
|
url = 'https://kanal2.postimees.ee/player/playlist/%(video_id)s?type=episodes' % {'video_id': video_id}
|
||||||
headers = {
|
headers = {
|
||||||
'X-Requested-With': 'XMLHttpRequest',
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
@ -87,7 +104,7 @@ class Kanal2IE(InfoExtractor):
|
|||||||
|
|
||||||
return self._download_json(url, video_id, headers=headers)
|
return self._download_json(url, video_id, headers=headers)
|
||||||
|
|
||||||
def get_session(path, video_id):
|
def get_session(self, path, video_id):
|
||||||
url = 'https://sts.postimees.ee/session/register'
|
url = 'https://sts.postimees.ee/session/register'
|
||||||
headers = {
|
headers = {
|
||||||
'X-Original-URI': path,
|
'X-Original-URI': path,
|
||||||
@ -100,23 +117,3 @@ class Kanal2IE(InfoExtractor):
|
|||||||
raise ExtractorError('%s: Unable to obtain session' % self.IE_NAME)
|
raise ExtractorError('%s: Unable to obtain session' % self.IE_NAME)
|
||||||
|
|
||||||
return session
|
return session
|
||||||
|
|
||||||
def extract_info(url):
|
|
||||||
video_id = self._match_id(url)
|
|
||||||
playlist = get_playlist(video_id)
|
|
||||||
|
|
||||||
# return a dict, description from here:
|
|
||||||
# https://github.com/rg3/youtube-dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extractor/common.py#L94-L303
|
|
||||||
info = {
|
|
||||||
'id': video_id,
|
|
||||||
'title': get_title(playlist['info']),
|
|
||||||
'description': playlist['info'].get('description'),
|
|
||||||
'webpage_url': playlist['data'].get('url'),
|
|
||||||
'thumbnail': playlist['data'].get('image'),
|
|
||||||
'formats': get_formats(playlist, video_id),
|
|
||||||
'timestamp': get_timestamp(playlist['info']['subtitle']),
|
|
||||||
}
|
|
||||||
|
|
||||||
return info
|
|
||||||
|
|
||||||
return extract_info(url_)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user