logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

livejournal.py (1530B)


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