You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.7 KiB

10 years ago
  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
  7. class YnetIE(InfoExtractor):
  8. _VALID_URL = r'http://(?:.+?\.)?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': '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': '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. return {
  39. 'id': video_id,
  40. 'title': title,
  41. 'formats': self._extract_f4m_formats(f4m_url, video_id),
  42. 'thumbnail': self._og_search_thumbnail(webpage),
  43. }