2014-11-26 13:01:39 +01:00
|
|
|
from __future__ import unicode_literals
|
2013-08-03 22:50:27 +02:00
|
|
|
|
2018-10-02 18:28:46 +02:00
|
|
|
import json
|
|
|
|
|
2013-08-03 22:50:27 +02:00
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
2014-11-26 13:01:39 +01:00
|
|
|
int_or_none,
|
2015-11-01 22:12:20 +01:00
|
|
|
parse_iso8601,
|
2018-10-02 18:28:46 +02:00
|
|
|
unescapeHTML,
|
|
|
|
sanitize_url,
|
|
|
|
clean_html,
|
|
|
|
get_element_by_attribute,
|
|
|
|
js_to_json,
|
2013-08-03 22:50:27 +02:00
|
|
|
)
|
|
|
|
|
2014-11-23 20:41:03 +01:00
|
|
|
|
2013-08-03 22:50:27 +02:00
|
|
|
class VideofyMeIE(InfoExtractor):
|
2014-11-26 13:01:39 +01:00
|
|
|
_VALID_URL = r'https?://(?:www\.videofy\.me/.+?|p\.videofy\.me/v)/(?P<id>\d+)(&|#|$)'
|
|
|
|
IE_NAME = 'videofy.me'
|
2013-08-03 22:50:27 +02:00
|
|
|
|
2018-10-02 18:28:46 +02:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://www.videofy.me/v/24582',
|
|
|
|
'md5': '1e46140bacdae8959827903cecd054d9',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '24582',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'The VideofyMe app demo!',
|
|
|
|
'description': 'This is VideofyMe.',
|
|
|
|
'upload_date': '20120607',
|
|
|
|
'timestamp': 1339070671,
|
|
|
|
'uploader': 'oskarglauser',
|
|
|
|
'uploader_id': 7010,
|
|
|
|
'view_count': int,
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.videofy.me/v/2975905',
|
|
|
|
'md5': '79ad4498ab14dec72e815a8f85c7641c',
|
2014-11-26 13:01:39 +01:00
|
|
|
'info_dict': {
|
2018-10-02 18:28:46 +02:00
|
|
|
'id': '2975905',
|
2014-11-26 13:01:39 +01:00
|
|
|
'ext': 'mp4',
|
2018-10-02 18:28:46 +02:00
|
|
|
'title': 'But',
|
2015-11-01 22:12:20 +01:00
|
|
|
'description': '',
|
2018-10-02 18:28:46 +02:00
|
|
|
'upload_date': '20180126',
|
|
|
|
'timestamp': 1516931131,
|
|
|
|
'uploader': 'iamatlien',
|
|
|
|
'uploader_id': 1798214,
|
2014-11-26 13:01:39 +01:00
|
|
|
'view_count': int,
|
2013-08-03 22:50:27 +02:00
|
|
|
},
|
2018-10-02 18:28:46 +02:00
|
|
|
},]
|
2013-08-03 22:50:27 +02:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-11-26 13:01:39 +01:00
|
|
|
video_id = self._match_id(url)
|
2015-11-01 22:12:20 +01:00
|
|
|
|
2018-10-02 18:28:46 +02:00
|
|
|
page = self._download_webpage(url, video_id)
|
|
|
|
|
|
|
|
video_info = json.loads(get_element_by_attribute('type', 'application/ld+json', page))
|
2015-11-01 22:12:20 +01:00
|
|
|
|
2018-10-02 18:28:46 +02:00
|
|
|
meta = self._download_json('https://www.videofy.me/wp-json/wp/v2/posts/%s' % video_id, video_id)
|
|
|
|
uploader_id = meta.get('author')
|
|
|
|
uploader_name = self._download_json('https://www.videofy.me/wp-json/wp/v2/users/%s' % uploader_id, uploader_id, fatal=False).get('name')
|
2013-08-03 22:50:27 +02:00
|
|
|
|
2014-11-26 13:01:39 +01:00
|
|
|
return {
|
|
|
|
'id': video_id,
|
2018-10-02 18:28:46 +02:00
|
|
|
'title': video_info['name'],
|
|
|
|
'url': video_info['contentUrl'],
|
|
|
|
'thumbnail': video_info.get('thumbnailUrl'),
|
|
|
|
'description': clean_html(video_info.get('description')),
|
|
|
|
'timestamp': parse_iso8601(video_info.get('uploadDate')),
|
|
|
|
'uploader_id': uploader_id,
|
|
|
|
'uploader': uploader_name,
|
|
|
|
'view_count': int_or_none(video_info.get('interactionCount')),
|
2014-11-26 13:01:39 +01:00
|
|
|
}
|