vier.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from .common import InfoExtractor
  2. from ..utils import escape_url
  3. import re
  4. class VierIE (InfoExtractor):
  5. _VALID_URL = r'(?:http://)?www.vier.be/(?P<program>.*)/videos/(.+?)/(?P<id>\d*)'
  6. _TEST = {
  7. 'url': 'http://www.vier.be/planb/videos/het-wordt-warm-de-moestuin/16129',
  8. 'md5': 'bf48f4eb998cbde44ecd02fc42c51149',
  9. 'info_dict': {
  10. 'id': '16129',
  11. 'ext': 'mp4',
  12. 'title': 'Het wordt warm in De Moestuin',
  13. 'description': 'De vele uren werk eisen hun tol. Wim droomt van assistentie...',
  14. },
  15. }
  16. def _real_extract (self, url):
  17. mobj = re.match (self._VALID_URL, url)
  18. program = mobj.group ('program')
  19. video_id = mobj.group ('id')
  20. webpage = self._download_webpage (url, video_id)
  21. title = self._html_search_regex(r'<meta property="og:title" content="(.+?)" />', webpage, u'title')
  22. description = self._html_search_regex (r'<meta property="og:description" content="(.+?)" />', webpage, u'description')
  23. vod_id = self._html_search_regex(r'"filename" : "(.+?)"', webpage, u'playlist URL')
  24. url = escape_url ("http://vod.streamcloud.be/vier_vod/mp4:_definst_/" + vod_id + ".mp4/playlist.m3u8")
  25. return {
  26. 'id': video_id,
  27. 'title': title,
  28. 'description': description,
  29. 'formats': self._extract_m3u8_formats(url, video_id, 'mp4'),
  30. }
  31. class VierVideosIE (InfoExtractor):
  32. _VALID_URL = r'http://www.vier.be/(?P<program>.*)/videos(\?page=(?P<page>\d*))?$'
  33. _TESTS = [{
  34. 'url': 'http://www.vier.be/demoestuin/videos',
  35. 'info_dict': {
  36. 'id': 'demoestuin page(0)',
  37. },
  38. 'playlist_mincount': 20,
  39. },
  40. {
  41. 'url': 'http://www.vier.be/demoestuin/videos?page=6',
  42. 'info_dict': {
  43. 'id': 'demoestuin page(6)',
  44. },
  45. 'playlist_mincount': 20,
  46. }]
  47. def _real_extract (self, url):
  48. mobj = re.match (self._VALID_URL, url)
  49. program = mobj.group ('program')
  50. page = mobj.group ('page')
  51. if page == None:
  52. page = 0
  53. videos_id = program + " page(" + str (page) + ")"
  54. videos_page = self._download_webpage (url, videos_id, note='Retrieving videos page')
  55. return {
  56. '_type': 'playlist',
  57. 'id': videos_id,
  58. 'entries': [{
  59. '_type': 'url',
  60. 'url': "http://www.vier.be/" + eurl[0],
  61. 'ie_key': 'Vier',
  62. } for eurl in re.findall (r'<h3><a href="(.+?)">(.+?)</a></h3>', videos_page)]
  63. }