telebruxelles.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. import json
  5. from .common import InfoExtractor
  6. class TeleBruxellesIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?telebruxelles\.be/(news|sport|dernier-jt)/?(?P<title>[^\?]+)'
  8. _TESTS = [{
  9. 'url': r'http://www.telebruxelles.be/news/auditions-devant-parlement-francken-galant-tres-attendus/',
  10. 'md5': '59439e568c9ee42fb77588b2096b214f',
  11. 'info_dict': {
  12. 'id': '11942',
  13. 'ext': 'flv',
  14. 'title': 're:Parlement : Francken et Galant répondent aux interpellations*',
  15. 'description': 're:Les auditions des ministres se poursuivent*'
  16. }
  17. }, {
  18. 'url': r'http://www.telebruxelles.be/sport/basket-brussels-bat-mons-80-74/',
  19. 'md5': '181d3fbdcf20b909309e5aef5c6c6047',
  20. 'info_dict': {
  21. 'id': '10091',
  22. 'ext': 'flv',
  23. 'title': 'Basket : le Brussels bat Mons 80-74',
  24. 'description': 're:Ils l\u2019on fait ! En basket, le B*'
  25. }
  26. }]
  27. def _real_extract(self, url):
  28. mobj = re.match(self._VALID_URL, url)
  29. title = mobj.group('title')
  30. webpage = self._download_webpage(url, title)
  31. article_id = self._html_search_regex(r"<article id=\"post-(\d+)\"", webpage, '0')
  32. title = self._html_search_regex(r'<h1 class=\"entry-title\">(.*?)</h1>', webpage, 'title')
  33. description = self._html_search_regex(r"property=\"og:description\" content=\"(.*?)\"", webpage, 'description', fatal=False)
  34. rtmp_url = self._html_search_regex(r"file: \"(rtmp://\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5}/vod/mp4:\" \+ \"\w+\" \+ \".mp4)\"", webpage, 'url')
  35. rtmp_url = rtmp_url.replace("\" + \"", "")
  36. return {
  37. 'id': article_id,
  38. 'title': title,
  39. 'description': description,
  40. 'url': rtmp_url,
  41. 'ext': 'flv',
  42. 'rtmp_live': True # if rtmpdump is not called with "--live" argument, the download is blocked and can be completed
  43. }