[trilulilu] extract info from webpage
This commit is contained in:
parent
bee4c5571a
commit
23b1009d19
@ -1,11 +1,14 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
int_or_none,
|
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
|
js_to_json,
|
||||||
|
parse_duration,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -22,10 +25,6 @@ class TriluliluIE(InfoExtractor):
|
|||||||
'uploader_id': 'chipy',
|
'uploader_id': 'chipy',
|
||||||
'upload_date': '20120304',
|
'upload_date': '20120304',
|
||||||
'timestamp': 1330830647,
|
'timestamp': 1330830647,
|
||||||
'uploader': 'chipy',
|
|
||||||
'view_count': int,
|
|
||||||
'like_count': int,
|
|
||||||
'comment_count': int,
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.trilulilu.ro/adena-ft-morreti-inocenta',
|
'url': 'http://www.trilulilu.ro/adena-ft-morreti-inocenta',
|
||||||
@ -37,57 +36,59 @@ class TriluliluIE(InfoExtractor):
|
|||||||
'description': 'pop music',
|
'description': 'pop music',
|
||||||
'uploader_id': 'VEVOmixt',
|
'uploader_id': 'VEVOmixt',
|
||||||
'upload_date': '20151204',
|
'upload_date': '20151204',
|
||||||
'uploader': 'VEVOmixt',
|
|
||||||
'timestamp': 1449187937,
|
'timestamp': 1449187937,
|
||||||
'view_count': int,
|
|
||||||
'like_count': int,
|
|
||||||
'comment_count': int,
|
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
media_info = self._download_json('http://m.trilulilu.ro/%s?format=json' % display_id, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
|
|
||||||
media_class = media_info.get('class')
|
if re.search(r'Fişierul nu este disponibil pentru vizionare în ţara dumneavoastră', webpage):
|
||||||
|
raise ExtractorError(
|
||||||
|
'This video is not available in your country.', expected=True)
|
||||||
|
elif re.search('Fişierul poate fi accesat doar de către prietenii lui', webpage):
|
||||||
|
raise ExtractorError('This video is private.', expected=True)
|
||||||
|
|
||||||
|
player_vars = self._parse_json(
|
||||||
|
self._search_regex(r'(?s)playerVars\s*=\s*({.+?});', webpage, 'player vars'),
|
||||||
|
display_id, js_to_json)
|
||||||
|
|
||||||
|
uploader_id, media_id = self._search_regex(
|
||||||
|
r'<input type="hidden" id="identifier" value="([^"]+)"',
|
||||||
|
webpage, 'identifier').split('|')
|
||||||
|
|
||||||
|
media_class = player_vars.get('fileClass')
|
||||||
if media_class not in ('video', 'audio'):
|
if media_class not in ('video', 'audio'):
|
||||||
raise ExtractorError('not a video or an audio')
|
raise ExtractorError('not a video or an audio')
|
||||||
|
|
||||||
user = media_info.get('user', {})
|
|
||||||
|
|
||||||
thumbnail = media_info.get('cover_url')
|
|
||||||
if thumbnail:
|
|
||||||
thumbnail.format(width='1600', height='1200')
|
|
||||||
|
|
||||||
# TODO: get correct ext for audio files
|
# TODO: get correct ext for audio files
|
||||||
stream_type = media_info.get('stream_type')
|
|
||||||
formats = [{
|
formats = [{
|
||||||
'url': media_info['href'],
|
'url': player_vars['file'],
|
||||||
'ext': stream_type,
|
'ext': player_vars.get('streamType'),
|
||||||
}]
|
}]
|
||||||
if media_info.get('is_hd'):
|
|
||||||
|
hd_url = player_vars.get('fileUrlHD')
|
||||||
|
if hd_url:
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': 'hd',
|
'format_id': 'hd',
|
||||||
'url': media_info['hrefhd'],
|
'url': hd_url,
|
||||||
'ext': stream_type,
|
'ext': player_vars.get('fileTypeHD'),
|
||||||
})
|
})
|
||||||
|
|
||||||
if media_class == 'audio':
|
if media_class == 'audio':
|
||||||
formats[0]['vcodec'] = 'none'
|
formats[0]['vcodec'] = 'none'
|
||||||
else:
|
else:
|
||||||
formats[0]['format_id'] = 'sd'
|
formats[0]['format_id'] = 'sd'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': media_info['identifier'].split('|')[1],
|
'id': media_id,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'title': media_info['title'],
|
'title': self._og_search_title(webpage),
|
||||||
'description': media_info.get('description'),
|
'description': self._og_search_description(webpage),
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': player_vars.get('image'),
|
||||||
'uploader_id': user.get('username'),
|
'uploader_id': uploader_id,
|
||||||
'uploader': user.get('fullname'),
|
'timestamp': parse_iso8601(self._html_search_meta('uploadDate', webpage), ' '),
|
||||||
'timestamp': parse_iso8601(media_info.get('published'), ' '),
|
'duration': parse_duration(self._html_search_meta('duration', webpage)),
|
||||||
'duration': int_or_none(media_info.get('duration')),
|
|
||||||
'view_count': int_or_none(media_info.get('count_views')),
|
|
||||||
'like_count': int_or_none(media_info.get('count_likes')),
|
|
||||||
'comment_count': int_or_none(media_info.get('count_comments')),
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user