]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/livejournal.py
debian/changelog: Wrap long line.
[youtubedl] / youtube_dl / extractor / livejournal.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_str
6 from ..utils import int_or_none
7
8
9 class LiveJournalIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:[^.]+\.)?livejournal\.com/video/album/\d+.+?\bid=(?P<id>\d+)'
11 _TEST = {
12 'url': 'https://andrei-bt.livejournal.com/video/album/407/?mode=view&id=51272',
13 'md5': 'adaf018388572ced8a6f301ace49d4b2',
14 'info_dict': {
15 'id': '1263729',
16 'ext': 'mp4',
17 'title': 'Истребители против БПЛА',
18 'upload_date': '20190624',
19 'timestamp': 1561406715,
20 }
21 }
22
23 def _real_extract(self, url):
24 video_id = self._match_id(url)
25 webpage = self._download_webpage(url, video_id)
26 record = self._parse_json(self._search_regex(
27 r'Site\.page\s*=\s*({.+?});', webpage,
28 'page data'), video_id)['video']['record']
29 storage_id = compat_str(record['storageid'])
30 title = record.get('name')
31 if title:
32 # remove filename extension(.mp4, .mov, etc...)
33 title = title.rsplit('.', 1)[0]
34 return {
35 '_type': 'url_transparent',
36 'id': video_id,
37 'title': title,
38 'thumbnail': record.get('thumbnail'),
39 'timestamp': int_or_none(record.get('timecreate')),
40 'url': 'eagleplatform:vc.videos.livejournal.com:' + storage_id,
41 'ie_key': 'EaglePlatform',
42 }