1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-12-04 22:27:55 +01:00
youtube-dl/youtube_dl/extractor/videofyme.py

70 lines
2.2 KiB
Python
Raw Normal View History

2014-11-26 13:01:39 +01:00
from __future__ import unicode_literals
import json
from .common import InfoExtractor
from ..utils import (
2014-11-26 13:01:39 +01:00
int_or_none,
parse_iso8601,
clean_html,
get_element_by_attribute,
)
2014-11-23 20:41:03 +01: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'
_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,
},
}, {
2018-10-02 18:36:33 +02:00
'url': 'https://www.videofy.me/v/2975905',
'md5': '79ad4498ab14dec72e815a8f85c7641c',
2014-11-26 13:01:39 +01:00
'info_dict': {
'id': '2975905',
2014-11-26 13:01:39 +01:00
'ext': 'mp4',
'title': 'But',
'description': '',
'upload_date': '20180126',
'timestamp': 1516931131,
'uploader': 'iamatlien',
'uploader_id': 1798214,
2014-11-26 13:01:39 +01:00
'view_count': int,
},
2018-10-02 18:36:33 +02:00
}]
def _real_extract(self, url):
2014-11-26 13:01:39 +01:00
video_id = self._match_id(url)
page = self._download_webpage(url, video_id)
video_info = json.loads(get_element_by_attribute('type', 'application/ld+json', page))
meta = self._download_json('https://www.videofy.me/wp-json/wp/v2/posts/%s' % video_id, video_id)
uploader_id = meta.get('author')
2018-10-02 18:36:33 +02:00
uploader_name = self._download_json('https://www.videofy.me/wp-json/wp/v2/users/%s' % uploader_id, uploader_id, fatal=False).get('name')
2014-11-26 13:01:39 +01:00
return {
'id': video_id,
'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
}