logo

youtube-dl

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

ynet.py (1807B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. import json
  5. from .common import InfoExtractor
  6. from ..compat import compat_urllib_parse_unquote_plus
  7. class YnetIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:.+?\.)?ynet\.co\.il/(?:.+?/)?0,7340,(?P<id>L(?:-[0-9]+)+),00\.html'
  9. _TESTS = [
  10. {
  11. 'url': 'http://hot.ynet.co.il/home/0,7340,L-11659-99244,00.html',
  12. 'info_dict': {
  13. 'id': 'L-11659-99244',
  14. 'ext': 'flv',
  15. 'title': 'איש לא יודע מאיפה באנו',
  16. 'thumbnail': r're:^https?://.*\.jpg',
  17. }
  18. }, {
  19. 'url': 'http://hot.ynet.co.il/home/0,7340,L-8859-84418,00.html',
  20. 'info_dict': {
  21. 'id': 'L-8859-84418',
  22. 'ext': 'flv',
  23. 'title': "צפו: הנשיקה הלוהטת של תורגי' ויוליה פלוטקין",
  24. 'thumbnail': r're:^https?://.*\.jpg',
  25. }
  26. }
  27. ]
  28. def _real_extract(self, url):
  29. video_id = self._match_id(url)
  30. webpage = self._download_webpage(url, video_id)
  31. content = compat_urllib_parse_unquote_plus(self._og_search_video_url(webpage))
  32. config = json.loads(self._search_regex(r'config=({.+?})$', content, 'video config'))
  33. f4m_url = config['clip']['url']
  34. title = self._og_search_title(webpage)
  35. m = re.search(r'ynet - HOT -- (["\']+)(?P<title>.+?)\1', title)
  36. if m:
  37. title = m.group('title')
  38. formats = self._extract_f4m_formats(f4m_url, video_id)
  39. self._sort_formats(formats)
  40. return {
  41. 'id': video_id,
  42. 'title': title,
  43. 'formats': formats,
  44. 'thumbnail': self._og_search_thumbnail(webpage),
  45. }