logo

youtube-dl

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

telemb.py (2966B)


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