telemb.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import remove_start
  4. class TeleMBIE(InfoExtractor):
  5. _WORKING = False
  6. _VALID_URL = r'https?://(?:www\.)?telemb\.be/(?P<display_id>.+?)_d_(?P<id>\d+)\.html'
  7. _TESTS = [
  8. {
  9. 'url': 'http://www.telemb.be/mons-cook-with-danielle-des-cours-de-cuisine-en-anglais-_d_13466.html',
  10. 'md5': 'f45ea69878516ba039835794e0f8f783',
  11. 'info_dict': {
  12. 'id': '13466',
  13. 'display_id': 'mons-cook-with-danielle-des-cours-de-cuisine-en-anglais-',
  14. 'ext': 'mp4',
  15. 'title': 'Mons - Cook with Danielle : des cours de cuisine en anglais ! - Les reportages',
  16. 'description': 'md5:bc5225f47b17c309761c856ad4776265',
  17. 'thumbnail': r're:^http://.*\.(?:jpg|png)$',
  18. },
  19. },
  20. {
  21. # non-ASCII characters in download URL
  22. 'url': 'http://telemb.be/les-reportages-havre-incendie-mortel_d_13514.html',
  23. 'md5': '6e9682736e5ccd4eab7f21e855350733',
  24. 'info_dict': {
  25. 'id': '13514',
  26. 'display_id': 'les-reportages-havre-incendie-mortel',
  27. 'ext': 'mp4',
  28. 'title': 'Havré - Incendie mortel - Les reportages',
  29. 'description': 'md5:5e54cb449acb029c2b7734e2d946bd4a',
  30. 'thumbnail': r're:^http://.*\.(?:jpg|png)$',
  31. },
  32. },
  33. ]
  34. def _real_extract(self, url):
  35. mobj = self._match_valid_url(url)
  36. video_id = mobj.group('id')
  37. display_id = mobj.group('display_id')
  38. webpage = self._download_webpage(url, display_id)
  39. formats = []
  40. for video_url in re.findall(r'file\s*:\s*"([^"]+)"', webpage):
  41. fmt = {
  42. 'url': video_url,
  43. 'format_id': video_url.split(':')[0],
  44. }
  45. rtmp = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>.+))/(?P<playpath>mp4:.+)$', video_url)
  46. if rtmp:
  47. fmt.update({
  48. 'play_path': rtmp.group('playpath'),
  49. 'app': rtmp.group('app'),
  50. 'player_url': 'http://p.jwpcdn.com/6/10/jwplayer.flash.swf',
  51. 'page_url': 'http://www.telemb.be',
  52. 'preference': -10,
  53. })
  54. formats.append(fmt)
  55. title = remove_start(self._og_search_title(webpage), 'TéléMB : ')
  56. description = self._html_search_regex(
  57. r'<meta property="og:description" content="(.+?)" />',
  58. webpage, 'description', fatal=False)
  59. thumbnail = self._og_search_thumbnail(webpage)
  60. return {
  61. 'id': video_id,
  62. 'display_id': display_id,
  63. 'title': title,
  64. 'description': description,
  65. 'thumbnail': thumbnail,
  66. 'formats': formats,
  67. }